Skip to content

Commit 470b43c

Browse files
committed
update recommended rules to match style guide
1 parent 5f4f3ce commit 470b43c

Some content is hidden

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

52 files changed

+133
-86
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/tests/integrations/*/node_modules
44
/node_modules
55
/test.*
6+
yarn.lock

README.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ The `--fix` option on the command line automatically fixes problems reported by
9292

9393
| | Rule ID | Description |
9494
|:---|:--------|:------------|
95-
| | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | disallow duplication of field names |
95+
| :white_check_mark: | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | disallow duplication of field names |
9696
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>` |
97-
| | [no-reserved-keys](./docs/rules/no-reserved-keys.md) | disallow overwriting reserved keys |
98-
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | enforce component's data property to be a function |
99-
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>` |
97+
| :white_check_mark: | [no-reserved-keys](./docs/rules/no-reserved-keys.md) | disallow overwriting reserved keys |
98+
| :white_check_mark: | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | enforce component's data property to be a function |
99+
| :white_check_mark: | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>` |
100100
| | [no-unused-vars](./docs/rules/no-unused-vars.md) | disallow unused variable definitions of v-for directives or scope attributes |
101-
| | [require-render-return](./docs/rules/require-render-return.md) | enforce render function to always return value |
102-
| | [require-valid-default-prop](./docs/rules/require-valid-default-prop.md) | enforce props default values to be valid |
103-
| | [return-in-computed-property](./docs/rules/return-in-computed-property.md) | enforce that a return statement is present in computed property |
101+
| :white_check_mark: | [require-render-return](./docs/rules/require-render-return.md) | enforce render function to always return value |
102+
| :white_check_mark: | [require-valid-default-prop](./docs/rules/require-valid-default-prop.md) | enforce props default values to be valid |
103+
| :white_check_mark: | [return-in-computed-property](./docs/rules/return-in-computed-property.md) | enforce that a return statement is present in computed property |
104104
| :white_check_mark: | [valid-template-root](./docs/rules/valid-template-root.md) | enforce valid template root |
105105
| :white_check_mark: | [valid-v-bind](./docs/rules/valid-v-bind.md) | enforce valid `v-bind` directives |
106106
| :white_check_mark: | [valid-v-cloak](./docs/rules/valid-v-cloak.md) | enforce valid `v-cloak` directives |
@@ -121,34 +121,34 @@ The `--fix` option on the command line automatically fixes problems reported by
121121

122122
| | Rule ID | Description |
123123
|:---|:--------|:------------|
124-
| :wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style |
125-
| | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | disallow asynchronous actions in computed properties |
124+
| :white_check_mark::wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style |
125+
| :white_check_mark: | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | disallow asynchronous actions in computed properties |
126126
| :white_check_mark: | [no-confusing-v-for-v-if](./docs/rules/no-confusing-v-for-v-if.md) | disallow confusing `v-for` and `v-if` on the same element |
127-
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplication of attributes |
128-
| | [no-side-effects-in-computed-properties](./docs/rules/no-side-effects-in-computed-properties.md) | disallow side effects in computed properties |
127+
| :white_check_mark: | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplication of attributes |
128+
| :white_check_mark: | [no-side-effects-in-computed-properties](./docs/rules/no-side-effects-in-computed-properties.md) | disallow side effects in computed properties |
129129
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>` |
130-
| | [order-in-components](./docs/rules/order-in-components.md) | enforce order of properties in components |
130+
| :white_check_mark: | [order-in-components](./docs/rules/order-in-components.md) | enforce order of properties in components |
131131
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements |
132-
| | [require-default-prop](./docs/rules/require-default-prop.md) | require default value for props |
133-
| | [require-prop-types](./docs/rules/require-prop-types.md) | require type definitions in props |
132+
| :white_check_mark: | [require-default-prop](./docs/rules/require-default-prop.md) | require default value for props |
133+
| :white_check_mark: | [require-prop-types](./docs/rules/require-prop-types.md) | require type definitions in props |
134134
| :white_check_mark: | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives |
135-
| | [this-in-template](./docs/rules/this-in-template.md) | enforce usage of `this` in template |
135+
| :white_check_mark: | [this-in-template](./docs/rules/this-in-template.md) | enforce usage of `this` in template |
136136

137137

138138
### Stylistic Issues
139139

140140
| | Rule ID | Description |
141141
|:---|:--------|:------------|
142-
| :wrench: | [attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | enforce attribute naming style in template |
142+
| :white_check_mark::wrench: | [attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | enforce attribute naming style in template |
143143
| :wrench: | [html-indent](./docs/rules/html-indent.md) | enforce consistent indentation in `<template>` |
144144
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes |
145-
| :wrench: | [html-self-closing](./docs/rules/html-self-closing.md) | enforce self-closing style |
146-
| | [max-attributes-per-line](./docs/rules/max-attributes-per-line.md) | enforce the maximum number of attributes per line |
147-
| :wrench: | [mustache-interpolation-spacing](./docs/rules/mustache-interpolation-spacing.md) | enforce unified spacing in mustache interpolations |
148-
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | enforce specific casing for the name property in Vue components |
149-
| :wrench: | [no-multi-spaces](./docs/rules/no-multi-spaces.md) | disallow multiple spaces |
150-
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style |
151-
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style |
145+
| :white_check_mark::wrench: | [html-self-closing](./docs/rules/html-self-closing.md) | enforce self-closing style |
146+
| :white_check_mark: | [max-attributes-per-line](./docs/rules/max-attributes-per-line.md) | enforce the maximum number of attributes per line |
147+
| :white_check_mark::wrench: | [mustache-interpolation-spacing](./docs/rules/mustache-interpolation-spacing.md) | enforce unified spacing in mustache interpolations |
148+
| :white_check_mark::wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | enforce specific casing for the name property in Vue components |
149+
| :white_check_mark::wrench: | [no-multi-spaces](./docs/rules/no-multi-spaces.md) | disallow multiple spaces |
150+
| :white_check_mark::wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style |
151+
| :white_check_mark::wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style |
152152

153153

154154
### Variables

docs/rules/attribute-hyphenation.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# enforce attribute naming style in template (attribute-hyphenation)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
## :wrench: Options

docs/rules/html-end-tags.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# enforce end tag style (html-end-tags)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
This rule enforce the way of end tags.

docs/rules/html-self-closing.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# enforce self-closing style (html-self-closing)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
In Vue.js template, we can use either two styles for elements which don't have their content.

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# enforce the maximum number of attributes per line (max-attributes-per-line)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
Limits the maximum number of attributes/properties per line to improve readability.
46

57

docs/rules/mustache-interpolation-spacing.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# enforce unified spacing in mustache interpolations (mustache-interpolation-spacing)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
## :book: Rule Details

docs/rules/name-property-casing.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# enforce specific casing for the name property in Vue components (name-property-casing)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
Define a style for the `name` property casing for consistency purposes.

docs/rules/no-async-in-computed-properties.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# disallow asynchronous actions in computed properties (no-async-in-computed-properties)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
Computed properties should be synchronous. Asynchronous actions inside them may not work as expected and can lead to an unexpected behaviour, that's why you should avoid them.
46
If you need async computed properties you might want to consider using additional plugin [vue-async-computed]
57

docs/rules/no-dupe-keys.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# disallow duplication of field names (no-dupe-keys)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
This rule prevents to use duplicated names.
46

57
## :book: Rule Details

docs/rules/no-duplicate-attributes.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# disallow duplication of attributes (no-duplicate-attributes)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
When duplicate arguments exist, only the last one is valid.
46
It's possibly mistakes.
57

@@ -33,7 +35,7 @@ This rule reports duplicate attributes.
3335
```
3436
'vue/no-duplicate-attributes': [2, {
3537
allowCoexistClass: Boolean // default: true
36-
allowCoexistStyle: Boolean, // default: true
38+
allowCoexistStyle: Boolean, // default: false
3739
}]
3840
```
3941

docs/rules/no-multi-spaces.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# disallow multiple spaces (no-multi-spaces)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
The `--fix` option on the command line can automatically fix some of the problems reported by this rule.

docs/rules/no-reserved-keys.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# disallow overwriting reserved keys (no-reserved-keys)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
This rule prevents to use reserved names from to avoid conflicts and unexpected behavior.
46

57
## Rule Details

docs/rules/no-shared-component-data.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# enforce component's data property to be a function (no-shared-component-data)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
When using the data property on a component (i.e. anywhere except on `new Vue`), the value must be a function that returns an object.
46

57
## :book: Rule Details

docs/rules/no-side-effects-in-computed-properties.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# disallow side effects in computed properties (no-side-effects-in-computed-properties)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
It is considered a very bad practice to introduce side effects inside computed properties. It makes the code not predictable and hard to understand.
46

57

docs/rules/no-template-key.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# disallow `key` attribute on `<template>` (no-template-key)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
Vue.js disallows `key` attribute on `<template>` elements.
46

57
## :book: Rule Details

docs/rules/order-in-components.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# enforce order of properties in components (order-in-components)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
This rule makes sure you keep declared order of properties in components.
46

57
## :book: Rule Details

docs/rules/require-default-prop.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# require default value for props (require-default-prop)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
This rule requires default value to be set for each props that are not marked as `required`.
46

57
## Rule Details

docs/rules/require-prop-types.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# require type definitions in props (require-prop-types)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
In committed code, prop definitions should always be as detailed as possible, specifying at least type(s).
46

57
## :book: Rule Details

docs/rules/require-render-return.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# enforce render function to always return value (require-render-return)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
This rule aims to enforce render function to always return value
46

57
## :book: Rule Details

docs/rules/require-valid-default-prop.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# enforce props default values to be valid (require-valid-default-prop)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
This rule checks whether the default value of each prop is valid for the given type. It should report an error when default value for type `Array` or `Object` is not returned using function.
46

57
## :book: Rule Details

docs/rules/return-in-computed-property.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# enforce that a return statement is present in computed property (return-in-computed-property)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
## :book: Rule Details
46

57
This rule enforces that a `return` statement is present in `computed` properties.

docs/rules/this-in-template.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# enforce usage of `this` in template (this-in-template)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
4+
35
## :book: Rule Details
46

57
:-1: Examples of **incorrect** code for this rule:

docs/rules/v-bind-style.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# enforce `v-bind` directive style (v-bind-style)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
This rule enforces `v-bind` directive style which you should use shorthand or long form.

docs/rules/v-on-style.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# enforce `v-on` directive style (v-on-style)
22

3+
- :white_check_mark: The `"extends": "plugin:vue/recommended"` property in a configuration file enables this rule.
34
- :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.
45

56
This rule enforces `v-on` directive style which you should use shorthand or long form.

lib/recommended-rules.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* in order to update its content execute "npm run update"
55
*/
66
module.exports = {
7-
"vue/attribute-hyphenation": "off",
8-
"vue/html-end-tags": "off",
7+
"vue/attribute-hyphenation": "error",
8+
"vue/html-end-tags": "error",
99
"vue/html-indent": "off",
10-
"vue/html-no-self-closing": "off",
10+
"vue/html-no-self-closing": "error",
1111
"vue/html-quotes": "off",
12-
"vue/html-self-closing": "off",
12+
"vue/html-self-closing": "error",
1313
"vue/jsx-uses-vars": "error",
14-
"vue/max-attributes-per-line": "off",
15-
"vue/mustache-interpolation-spacing": "off",
16-
"vue/name-property-casing": "off",
17-
"vue/no-async-in-computed-properties": "off",
14+
"vue/max-attributes-per-line": "error",
15+
"vue/mustache-interpolation-spacing": "error",
16+
"vue/name-property-casing": "error",
17+
"vue/no-async-in-computed-properties": "error",
1818
"vue/no-confusing-v-for-v-if": "error",
19-
"vue/no-dupe-keys": "off",
20-
"vue/no-duplicate-attributes": "off",
19+
"vue/no-dupe-keys": "error",
20+
"vue/no-duplicate-attributes": "error",
2121
"vue/no-invalid-template-root": "off",
2222
"vue/no-invalid-v-bind": "off",
2323
"vue/no-invalid-v-cloak": "off",
@@ -32,26 +32,26 @@ module.exports = {
3232
"vue/no-invalid-v-pre": "off",
3333
"vue/no-invalid-v-show": "off",
3434
"vue/no-invalid-v-text": "off",
35-
"vue/no-multi-spaces": "off",
35+
"vue/no-multi-spaces": "error",
3636
"vue/no-parsing-error": "error",
37-
"vue/no-reserved-keys": "off",
37+
"vue/no-reserved-keys": "error",
3838
"vue/no-reservered-keys": "off",
39-
"vue/no-shared-component-data": "off",
40-
"vue/no-side-effects-in-computed-properties": "off",
41-
"vue/no-template-key": "off",
39+
"vue/no-shared-component-data": "error",
40+
"vue/no-side-effects-in-computed-properties": "error",
41+
"vue/no-template-key": "error",
4242
"vue/no-textarea-mustache": "error",
4343
"vue/no-unused-vars": "off",
44-
"vue/order-in-components": "off",
44+
"vue/order-in-components": "error",
4545
"vue/require-component-is": "error",
46-
"vue/require-default-prop": "off",
47-
"vue/require-prop-types": "off",
48-
"vue/require-render-return": "off",
46+
"vue/require-default-prop": "error",
47+
"vue/require-prop-types": "error",
48+
"vue/require-render-return": "error",
4949
"vue/require-v-for-key": "error",
50-
"vue/require-valid-default-prop": "off",
51-
"vue/return-in-computed-property": "off",
52-
"vue/this-in-template": "off",
53-
"vue/v-bind-style": "off",
54-
"vue/v-on-style": "off",
50+
"vue/require-valid-default-prop": "error",
51+
"vue/return-in-computed-property": "error",
52+
"vue/this-in-template": "error",
53+
"vue/v-bind-style": "error",
54+
"vue/v-on-style": "error",
5555
"vue/valid-template-root": "error",
5656
"vue/valid-v-bind": "error",
5757
"vue/valid-v-cloak": "error",

lib/rules/attribute-hyphenation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module.exports = {
6060
docs: {
6161
description: 'enforce attribute naming style in template',
6262
category: 'Stylistic Issues',
63-
recommended: false
63+
recommended: true
6464
},
6565
fixable: 'code',
6666
schema: [

lib/rules/html-end-tags.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module.exports = {
6161
docs: {
6262
description: 'enforce end tag style',
6363
category: 'Best Practices',
64-
recommended: false
64+
recommended: true
6565
},
6666
fixable: 'code',
6767
schema: []

lib/rules/html-no-self-closing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
docs: {
5555
description: 'disallow self-closing elements',
5656
category: 'Best Practices',
57-
recommended: false,
57+
recommended: true,
5858
replacedBy: ['html-self-closing']
5959
},
6060
deprecated: true,

lib/rules/html-quotes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module.exports = {
5757
},
5858
fixable: false,
5959
schema: [
60-
{ enum: ['double', 'single'] }
60+
{ enum: ['double', 'single'] }
6161
]
6262
}
6363
}

0 commit comments

Comments
 (0)