Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
refactor: rename rules
Browse files Browse the repository at this point in the history
The previous names were confusing, long and partially redundant.
The new names are:
- blaze-consistent-eventmap-params -> eventmap-params
- no-blaze-lifecycle-assignment -> no-template-lifecycle-assignments
- template-naming-convention -> template-names

BREAKING CHANGE: Rule names have changed.
  • Loading branch information
dferber90 committed Mar 9, 2016
1 parent 0eff690 commit faefe6c
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 36 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ For a more thorough introduction, read the [setup guide](/docs/guides/setup.md).
# List of supported rules

## Best Practices
* [audit-argument-checks](docs/rules/audit-argument-checks.md): Enforce check on all arguments passed to methods and publish functions
* [no-session](docs/rules/no-session.md): Prevent usage of Session
* [no-blaze-lifecycle-assignment](docs/rules/no-blaze-lifecycle-assignment.md): Prevent deprecated template lifecycle callback assignments
* [no-zero-timeout](docs/rules/no-zero-timeout.md): Prevent usage of Meteor.setTimeout with zero delay
* [blaze-consistent-eventmap-params](docs/rules/blaze-consistent-eventmap-params.md): Force consistent event handler parameters in event maps
* [prefer-session-equals](docs/prefer-session-equals.md): Prefer `Session.equals` in conditions
* [template-naming-convention](docs/template-naming-convention.md): Naming convention for templates

* General
* [no-zero-timeout](docs/rules/no-zero-timeout.md): Prevent usage of Meteor.setTimeout with zero delay
* Session
* [no-session](docs/rules/no-session.md): Prevent usage of Session
* [prefer-session-equals](docs/prefer-session-equals.md): Prefer `Session.equals` in conditions
* Security
* [audit-argument-checks](docs/rules/audit-argument-checks.md): Enforce check on all arguments passed to methods and publish functions
* Blaze
* [template-names](docs/template-names.md): Naming convention for templates
* [no-template-lifecycle-assignments](docs/rules/no-template-lifecycle-assignments.md): Prevent deprecated template lifecycle callback assignments
* [eventmap-params](docs/rules/eventmap-params.md): Force consistent event handler parameter names in event maps

