From faefe6c5d151f536c7d3dfd63673701ee3fab07f Mon Sep 17 00:00:00 2001 From: Dominik Ferber Date: Wed, 9 Mar 2016 18:38:23 +0100 Subject: [PATCH] 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. --- README.md | 24 +++++++++++-------- ...-eventmap-params.md => eventmap-params.md} | 8 +++---- ...d => no-template-lifecycle-assignments.md} | 2 +- ...naming-convention.md => template-names.md} | 12 +++++----- lib/index.js | 18 +++++++------- ...-eventmap-params.js => eventmap-params.js} | 0 ...s => no-template-lifecycle-assignments.js} | 0 ...naming-convention.js => template-names.js} | 0 ...-eventmap-params.js => eventmap-params.js} | 4 ++-- ...s => no-template-lifecycle-assignments.js} | 4 ++-- ...naming-convention.js => template-names.js} | 4 ++-- 11 files changed, 40 insertions(+), 36 deletions(-) rename docs/rules/{blaze-consistent-eventmap-params.md => eventmap-params.md} (78%) rename docs/rules/{no-blaze-lifecycle-assignment.md => no-template-lifecycle-assignments.md} (97%) rename docs/rules/{template-naming-convention.md => template-names.md} (77%) rename lib/rules/{blaze-consistent-eventmap-params.js => eventmap-params.js} (100%) rename lib/rules/{no-blaze-lifecycle-assignment.js => no-template-lifecycle-assignments.js} (100%) rename lib/rules/{template-naming-convention.js => template-names.js} (100%) rename tests/lib/rules/{blaze-consistent-eventmap-params.js => eventmap-params.js} (97%) rename tests/lib/rules/{no-blaze-lifecycle-assignment.js => no-template-lifecycle-assignments.js} (95%) rename tests/lib/rules/{template-naming-convention.js => template-names.js} (96%) diff --git a/README.md b/README.md index 779ee74cc9..e5fb7b8423 100755 --- a/README.md +++ b/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 diff --git a/docs/rules/blaze-consistent-eventmap-params.md b/docs/rules/eventmap-params.md similarity index 78% rename from docs/rules/blaze-consistent-eventmap-params.md rename to docs/rules/eventmap-params.md index 51cf32f13c..1b8883807c 100644 --- a/docs/rules/blaze-consistent-eventmap-params.md +++ b/docs/rules/eventmap-params.md @@ -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) {} diff --git a/docs/rules/no-blaze-lifecycle-assignment.md b/docs/rules/no-template-lifecycle-assignments.md similarity index 97% rename from docs/rules/no-blaze-lifecycle-assignment.md rename to docs/rules/no-template-lifecycle-assignments.md index 4decf3d7a2..1c1908f260 100644 --- a/docs/rules/no-blaze-lifecycle-assignment.md +++ b/docs/rules/no-template-lifecycle-assignments.md @@ -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. diff --git a/docs/rules/template-naming-convention.md b/docs/rules/template-names.md similarity index 77% rename from docs/rules/template-naming-convention.md rename to docs/rules/template-names.md index b4aaef1af6..694005d2a7 100644 --- a/docs/rules/template-naming-convention.md +++ b/docs/rules/template-names.md @@ -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"] } } ``` diff --git a/lib/index.js b/lib/index.js index 290581f0f5..22dcc3afbe 100755 --- a/lib/index.js +++ b/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, }, }, }, diff --git a/lib/rules/blaze-consistent-eventmap-params.js b/lib/rules/eventmap-params.js similarity index 100% rename from lib/rules/blaze-consistent-eventmap-params.js rename to lib/rules/eventmap-params.js diff --git a/lib/rules/no-blaze-lifecycle-assignment.js b/lib/rules/no-template-lifecycle-assignments.js similarity index 100% rename from lib/rules/no-blaze-lifecycle-assignment.js rename to lib/rules/no-template-lifecycle-assignments.js diff --git a/lib/rules/template-naming-convention.js b/lib/rules/template-names.js similarity index 100% rename from lib/rules/template-naming-convention.js rename to lib/rules/template-names.js diff --git a/tests/lib/rules/blaze-consistent-eventmap-params.js b/tests/lib/rules/eventmap-params.js similarity index 97% rename from tests/lib/rules/blaze-consistent-eventmap-params.js rename to tests/lib/rules/eventmap-params.js index 5677d68ea0..790b65882d 100644 --- a/tests/lib/rules/blaze-consistent-eventmap-params.js +++ b/tests/lib/rules/eventmap-params.js @@ -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({ diff --git a/tests/lib/rules/no-blaze-lifecycle-assignment.js b/tests/lib/rules/no-template-lifecycle-assignments.js similarity index 95% rename from tests/lib/rules/no-blaze-lifecycle-assignment.js rename to tests/lib/rules/no-template-lifecycle-assignments.js index 4e0f5cf1d4..46f7e68a3e 100644 --- a/tests/lib/rules/no-blaze-lifecycle-assignment.js +++ b/tests/lib/rules/no-template-lifecycle-assignments.js @@ -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', diff --git a/tests/lib/rules/template-naming-convention.js b/tests/lib/rules/template-names.js similarity index 96% rename from tests/lib/rules/template-naming-convention.js rename to tests/lib/rules/template-names.js index f0357cda80..954b20d356 100644 --- a/tests/lib/rules/template-naming-convention.js +++ b/tests/lib/rules/template-names.js @@ -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',