mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
refactor: rename rules
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.
This commit is contained in:
24
README.md
24
README.md
@@ -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*
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {}
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
}
|
||||
```
|
||||
18
lib/index.js
18
lib/index.js
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// Requirements
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
import rule from '../../../lib/rules/blaze-consistent-eventmap-params'
|
||||
import rule from '../../../lib/rules/eventmap-params'
|
||||
import { RuleTester } from 'eslint'
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -17,7 +17,7 @@ import { RuleTester } from 'eslint'
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const ruleTester = new RuleTester()
|
||||
ruleTester.run('blaze-consistent-eventmap-params', rule, {
|
||||
ruleTester.run('eventmap-params', rule, {
|
||||
valid: [
|
||||
`
|
||||
Foo.bar.events({
|
||||
@@ -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'
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -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',
|
||||
@@ -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',
|
||||
Reference in New Issue
Block a user