## Core API
* *currently no rules implemented*
Expand All @@ -87,10 +91,10 @@ See [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extendi
The rules enabled in this configuration are:
- [audit-argument-checks](docs/rules/audit-argument-checks.md)
- [no-session](docs/rules/no-session.md)
- [no-blaze-lifecycle-assignment](docs/rules/no-blaze-lifecycle-assignment.md)
- [no-template-lifecycle-assignments](docs/rules/no-template-lifecycle-assignments.md)
- [no-zero-timeout](docs/rules/no-zero-timeout.md)
- [blaze-consistent-eventmap-params](docs/rules/blaze-consistent-eventmap-params.md)
- [template-naming-convention](docs/rules/template-naming-convention.md)
- [eventmap-params](docs/rules/eventmap-params.md)
- [template-names](docs/rules/template-names.md)

## Limitations

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Consistent event handler parameters (blaze-consistent-eventmap-params)
# Consistent event handler parameters (eventmap-params)

Force consistent event handler parameters in [event maps](http://docs.meteor.com/#/full/eventmaps)

Expand Down Expand Up @@ -48,21 +48,21 @@ Here are examples of how to do this:

```js
/*
eslint meteor/blaze-consistent-eventmap-params: [2, {"eventParamName": "evt"}]
eslint meteor/eventmap-params: [2, {"eventParamName": "evt"}]
*/
Template.foo.events({
'submit form': function (evt) {}
})

/*
eslint meteor/blaze-consistent-eventmap-params: [2, {"templateInstanceParamName": "tmplInst"}]
eslint meteor/eventmap-params: [2, {"templateInstanceParamName": "tmplInst"}]
*/
Template.foo.events({
'submit form': function (event, tmplInst) {}
})

/*
eslint meteor/blaze-consistent-eventmap-params: [2, {"eventParamName": "evt", "templateInstanceParamName": "tmplInst"}]
eslint meteor/eventmap-params: [2, {"eventParamName": "evt", "templateInstanceParamName": "tmplInst"}]
*/
Template.foo.events({
'submit form': function (evt, tmplInst) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Prevent deprecated template lifecycle callback assignments (no-blaze-lifecycle-assignment)
# Prevent deprecated template lifecycle callback assignments (no-template-lifecycle-assignments)

Assigning lifecycle callbacks to template properties has been deprecated in favor of the more robust template lifecycle callback registration functions.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Force a naming convention for templates (template-naming-convention)
# Force a naming convention for templates (template-names)

When it comes to naming templates there are multiple naming conventions available. Enforce one of them with this rule.

Expand All @@ -14,7 +14,7 @@ The following patterns are considered warnings:

```js

/*eslint meteor/template-naming-convention: [2, "camel-case"]*/
/*eslint meteor/template-names: [2, "camel-case"]*/
Template.foo_bar.onCreated
Template.foo_bar.onRendered
Template.foo_bar.onDestroyed
Expand All @@ -33,18 +33,18 @@ The following patterns are not warnings:

```js

/*eslint meteor/template-naming-convention: [2, "camel-case"]*/
/*eslint meteor/template-names: [2, "camel-case"]*/
Template.fooBar.onCreated
Template.fooBar.onRendered
Template.fooBar.onDestroyed
Template.fooBar.events
Template.fooBar.helpers

/*eslint meteor/template-naming-convention: [2, "pascal-case"]*/
/*eslint meteor/template-names: [2, "pascal-case"]*/
Template.FooBar.onCreated
/* .. */

/*eslint meteor/template-naming-convention: [2, "snake-case"]*/
/*eslint meteor/template-names: [2, "snake-case"]*/
Template.foo.onCreated
Template.foo_bar.onCreated

Expand All @@ -57,7 +57,7 @@ This rule accepts a single options argument with the following defaults:
```json
{
"rules": {
"template-naming-convention": [2, "camel-case"]
"template-names": [2, "camel-case"]
}
}
```
Expand Down
18 changes: 9 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import auditArgumentChecks from './rules/audit-argument-checks'
import noSession from './rules/no-session'
import noBlazeLifecycleAssignment from './rules/no-blaze-lifecycle-assignment'
import noBlazeLifecycleAssignment from './rules/no-template-lifecycle-assignments'
import noZeroTimeout from './rules/no-zero-timeout'
import blazeConsistentEventMapParams from './rules/blaze-consistent-eventmap-params'
import blazeConsistentEventMapParams from './rules/eventmap-params'
import preferSessionEquals from './rules/prefer-session-equals'
import templateNamingConvention from './rules/template-naming-convention'
import templateNamingConvention from './rules/template-names'

export default {
rules: {
'audit-argument-checks': auditArgumentChecks,
'no-session': noSession,
'no-blaze-lifecycle-assignment': noBlazeLifecycleAssignment,
'no-template-lifecycle-assignments': noBlazeLifecycleAssignment,
'no-zero-timeout': noZeroTimeout,
'blaze-consistent-eventmap-params': blazeConsistentEventMapParams,
'eventmap-params': blazeConsistentEventMapParams,
'prefer-session-equals': preferSessionEquals,
'template-naming-convention': templateNamingConvention,
'template-names': templateNamingConvention,
},
configs: {
recommended: {
rules: {
'meteor/audit-argument-checks': 2,
'meteor/no-session': 2,
'meteor/no-blaze-lifecycle-assignment': 2,
'meteor/no-template-lifecycle-assignments': 2,
'meteor/no-zero-timeout': 2,
'meteor/blaze-consistent-eventmap-params': 2,
'meteor/eventmap-params': 2,
'meteor/prefer-session-equals': 0,
'meteor/template-naming-convention': 2,
'meteor/template-names': 2,
},
},
},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
// Requirements
// -----------------------------------------------------------------------------

import rule from '../../../lib/rules/blaze-consistent-eventmap-params'
import rule from '../../../lib/rules/eventmap-params'
import { RuleTester } from 'eslint'

// -----------------------------------------------------------------------------
// Tests
// -----------------------------------------------------------------------------

const ruleTester = new RuleTester()
ruleTester.run('blaze-consistent-eventmap-params', rule, {
ruleTester.run('eventmap-params', rule, {
valid: [
`
Foo.bar.events({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Requirements
// -----------------------------------------------------------------------------

import rule from '../../../lib/rules/no-blaze-lifecycle-assignment'
import rule from '../../../lib/rules/no-template-lifecycle-assignments'
import { RuleTester } from 'eslint'

// -----------------------------------------------------------------------------
Expand All @@ -19,7 +19,7 @@ import { RuleTester } from 'eslint'
const ruleTester = new RuleTester()


ruleTester.run('no-blaze-lifecycle-assignment', rule, {
ruleTester.run('no-template-lifecycle-assignments', rule, {
valid: [
'x += 1',
'Template = true',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// Requirements
// -----------------------------------------------------------------------------

import rule from '../../../lib/rules/template-naming-convention'
import rule from '../../../lib/rules/template-names'
import { RuleTester } from 'eslint'
const ruleTester = new RuleTester()

ruleTester.run('template-naming-convention', rule, {
ruleTester.run('template-names', rule, {
valid: [
'Template.foo.helpers',
'Template.foo01.helpers',
Expand Down

0 comments on commit faefe6c

Please sign in to comment.