diff --git a/.eslintignore b/.eslintignore
index 9bb8b51c8..e0072d13e 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,4 +1,4 @@
node_modules
-lib/recommended-rules.js
+lib/*-rules.js
coverage
.nyc_output
diff --git a/.gitignore b/.gitignore
index f5ee9df9b..a56cde83a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
/tests/integrations/*/node_modules
/node_modules
/test.*
+yarn.lock
diff --git a/README.md b/README.md
index 62121c2e1..1803aff7b 100644
--- a/README.md
+++ b/README.md
@@ -75,87 +75,109 @@ Vue.component('AsyncComponent', (resolve, reject) => {
## :gear: Configs
This plugin provides two predefined configs:
-- `plugin:vue/base` - contains necessary settings for this plugin to work properly
-- `plugin:vue/recommended` - extends base config with recommended rules (the ones with check mark :white_check_mark: in the table below)
+- `plugin:vue/base` - Settings and rules to enable correct ESLint parsing
+- `plugin:vue/essential` - Above, plus rules to prevent errors or unintended behavior
+- `plugin:vue/strongly-recommended` - Above, plus rules to considerably improve code readability and/or dev experience
+- `plugin:vue/recommended` - Above, plus rules to enforce subjective community defaults to ensure consistency
## :bulb: Rules
-Rules are grouped by category to help you understand their purpose.
+Rules are grouped by priority to help you understand their purpose. The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
-No rules are enabled by `plugin:vue/base` config. The `plugin:vue/recommended` config enables rules that report common problems, which have a check mark :white_check_mark: below.
+
-The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
+### Base Rules (Enabling Correct ESLint Parsing)
-
+Enforce all the rules in this category, as well as all higher priority rules, with:
-### Possible Errors
+``` json
+"extends": "plugin:vue/base"
+```
| | Rule ID | Description |
|:---|:--------|:------------|
+| | [jsx-uses-vars](./docs/rules/jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused |
+
+
+### Priority A: Essential (Error Prevention)
+
+Enforce all the rules in this category, as well as all higher priority rules, with:
+
+``` json
+"extends": "plugin:vue/essential"
+```
+
+| | Rule ID | Description |
+|:---|:--------|:------------|
+| | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | disallow asynchronous actions in computed properties |
| | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | disallow duplication of field names |
-| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `` |
+| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplication of attributes |
+| | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `` |
| | [no-reserved-keys](./docs/rules/no-reserved-keys.md) | disallow overwriting reserved keys |
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | enforce component's data property to be a function |
+| | [no-side-effects-in-computed-properties](./docs/rules/no-side-effects-in-computed-properties.md) | disallow side effects in computed properties |
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `` |
+| | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 7 },
@@ -1543,6 +1547,7 @@ tester.run('html-indent', rule, {
ccc
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 4 spaces but found 2 spaces.', line: 2 },
{ message: 'Expected indentation of 4 spaces but found 2 spaces.', line: 3 }
@@ -1568,6 +1573,7 @@ tester.run('html-indent', rule, {
}}
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 4 spaces but found 2 spaces.', line: 2 },
{ message: 'Expected indentation of 4 spaces but found 2 spaces.', line: 3 },
@@ -1613,6 +1619,7 @@ tester.run('html-indent', rule, {
">
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 8 spaces but found 6 spaces.', line: 3 },
{ message: 'Expected indentation of 12 spaces but found 6 spaces.', line: 4 },
@@ -1700,6 +1707,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 5 },
@@ -1779,6 +1787,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -1822,6 +1831,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 16 spaces but found 14 spaces.', line: 5 },
{ message: 'Expected indentation of 20 spaces but found 14 spaces.', line: 6 }
@@ -1864,6 +1874,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 6 },
@@ -1936,6 +1947,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 5 },
@@ -2036,6 +2048,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -2139,6 +2152,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -2226,6 +2240,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -2323,6 +2338,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -2483,6 +2499,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -2670,6 +2687,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -2798,6 +2816,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -2902,6 +2921,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -3087,6 +3107,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -3238,6 +3259,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -3298,6 +3320,7 @@ tester.run('html-indent', rule, {
">
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 8 spaces but found 6 spaces.', line: 3 },
{ message: 'Expected indentation of 12 spaces but found 6 spaces.', line: 4 },
@@ -3361,6 +3384,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 5 },
@@ -3378,26 +3402,26 @@ tester.run('html-indent', rule, {
{
code: unIndent`
- {{
- a,
- b,
- c
- }}
+ {{
+ a,
+ b,
+ c
+ }}
`,
output: unIndent`
- {{
- a,
- b,
- c
- }}
+ {{
+ a,
+ b,
+ c
+ }}
`,
errors: [
- { message: 'Expected indentation of 8 spaces but found 4 spaces.', line: 3 },
- { message: 'Expected indentation of 8 spaces but found 4 spaces.', line: 4 },
- { message: 'Expected indentation of 8 spaces but found 4 spaces.', line: 5 }
+ { message: 'Expected indentation of 4 spaces but found 2 spaces.', line: 3 },
+ { message: 'Expected indentation of 4 spaces but found 2 spaces.', line: 4 },
+ { message: 'Expected indentation of 4 spaces but found 2 spaces.', line: 5 }
]
},
@@ -3477,6 +3501,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -3548,6 +3573,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 7 },
@@ -3605,6 +3631,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 },
@@ -3653,6 +3680,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 16 spaces but found 14 spaces.', line: 6 },
{ message: 'Expected indentation of 20 spaces but found 14 spaces.', line: 7 },
@@ -3691,6 +3719,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 5 },
@@ -3705,37 +3734,37 @@ tester.run('html-indent', rule, {
@@ -3779,34 +3808,35 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 5 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 6 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 7 },
- { message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 8 },
- { message: 'Expected indentation of 20 spaces but found 10 spaces.', line: 9 },
- { message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 10 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 11 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 12 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 15 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 16 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 17 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 18 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 19 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 20 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 23 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 24 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 25 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 26 },
- { message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 27 },
- { message: 'Expected indentation of 20 spaces but found 10 spaces.', line: 28 },
- { message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 29 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 30 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 31 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 32 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 33 },
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 34 }
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 4 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 5 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 6 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 7 },
+ { message: 'Expected indentation of 16 spaces but found 8 spaces.', line: 8 },
+ { message: 'Expected indentation of 20 spaces but found 8 spaces.', line: 9 },
+ { message: 'Expected indentation of 16 spaces but found 8 spaces.', line: 10 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 11 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 12 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 15 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 16 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 17 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 18 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 19 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 20 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 23 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 24 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 25 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 26 },
+ { message: 'Expected indentation of 16 spaces but found 8 spaces.', line: 27 },
+ { message: 'Expected indentation of 20 spaces but found 8 spaces.', line: 28 },
+ { message: 'Expected indentation of 16 spaces but found 8 spaces.', line: 29 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 30 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 31 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 32 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 33 },
+ { message: 'Expected indentation of 12 spaces but found 8 spaces.', line: 34 }
]
},
@@ -3814,27 +3844,27 @@ tester.run('html-indent', rule, {
{
code: unIndent`
-
+
`,
output: unIndent`
-
+
`,
errors: [
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
- { message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 }
+ { message: 'Expected indentation of 6 spaces but found 8 spaces.', line: 4 },
+ { message: 'Expected indentation of 8 spaces but found 6 spaces.', line: 5 }
]
},
@@ -3842,27 +3872,27 @@ tester.run('html-indent', rule, {
{
code: unIndent`
-
+
`,
output: unIndent`
-
+
`,
errors: [
- { message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
- { message: 'Expected indentation of 16 spaces but found 10 spaces.', line: 5 }
+ { message: 'Expected indentation of 6 spaces but found 8 spaces.', line: 4 },
+ { message: 'Expected indentation of 8 spaces but found 6 spaces.', line: 5 }
]
},
@@ -3885,7 +3915,7 @@ tester.run('html-indent', rule, {
ccc
=
2
- const ddd
+ const ddd
=
3,
eee
@@ -3929,7 +3959,7 @@ tester.run('html-indent', rule, {
ccc
=
2
- const ddd
+ const ddd
=
3,
eee
@@ -3956,6 +3986,7 @@ tester.run('html-indent', rule, {
>
`,
+ options: [4],
errors: [
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 4 },
{ message: 'Expected indentation of 12 spaces but found 10 spaces.', line: 5 },
@@ -3996,56 +4027,56 @@ tester.run('html-indent', rule, {
{
code: unIndent`
-
+ }
+ "
+ >
`,
output: unIndent`
-
+
`,
errors: [
- { message: 'Expected indentation of 16 spaces but found 14 spaces.', line: 5 },
- { message: 'Expected indentation of 16 spaces but found 14 spaces.', line: 10 },
- { message: 'Expected indentation of 16 spaces but found 14 spaces.', line: 11 },
- { message: 'Expected indentation of 16 spaces but found 14 spaces.', line: 16 },
- { message: 'Expected indentation of 20 spaces but found 14 spaces.', line: 17 }
+ { message: 'Expected indentation of 8 spaces but found 10 spaces.', line: 5 },
+ { message: 'Expected indentation of 8 spaces but found 10 spaces.', line: 10 },
+ { message: 'Expected indentation of 8 spaces but found 10 spaces.', line: 11 },
+ { message: 'Expected indentation of 8 spaces but found 10 spaces.', line: 16 },
+ { message: 'Expected indentation of 10 spaces but found 14 spaces.', line: 17 }
]
},
@@ -4121,16 +4152,16 @@ tester.run('html-indent', rule, {
{
code: unIndent`
- ',
'