diff --git a/README.md b/README.md index 1803aff7b..cca995804 100644 --- a/README.md +++ b/README.md @@ -179,30 +179,6 @@ Enforce all the rules in this category, as well as all higher priority rules, wi | | [order-in-components](./docs/rules/order-in-components.md) | enforce order of properties in components | | | [this-in-template](./docs/rules/this-in-template.md) | enforce usage of `this` in template | -### Deprecated - -> - :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules. -> - :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources. - -| Rule ID | Replaced by | -|:--------|:------------| -| [html-no-self-closing](./docs/rules/html-no-self-closing.md) | [html-self-closing](./docs/rules/html-self-closing.md) | -| [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | [valid-template-root](./docs/rules/valid-template-root.md) | -| [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | [valid-v-bind](./docs/rules/valid-v-bind.md) | -| [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | [valid-v-cloak](./docs/rules/valid-v-cloak.md) | -| [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | [valid-v-else-if](./docs/rules/valid-v-else-if.md) | -| [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | [valid-v-else](./docs/rules/valid-v-else.md) | -| [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | [valid-v-for](./docs/rules/valid-v-for.md) | -| [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | [valid-v-html](./docs/rules/valid-v-html.md) | -| [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | [valid-v-if](./docs/rules/valid-v-if.md) | -| [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | [valid-v-model](./docs/rules/valid-v-model.md) | -| [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | [valid-v-on](./docs/rules/valid-v-on.md) | -| [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | [valid-v-once](./docs/rules/valid-v-once.md) | -| [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | [valid-v-pre](./docs/rules/valid-v-pre.md) | -| [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | [valid-v-show](./docs/rules/valid-v-show.md) | -| [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | [valid-v-text](./docs/rules/valid-v-text.md) | -| [no-reservered-keys](./docs/rules/no-reservered-keys.md) | [no-reserved-keys](./docs/rules/no-reserved-keys.md) | - ## :couple: FAQ diff --git a/docs/rules/html-no-self-closing.md b/docs/rules/html-no-self-closing.md deleted file mode 100644 index bda6e3328..000000000 --- a/docs/rules/html-no-self-closing.md +++ /dev/null @@ -1,39 +0,0 @@ -# disallow self-closing elements (html-no-self-closing) - -- :warning: This rule was **deprecated** and replaced by [html-self-closing](html-self-closing.md) rule. -- :wrench: The `--fix` option on the [command line](http://eslint.org/docs/user-guide/command-line-interface#fix) can automatically fix some of the problems reported by this rule. - -Self-closing (e.g. `
`) is syntax of XML/XHTML. -HTML ignores it. - -## :book: Rule Details - -This rule reports every self-closing element except XML context. - -:-1: Examples of **incorrect** code for this rule: - -```html - -``` - -:+1: Examples of **correct** code for this rule: - -```html - -``` - -## :wrench: Options - -Nothing. diff --git a/docs/rules/no-invalid-template-root.md b/docs/rules/no-invalid-template-root.md deleted file mode 100644 index 1e6bf84d5..000000000 --- a/docs/rules/no-invalid-template-root.md +++ /dev/null @@ -1,100 +0,0 @@ -# disallow invalid template root (no-invalid-template-root) - -- :warning: This rule was **deprecated** and replaced by [valid-template-root](valid-template-root.md) rule. - -This rule checks whether every template root is valid. - -## :book: Rule Details - -This rule reports the template root in the following cases: - -- The root is nothing. E.g. ``. -- The root is text. E.g. ``. -- The root is multiple elements. E.g. ``. -- The root element has `v-for` directives. E.g. ``. -- The root element is `' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - } - ], - invalid: [ - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives aren't supported on
elements."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives require no argument."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives don't support the modifier 'aaa'."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives require that attribute value."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives require the attribute value which is valid as LHS."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives don't support dynamic input types."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives don't support dynamic input types."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives don't support 'file' input type."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-model' directives cannot update the iteration variable 'x' itself."] - } - ] -}) diff --git a/tests/lib/rules/no-invalid-v-on.js b/tests/lib/rules/no-invalid-v-on.js deleted file mode 100644 index 45594645e..000000000 --- a/tests/lib/rules/no-invalid-v-on.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2017 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -'use strict' - -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -const RuleTester = require('eslint').RuleTester -const rule = require('../../../lib/rules/no-invalid-v-on') - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -const tester = new RuleTester({ - parser: 'vue-eslint-parser', - parserOptions: { ecmaVersion: 2015 } -}) - -tester.run('no-invalid-v-on', rule, { - valid: [ - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - } - ], - invalid: [ - { - filename: 'test.vue', - code: '', - errors: ["'v-on' directives don't support the modifier 'aaa'."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-on' directives require that attribute value or verb modifiers."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-on' directives require that attribute value or verb modifiers."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-on' directives require that attribute value or verb modifiers."] - } - ] -}) diff --git a/tests/lib/rules/no-invalid-v-once.js b/tests/lib/rules/no-invalid-v-once.js deleted file mode 100644 index 26c7a998b..000000000 --- a/tests/lib/rules/no-invalid-v-once.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2017 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -'use strict' - -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -const RuleTester = require('eslint').RuleTester -const rule = require('../../../lib/rules/no-invalid-v-once') - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -const tester = new RuleTester({ - parser: 'vue-eslint-parser', - parserOptions: { ecmaVersion: 2015 } -}) - -tester.run('no-invalid-v-once', rule, { - valid: [ - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - } - ], - invalid: [ - { - filename: 'test.vue', - code: '', - errors: ["'v-once' directives require no argument."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-once' directives require no modifier."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-once' directives require no attribute value."] - } - ] -}) diff --git a/tests/lib/rules/no-invalid-v-pre.js b/tests/lib/rules/no-invalid-v-pre.js deleted file mode 100644 index b31b474b3..000000000 --- a/tests/lib/rules/no-invalid-v-pre.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2017 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -'use strict' - -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -const RuleTester = require('eslint').RuleTester -const rule = require('../../../lib/rules/no-invalid-v-pre') - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -const tester = new RuleTester({ - parser: 'vue-eslint-parser', - parserOptions: { ecmaVersion: 2015 } -}) - -tester.run('no-invalid-v-pre', rule, { - valid: [ - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - } - ], - invalid: [ - { - filename: 'test.vue', - code: '', - errors: ["'v-pre' directives require no argument."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-pre' directives require no modifier."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-pre' directives require no attribute value."] - } - ] -}) diff --git a/tests/lib/rules/no-invalid-v-show.js b/tests/lib/rules/no-invalid-v-show.js deleted file mode 100644 index 4d2e97507..000000000 --- a/tests/lib/rules/no-invalid-v-show.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2017 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -'use strict' - -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -const RuleTester = require('eslint').RuleTester -const rule = require('../../../lib/rules/no-invalid-v-show') - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -const tester = new RuleTester({ - parser: 'vue-eslint-parser', - parserOptions: { ecmaVersion: 2015 } -}) - -tester.run('no-invalid-v-show', rule, { - valid: [ - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - } - ], - invalid: [ - { - filename: 'test.vue', - code: '', - errors: ["'v-show' directives require no argument."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-show' directives require no modifier."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-show' directives require that attribute value."] - } - ] -}) diff --git a/tests/lib/rules/no-invalid-v-text.js b/tests/lib/rules/no-invalid-v-text.js deleted file mode 100644 index e8cda5873..000000000 --- a/tests/lib/rules/no-invalid-v-text.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2017 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -'use strict' - -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -const RuleTester = require('eslint').RuleTester -const rule = require('../../../lib/rules/no-invalid-v-text') - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -const tester = new RuleTester({ - parser: 'vue-eslint-parser', - parserOptions: { ecmaVersion: 2015 } -}) - -tester.run('no-invalid-v-text', rule, { - valid: [ - { - filename: 'test.js', - code: 'test' - }, - { - filename: 'test.vue', - code: '' - }, - { - filename: 'test.vue', - code: '' - } - ], - invalid: [ - { - filename: 'test.vue', - code: '', - errors: ["'v-text' directives require no argument."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-text' directives require no modifier."] - }, - { - filename: 'test.vue', - code: '', - errors: ["'v-text' directives require that attribute value."] - } - ] -}) diff --git a/tests/lib/rules/no-reservered-keys.js b/tests/lib/rules/no-reservered-keys.js deleted file mode 100644 index 46744a266..000000000 --- a/tests/lib/rules/no-reservered-keys.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @fileoverview Prevent overwrite reserved keys - * @author Armano - */ -'use strict' - -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -const rule = require('../../../lib/rules/no-reservered-keys') -const RuleTester = require('eslint').RuleTester - -const parserOptions = { - ecmaVersion: 7, - sourceType: 'module', - ecmaFeatures: { experimentalObjectRestSpread: true } -} - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -const ruleTester = new RuleTester() -ruleTester.run('no-reservered-keys', rule, { - valid: [ - { - filename: 'test.vue', - code: ` - export default { - props: ['foo'], - computed: { - bar () { - } - }, - data () { - return { - dat: null - } - }, - methods: { - _foo () {}, - test () { - } - } - } - `, - parserOptions - } - ], - - invalid: [ - { - filename: 'test.js', - code: ` - new Vue({ - props: { - $el: String - } - }) - `, - parserOptions: { ecmaVersion: 6 }, - errors: [{ - message: "Key '$el' is reserved.", - line: 4 - }] - }, - { - filename: 'test.js', - code: ` - new Vue({ - data: { - _foo: String - } - }) - `, - parserOptions: { ecmaVersion: 6 }, - errors: [{ - message: "Keys starting with with '_' are reserved in '_foo' group.", - line: 4 - }] - }, - { - filename: 'test.js', - code: ` - new Vue({ - foo: { - bar: String - } - }) - `, - options: [{ reserved: ['bar'], groups: ['foo'] }], - parserOptions: { ecmaVersion: 6 }, - errors: [{ - message: "Key 'bar' is reserved.", - line: 4 - }] - } - ] -}) diff --git a/tools/update-rules.js b/tools/update-rules.js index 67affeed8..a1c500a12 100644 --- a/tools/update-rules.js +++ b/tools/update-rules.js @@ -44,7 +44,7 @@ const categories = [ !entry[1].meta.deprecated && entry[1].meta.docs.category === category ) - ) +) // Throw if an invalid category has been used for (const entry of rules) { @@ -58,12 +58,12 @@ for (const entry of rules) { } const categoryTitles = { - base: 'Base Rules (Enabling Correct ESLint Parsing)', - essential: 'Priority A: Essential (Error Prevention)', + 'base': 'Base Rules (Enabling Correct ESLint Parsing)', + 'essential': 'Priority A: Essential (Error Prevention)', 'strongly-recommended': 'Priority B: Strongly Recommended (Improving Readability)', - recommended: 'Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)', + 'recommended': 'Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)', 'use-with-caution': 'Priority D: Use with Caution (Potentially Dangerous Patterns)', - uncategorized: 'Uncategorized' + 'uncategorized': 'Uncategorized' } // Throw if no title is defined for a category @@ -73,7 +73,10 @@ for (const category of categories) { } } -const rulesTableContent = categories.map(category => ` +const deprecatedRules = rules + .filter(entry => entry[1].meta.deprecated) + +let rulesTableContent = categories.map(category => ` ### ${categoryTitles[category]} ${ category === 'uncategorized' ? '' : ` @@ -108,27 +111,31 @@ ${ }) .join('\n') } -`).join('\n') + ` -### Deprecated - -> - :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules. -> - :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources. - -| Rule ID | Replaced by | -|:--------|:------------| -${ - rules - .filter(entry => entry[1].meta.deprecated) - .map(entry => { - const name = entry[0] - const meta = entry[1].meta - const link = `[${name}](./docs/rules/${name}.md)` - const replacedBy = (meta.docs.replacedBy || []).map(id => `[${id}](./docs/rules/${id}.md)`).join(', ') || '(no replacement)' - return `| ${link} | ${replacedBy} |` - }) - .join('\n') +`).join('\n') + +if (deprecatedRules.length) { + rulesTableContent += ` + ### Deprecated + + > - :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules. + > - :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources. + + | Rule ID | Replaced by | + |:--------|:------------| + ${ + rules + .filter(entry => entry[1].meta.deprecated) + .map(entry => { + const name = entry[0] + const meta = entry[1].meta + const link = `[${name}](./docs/rules/${name}.md)` + const replacedBy = (meta.docs.replacedBy || []).map(id => `[${id}](./docs/rules/${id}.md)`).join(', ') || '(no replacement)' + return `| ${link} | ${replacedBy} |` + }) + .join('\n') } -` + ` +} categories.forEach((category, categoryIndex) => { if (category === 'uncategorized') return @@ -185,9 +192,10 @@ for (const entry of rules) { const ruleId = entry[0] const meta = entry[1].meta const filePath = path.join(docsRoot, `${ruleId}.md`) - const deprecated = meta.deprecated ? `- ${WARN} This rule was **deprecated** and replaced by ${meta.docs.replacedBy.map(id => `[${id}](${id}.md) rule`).join(', ')}.\n` : '' const autofix = meta.fixable ? `- ${PEN} The \`--fix\` option on the [command line](http://eslint.org/docs/user-guide/command-line-interface#fix) can automatically fix some of the problems reported by this rule.\n` : '' - const header = `# ${meta.docs.description} (${ruleId})\n${deprecated || autofix ? '\n' : ''}${deprecated}${autofix}\n` + let deprecated = meta.deprecated ? `- ${WARN} This rule was **deprecated**` : '' + deprecated += meta.deprecated && meta.docs.replacedBy ? ` and replaced by ${meta.docs.replacedBy.map(id => `[${id}](${id}.md) rule`).join(', ')}.` : '' + const header = `# ${meta.docs.description} (${ruleId})\n\n${deprecated ? deprecated + '\n' : ''}${autofix ? autofix + '\n' : ''}` fs.writeFileSync( filePath,