Skip to content

Commit 9411cd8

Browse files
committed
Add the ruleset for Vue.js 3
- Add `plugin:vue/vue3-essential` config - Add `plugin:vue/vue3-strongly-recommended` config - Add `plugin:vue/vue3-recommended` config
1 parent b86640a commit 9411cd8

File tree

169 files changed

+645
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+645
-202
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
rules: {
3030
"consistent-docs-description": "error",
3131
"no-invalid-meta": "error",
32+
"no-invalid-meta-docs-categories": "error",
3233
'eslint-plugin/require-meta-type': 'error',
3334
"require-meta-docs-url": ["error", {
3435
"pattern": `https://eslint.vuejs.org/rules/{{name}}.html`

docs/.vuepress/config.js

+24-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,31 @@
77
const rules = require('../../tools/lib/rules')
88
const categories = require('../../tools/lib/categories')
99

10-
const uncategorizedRules = rules.filter(rule => !rule.meta.docs.category && !rule.meta.deprecated)
10+
const uncategorizedRules = rules.filter(rule => !rule.meta.docs.categories && !rule.meta.deprecated)
1111
const deprecatedRules = rules.filter(rule => rule.meta.deprecated)
1212

13+
const categorizedRules = []
14+
for (const category of categories) {
15+
const { title, rules } = category
16+
17+
const children = rules
18+
.filter(({ ruleId }) => categorizedRules
19+
.every(({ children }) => {
20+
return children.every(([, alreadyRuleId]) => alreadyRuleId !== ruleId)
21+
}))
22+
.map(({ ruleId, name }) => [`/rules/${name}`, ruleId])
23+
24+
if (children.length === 0) {
25+
continue
26+
}
27+
28+
categorizedRules.push({
29+
title: title.text.replace(/ \(.+?\)/, ''),
30+
collapsable: false,
31+
children
32+
})
33+
}
34+
1335
const extraCategories = []
1436
if (uncategorizedRules.length > 0) {
1537
extraCategories.push({
@@ -59,11 +81,7 @@ module.exports = {
5981
'/rules/',
6082

6183
// Rules in each category.
62-
...categories.map(({ title, rules }) => ({
63-
title: title.replace(/ \(.+?\)/, ''),
64-
collapsable: false,
65-
children: rules.map(({ ruleId, name }) => [`/rules/${name}`, ruleId])
66-
})),
84+
...categorizedRules,
6785

6886
// Rules in no category.
6987
...extraCategories

docs/rules/README.md

+102-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,106 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
2626
| [vue/comment-directive](./comment-directive.md) | support comment-directives in `<template>` | |
2727
| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | |
2828

29-
## Priority A: Essential (Error Prevention)
29+
## Priority A: Essential (Error Prevention) <badge text="for Vue.js 3.x" vertical="middle">for Vue.js 3.x</badge>
30+
31+
Enforce all the rules in this category, as well as all higher priority rules, with:
32+
33+
```json
34+
{
35+
"extends": "plugin:vue/vue3-essential"
36+
}
37+
```
38+
39+
| Rule ID | Description | |
40+
|:--------|:------------|:---|
41+
| [vue/no-async-in-computed-properties](./no-async-in-computed-properties.md) | disallow asynchronous actions in computed properties | |
42+
| [vue/no-deprecated-scope-attribute](./no-deprecated-scope-attribute.md) | disallow deprecated `scope` attribute (in Vue.js 2.5.0+) | :wrench: |
43+
| [vue/no-deprecated-slot-attribute](./no-deprecated-slot-attribute.md) | disallow deprecated `slot` attribute (in Vue.js 2.6.0+) | :wrench: |
44+
| [vue/no-deprecated-slot-scope-attribute](./no-deprecated-slot-scope-attribute.md) | disallow deprecated `slot-scope` attribute (in Vue.js 2.6.0+) | :wrench: |
45+
| [vue/no-dupe-keys](./no-dupe-keys.md) | disallow duplication of field names | |
46+
| [vue/no-duplicate-attributes](./no-duplicate-attributes.md) | disallow duplication of attributes | |
47+
| [vue/no-parsing-error](./no-parsing-error.md) | disallow parsing errors in `<template>` | |
48+
| [vue/no-reserved-keys](./no-reserved-keys.md) | disallow overwriting reserved keys | |
49+
| [vue/no-shared-component-data](./no-shared-component-data.md) | enforce component's data property to be a function | :wrench: |
50+
| [vue/no-side-effects-in-computed-properties](./no-side-effects-in-computed-properties.md) | disallow side effects in computed properties | |
51+
| [vue/no-template-key](./no-template-key.md) | disallow `key` attribute on `<template>` | |
52+
| [vue/no-textarea-mustache](./no-textarea-mustache.md) | disallow mustaches in `<textarea>` | |
53+
| [vue/no-unused-components](./no-unused-components.md) | disallow registering components that are not used inside templates | |
54+
| [vue/no-unused-vars](./no-unused-vars.md) | disallow unused variable definitions of v-for directives or scope attributes | |
55+
| [vue/no-use-v-if-with-v-for](./no-use-v-if-with-v-for.md) | disallow use v-if on the same element as v-for | |
56+
| [vue/require-component-is](./require-component-is.md) | require `v-bind:is` of `<component>` elements | |
57+
| [vue/require-prop-type-constructor](./require-prop-type-constructor.md) | require prop type to be a constructor | :wrench: |
58+
| [vue/require-render-return](./require-render-return.md) | enforce render function to always return value | |
59+
| [vue/require-v-for-key](./require-v-for-key.md) | require `v-bind:key` with `v-for` directives | |
60+
| [vue/require-valid-default-prop](./require-valid-default-prop.md) | enforce props default values to be valid | |
61+
| [vue/return-in-computed-property](./return-in-computed-property.md) | enforce that a return statement is present in computed property | |
62+
| [vue/use-v-on-exact](./use-v-on-exact.md) | enforce usage of `exact` modifier on `v-on` | |
63+
| [vue/valid-template-root](./valid-template-root.md) | enforce valid template root | |
64+
| [vue/valid-v-bind](./valid-v-bind.md) | enforce valid `v-bind` directives | |
65+
| [vue/valid-v-cloak](./valid-v-cloak.md) | enforce valid `v-cloak` directives | |
66+
| [vue/valid-v-else-if](./valid-v-else-if.md) | enforce valid `v-else-if` directives | |
67+
| [vue/valid-v-else](./valid-v-else.md) | enforce valid `v-else` directives | |
68+
| [vue/valid-v-for](./valid-v-for.md) | enforce valid `v-for` directives | |
69+
| [vue/valid-v-html](./valid-v-html.md) | enforce valid `v-html` directives | |
70+
| [vue/valid-v-if](./valid-v-if.md) | enforce valid `v-if` directives | |
71+
| [vue/valid-v-model](./valid-v-model.md) | enforce valid `v-model` directives | |
72+
| [vue/valid-v-on](./valid-v-on.md) | enforce valid `v-on` directives | |
73+
| [vue/valid-v-once](./valid-v-once.md) | enforce valid `v-once` directives | |
74+
| [vue/valid-v-pre](./valid-v-pre.md) | enforce valid `v-pre` directives | |
75+
| [vue/valid-v-show](./valid-v-show.md) | enforce valid `v-show` directives | |
76+
| [vue/valid-v-text](./valid-v-text.md) | enforce valid `v-text` directives | |
77+
78+
## Priority B: Strongly Recommended (Improving Readability) <badge text="for Vue.js 3.x" vertical="middle">for Vue.js 3.x</badge>
79+
80+
Enforce all the rules in this category, as well as all higher priority rules, with:
81+
82+
```json
83+
{
84+
"extends": "plugin:vue/vue3-strongly-recommended"
85+
}
86+
```
87+
88+
| Rule ID | Description | |
89+
|:--------|:------------|:---|
90+
| [vue/attribute-hyphenation](./attribute-hyphenation.md) | enforce attribute naming style on custom components in template | :wrench: |
91+
| [vue/html-closing-bracket-newline](./html-closing-bracket-newline.md) | require or disallow a line break before tag's closing brackets | :wrench: |
92+
| [vue/html-closing-bracket-spacing](./html-closing-bracket-spacing.md) | require or disallow a space before tag's closing brackets | :wrench: |
93+
| [vue/html-end-tags](./html-end-tags.md) | enforce end tag style | :wrench: |
94+
| [vue/html-indent](./html-indent.md) | enforce consistent indentation in `<template>` | :wrench: |
95+
| [vue/html-quotes](./html-quotes.md) | enforce quotes style of HTML attributes | :wrench: |
96+
| [vue/html-self-closing](./html-self-closing.md) | enforce self-closing style | :wrench: |
97+
| [vue/max-attributes-per-line](./max-attributes-per-line.md) | enforce the maximum number of attributes per line | :wrench: |
98+
| [vue/multiline-html-element-content-newline](./multiline-html-element-content-newline.md) | require a line break before and after the contents of a multiline element | :wrench: |
99+
| [vue/mustache-interpolation-spacing](./mustache-interpolation-spacing.md) | enforce unified spacing in mustache interpolations | :wrench: |
100+
| [vue/name-property-casing](./name-property-casing.md) | enforce specific casing for the name property in Vue components | :wrench: |
101+
| [vue/no-multi-spaces](./no-multi-spaces.md) | disallow multiple spaces | :wrench: |
102+
| [vue/no-spaces-around-equal-signs-in-attribute](./no-spaces-around-equal-signs-in-attribute.md) | disallow spaces around equal signs in attribute | :wrench: |
103+
| [vue/no-template-shadow](./no-template-shadow.md) | disallow variable declarations from shadowing variables declared in the outer scope | |
104+
| [vue/prop-name-casing](./prop-name-casing.md) | enforce specific casing for the Prop name in Vue components | |
105+
| [vue/require-default-prop](./require-default-prop.md) | require default value for props | |
106+
| [vue/require-prop-types](./require-prop-types.md) | require type definitions in props | |
107+
| [vue/singleline-html-element-content-newline](./singleline-html-element-content-newline.md) | require a line break before and after the contents of a singleline element | :wrench: |
108+
| [vue/v-bind-style](./v-bind-style.md) | enforce `v-bind` directive style | :wrench: |
109+
| [vue/v-on-style](./v-on-style.md) | enforce `v-on` directive style | :wrench: |
110+
111+
## Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead) <badge text="for Vue.js 3.x" vertical="middle">for Vue.js 3.x</badge>
112+
113+
Enforce all the rules in this category, as well as all higher priority rules, with:
114+
115+
```json
116+
{
117+
"extends": "plugin:vue/vue3-recommended"
118+
}
119+
```
120+
121+
| Rule ID | Description | |
122+
|:--------|:------------|:---|
123+
| [vue/attributes-order](./attributes-order.md) | enforce order of attributes | :wrench: |
124+
| [vue/no-v-html](./no-v-html.md) | disallow use of v-html to prevent XSS attack | |
125+
| [vue/order-in-components](./order-in-components.md) | enforce order of properties in components | :wrench: |
126+
| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | |
127+
128+
## Priority A: Essential (Error Prevention) <badge text="for Vue.js 2.x" vertical="middle" type="warn">for Vue.js 2.x</badge>
30129

31130
Enforce all the rules in this category, as well as all higher priority rules, with:
32131

@@ -72,7 +171,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
72171
| [vue/valid-v-show](./valid-v-show.md) | enforce valid `v-show` directives | |
73172
| [vue/valid-v-text](./valid-v-text.md) | enforce valid `v-text` directives | |
74173

75-
## Priority B: Strongly Recommended (Improving Readability)
174+
## Priority B: Strongly Recommended (Improving Readability) <badge text="for Vue.js 2.x" vertical="middle" type="warn">for Vue.js 2.x</badge>
76175

77176
Enforce all the rules in this category, as well as all higher priority rules, with:
78177

@@ -105,7 +204,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
105204
| [vue/v-bind-style](./v-bind-style.md) | enforce `v-bind` directive style | :wrench: |
106205
| [vue/v-on-style](./v-on-style.md) | enforce `v-on` directive style | :wrench: |
107206

108-
## Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
207+
## Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead) <badge text="for Vue.js 2.x" vertical="middle" type="warn">for Vue.js 2.x</badge>
109208

110209
Enforce all the rules in this category, as well as all higher priority rules, with:
111210

@@ -155,9 +254,6 @@ For example:
155254
| [vue/match-component-file-name](./match-component-file-name.md) | require component name property to match its file name | |
156255
| [vue/max-len](./max-len.md) | enforce a maximum line length | |
157256
| [vue/no-boolean-default](./no-boolean-default.md) | disallow boolean defaults | :wrench: |
158-
| [vue/no-deprecated-scope-attribute](./no-deprecated-scope-attribute.md) | disallow deprecated `scope` attribute (in Vue.js 2.5.0+) | :wrench: |
159-
| [vue/no-deprecated-slot-attribute](./no-deprecated-slot-attribute.md) | disallow deprecated `slot` attribute (in Vue.js 2.6.0+) | :wrench: |
160-
| [vue/no-deprecated-slot-scope-attribute](./no-deprecated-slot-scope-attribute.md) | disallow deprecated `slot-scope` attribute (in Vue.js 2.6.0+) | :wrench: |
161257
| [vue/no-empty-pattern](./no-empty-pattern.md) | disallow empty destructuring patterns | |
162258
| [vue/no-irregular-whitespace](./no-irregular-whitespace.md) | disallow irregular whitespace | |
163259
| [vue/no-reserved-component-names](./no-reserved-component-names.md) | disallow the use of reserved names in component definitions | |

docs/rules/attribute-hyphenation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce attribute naming style on custom components in template
77
# vue/attribute-hyphenation
88
> enforce attribute naming style on custom components in template
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/attributes-order.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce order of attributes
77
# vue/attributes-order
88
> enforce order of attributes
99
10-
- :gear: This rule is included in `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/html-closing-bracket-newline.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: require or disallow a line break before tag's closing brackets
77
# vue/html-closing-bracket-newline
88
> require or disallow a line break before tag's closing brackets
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
People have their own preference about the location of closing brackets.

docs/rules/html-closing-bracket-spacing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: require or disallow a space before tag's closing brackets
77
# vue/html-closing-bracket-spacing
88
> require or disallow a space before tag's closing brackets
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/html-end-tags.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce end tag style
77
# vue/html-end-tags
88
> enforce end tag style
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/html-indent.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce consistent indentation in `<template>`
77
# vue/html-indent
88
> enforce consistent indentation in `<template>`
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/html-quotes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce quotes style of HTML attributes
77
# vue/html-quotes
88
> enforce quotes style of HTML attributes
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
You can choose quotes of HTML attributes from:

docs/rules/html-self-closing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce self-closing style
77
# vue/html-self-closing
88
> enforce self-closing style
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/max-attributes-per-line.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce the maximum number of attributes per line
77
# vue/max-attributes-per-line
88
> enforce the maximum number of attributes per line
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
Limits the maximum number of attributes/properties per line to improve readability.

docs/rules/multiline-html-element-content-newline.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: require a line break before and after the contents of a multiline e
77
# vue/multiline-html-element-content-newline
88
> require a line break before and after the contents of a multiline element
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/mustache-interpolation-spacing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce unified spacing in mustache interpolations
77
# vue/mustache-interpolation-spacing
88
> enforce unified spacing in mustache interpolations
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

docs/rules/name-property-casing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: enforce specific casing for the name property in Vue components
77
# vue/name-property-casing
88
> enforce specific casing for the name property in Vue components
99
10-
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
10+
- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
1111
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1212

1313
## :book: Rule Details

0 commit comments

Comments
 (0)