Skip to content

Commit 37ba44b

Browse files
committed
Merge remote-tracking branch 'origin/master' into patch-2-no-async-in-computed-properties
2 parents 12ef6af + 602d80f commit 37ba44b

39 files changed

+172
-116
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The `--fix` option on the command line automatically fixes problems reported by
6868
| :wrench: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. |
6969
| | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | Check if there are no side effects inside computed properties |
7070
| :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. |
71-
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate arguments. |
71+
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate attributes. |
7272
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
7373
| | [order-in-components](./docs/rules/order-in-components.md) | Keep order of properties in components |
7474
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
@@ -80,8 +80,8 @@ The `--fix` option on the command line automatically fixes problems reported by
8080
| | Rule ID | Description |
8181
|:---|:--------|:------------|
8282
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
83-
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce v-bind directive style. |
84-
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce v-on directive style. |
83+
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
84+
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |
8585

8686

8787
### Variables
@@ -96,21 +96,21 @@ The `--fix` option on the command line automatically fixes problems reported by
9696
| | Rule ID | Description |
9797
|:---|:--------|:------------|
9898
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
99-
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid v-bind directives. |
100-
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid v-cloak directives. |
101-
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid v-else-if directives. |
102-
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid v-else directives. |
103-
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid v-for directives. |
104-
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid v-html directives. |
105-
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid v-if directives. |
106-
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid v-model directives. |
107-
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid v-on directives. |
108-
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid v-once directives. |
109-
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid v-pre directives. |
110-
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid v-show directives. |
111-
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid v-text directives. |
99+
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid `v-bind` directives. |
100+
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid `v-cloak` directives. |
101+
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid `v-else-if` directives. |
102+
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid `v-else` directives. |
103+
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid `v-for` directives. |
104+
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid `v-html` directives. |
105+
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid `v-if` directives. |
106+
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid `v-model` directives. |
107+
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid `v-on` directives. |
108+
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid `v-once` directives. |
109+
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid `v-pre` directives. |
110+
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid `v-show` directives. |
111+
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid `v-text` directives. |
112112
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
113-
| | [no-template-key](./docs/rules/no-template-key.md) | disallow 'key' attribute on '<template>'. |
113+
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>`. |
114114

115115
<!--RULES_TABLE_END-->
116116

docs/rules/no-invalid-v-bind.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-bind directives (no-invalid-v-bind)
1+
# Disallow invalid `v-bind` directives (no-invalid-v-bind)
22

33
This rule checks whether every `v-bind` directive is valid.
44

docs/rules/no-invalid-v-cloak.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-cloak directives (no-invalid-v-cloak)
1+
# Disallow invalid `v-cloak` directives (no-invalid-v-cloak)
22

33
This rule checks whether every `v-cloak` directive is valid.
44

docs/rules/no-invalid-v-else-if.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-else-if directives (no-invalid-v-else-if)
1+
# Disallow invalid `v-else-if` directives (no-invalid-v-else-if)
22

33
This rule checks whether every `v-else-if` directive is valid.
44

docs/rules/no-invalid-v-else.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-else directives (no-invalid-v-else)
1+
# Disallow invalid `v-else` directives (no-invalid-v-else)
22

33
This rule checks whether every `v-else` directive is valid.
44

docs/rules/no-invalid-v-for.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-for directives (no-invalid-v-for)
1+
# Disallow invalid `v-for` directives (no-invalid-v-for)
22

33
This rule checks whether every `v-for` directive is valid.
44

docs/rules/no-invalid-v-html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-html directives (no-invalid-v-html)
1+
# Disallow invalid `v-html` directives (no-invalid-v-html)
22

33
This rule checks whether every `v-html` directive is valid.
44

docs/rules/no-invalid-v-if.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-if directives (no-invalid-v-if)
1+
# Disallow invalid `v-if` directives (no-invalid-v-if)
22

33
This rule checks whether every `v-if` directive is valid.
44

docs/rules/no-invalid-v-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-model directives (no-invalid-v-model)
1+
# Disallow invalid `v-model` directives (no-invalid-v-model)
22

33
This rule checks whether every `v-model` directive is valid.
44

docs/rules/no-invalid-v-on.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-on directives (no-invalid-v-on)
1+
# Disallow invalid `v-on` directives (no-invalid-v-on)
22

33
This rule checks whether every `v-on` directive is valid.
44

docs/rules/no-invalid-v-once.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-once directives (no-invalid-v-once)
1+
# Disallow invalid `v-once` directives (no-invalid-v-once)
22

33
This rule checks whether every `v-once` directive is valid.
44

docs/rules/no-invalid-v-pre.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-pre directives (no-invalid-v-pre)
1+
# Disallow invalid `v-pre` directives (no-invalid-v-pre)
22

33
This rule checks whether every `v-pre` directive is valid.
44

docs/rules/no-invalid-v-show.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-show directives (no-invalid-v-show)
1+
# Disallow invalid `v-show` directives (no-invalid-v-show)
22

33
This rule checks whether every `v-show` directive is valid.
44

docs/rules/no-invalid-v-text.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow invalid v-text directives (no-invalid-v-text)
1+
# Disallow invalid `v-text` directives (no-invalid-v-text)
22

33
This rule checks whether every `v-text` directive is valid.
44

docs/rules/no-template-key.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow 'key' attribute on '<template>' (no-template-key)
1+
# Disallow `key` attribute on `<template>` (no-template-key)
22

33
Vue.js disallows `key` attribute on `<template>` elements.
44

docs/rules/order-in-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Keep proper order of properties in your components (order-in-components)
1+
# Keep proper order of properties in your `components` (order-in-components)
22

33
This rule makes sure you keep declared order of properties in components.
44

lib/rules/no-async-in-computed-properties.js

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Check if there are no side effects inside computed properties
2+
* @fileoverview Check if there are no async inside computed properties
33
* @author Armano
44
*/
55
'use strict'
@@ -29,40 +29,30 @@ function checkAsync (data, context) {
2929
}
3030

3131
function create (context) {
32-
const filePath = context.getFilename()
32+
const forbiddenNodes = []
33+
34+
return Object.assign({},
35+
{
3336

34-
return {
35-
ExportDefaultDeclaration (node) {
36-
context.report({
37-
node,
38-
loc: node.key.loc,
39-
message: node
40-
})
41-
// export default {} in .vue || .jsx
42-
if (!utils.isComponentFile(node, filePath)) return
43-
checkAsync(node.declaration.properties, context)
44-
},
45-
CallExpression (node) {
46-
context.report({
47-
node,
48-
loc: node.key.loc,
49-
message: node
50-
})
51-
// Vue.component('xxx', {}) || component('xxx', {})
52-
if (!utils.isVueComponent(node)) return
53-
checkAsync(node.arguments.slice(-1)[0].properties, context)
5437
},
55-
NewExpression (node) {
56-
context.report({
57-
node,
58-
loc: node.key.loc,
59-
message: node
38+
utils.executeOnVueComponent(context, (properties) => {
39+
const computedProperties = utils.getComputedProperties(properties)
40+
41+
computedProperties.forEach(cp => {
42+
forbiddenNodes.forEach(node => {
43+
if (
44+
node.loc.start.line >= cp.value.loc.start.line &&
45+
node.loc.end.line <= cp.value.loc.end.line
46+
) {
47+
context.report({
48+
node: node,
49+
message: `Unexpected async effect in "${cp.key}" computed property.`
50+
})
51+
}
52+
})
6053
})
61-
// new Vue({})
62-
if (!utils.isVueInstance(node)) return
63-
checkAsync(node.arguments[0].properties, context)
64-
}
65-
}
54+
})
55+
)
6656
}
6757

6858
// ------------------------------------------------------------------------------
@@ -73,7 +63,7 @@ module.exports = {
7363
create,
7464
meta: {
7565
docs: {
76-
description: 'Check if there are no side effects inside computed properties',
66+
description: 'Check if there are no async inside computed properties',
7767
category: 'Best Practices',
7868
recommended: false
7969
},

lib/rules/no-duplicate-attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = {
7272
create,
7373
meta: {
7474
docs: {
75-
description: 'disallow duplicate arguments.',
75+
description: 'disallow duplicate attributes.',
7676
category: 'Best Practices',
7777
recommended: false
7878
},

lib/rules/no-invalid-v-bind.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
create,
5959
meta: {
6060
docs: {
61-
description: 'disallow invalid v-bind directives.',
61+
description: 'disallow invalid `v-bind` directives.',
6262
category: 'Possible Errors',
6363
recommended: true
6464
},

lib/rules/no-invalid-v-cloak.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
create,
6060
meta: {
6161
docs: {
62-
description: 'disallow invalid v-cloak directives.',
62+
description: 'disallow invalid `v-cloak` directives.',
6363
category: 'Possible Errors',
6464
recommended: true
6565
},

lib/rules/no-invalid-v-else-if.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = {
8080
create,
8181
meta: {
8282
docs: {
83-
description: 'disallow invalid v-else-if directives.',
83+
description: 'disallow invalid `v-else-if` directives.',
8484
category: 'Possible Errors',
8585
recommended: true
8686
},

lib/rules/no-invalid-v-else.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = {
8080
create,
8181
meta: {
8282
docs: {
83-
description: 'disallow invalid v-else directives.',
83+
description: 'disallow invalid `v-else` directives.',
8484
category: 'Possible Errors',
8585
recommended: true
8686
},

lib/rules/no-invalid-v-for.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ module.exports = {
162162
create,
163163
meta: {
164164
docs: {
165-
description: 'disallow invalid v-for directives.',
165+
description: 'disallow invalid `v-for` directives.',
166166
category: 'Possible Errors',
167167
recommended: true
168168
},

lib/rules/no-invalid-v-html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
create,
6060
meta: {
6161
docs: {
62-
description: 'disallow invalid v-html directives.',
62+
description: 'disallow invalid `v-html` directives.',
6363
category: 'Possible Errors',
6464
recommended: true
6565
},

lib/rules/no-invalid-v-if.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module.exports = {
7373
create,
7474
meta: {
7575
docs: {
76-
description: 'disallow invalid v-if directives.',
76+
description: 'disallow invalid `v-if` directives.',
7777
category: 'Possible Errors',
7878
recommended: true
7979
},

lib/rules/no-invalid-v-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module.exports = {
172172
create,
173173
meta: {
174174
docs: {
175-
description: 'disallow invalid v-model directives.',
175+
description: 'disallow invalid `v-model` directives.',
176176
category: 'Possible Errors',
177177
recommended: true
178178
},

lib/rules/no-invalid-v-on.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module.exports = {
7171
create,
7272
meta: {
7373
docs: {
74-
description: 'disallow invalid v-on directives.',
74+
description: 'disallow invalid `v-on` directives.',
7575
category: 'Possible Errors',
7676
recommended: true
7777
},

lib/rules/no-invalid-v-once.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
create,
6060
meta: {
6161
docs: {
62-
description: 'disallow invalid v-once directives.',
62+
description: 'disallow invalid `v-once` directives.',
6363
category: 'Possible Errors',
6464
recommended: true
6565
},

lib/rules/no-invalid-v-pre.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
create,
6060
meta: {
6161
docs: {
62-
description: 'disallow invalid v-pre directives.',
62+
description: 'disallow invalid `v-pre` directives.',
6363
category: 'Possible Errors',
6464
recommended: true
6565
},

lib/rules/no-invalid-v-show.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
create,
6060
meta: {
6161
docs: {
62-
description: 'disallow invalid v-show directives.',
62+
description: 'disallow invalid `v-show` directives.',
6363
category: 'Possible Errors',
6464
recommended: true
6565
},

lib/rules/no-invalid-v-text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = {
5959
create,
6060
meta: {
6161
docs: {
62-
description: 'disallow invalid v-text directives.',
62+
description: 'disallow invalid `v-text` directives.',
6363
category: 'Possible Errors',
6464
recommended: true
6565
},

lib/rules/no-template-key.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = {
4545
create,
4646
meta: {
4747
docs: {
48-
description: "disallow 'key' attribute on '<template>'.",
48+
description: 'disallow `key` attribute on `<template>`.',
4949
category: 'Possible Errors',
5050
recommended: false
5151
},

lib/rules/order-in-components.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,13 @@ function checkOrder (propertiesNodes, orderMap, context) {
7676
function create (context) {
7777
const options = context.options[0] || {}
7878
const order = options.order || defaultOrder
79-
const filePath = context.getFilename()
8079

8180
const extendedOrder = order.map(property => groups[property] || property)
8281
const orderMap = getOrderMap(extendedOrder)
8382

84-
return {
85-
ExportDefaultDeclaration (node) {
86-
// export default {} in .vue || .jsx
87-
if (!utils.isComponentFile(node, filePath)) return
88-
checkOrder(node.declaration.properties, orderMap, context)
89-
},
90-
CallExpression (node) {
91-
// Vue.component('xxx', {}) || component('xxx', {})
92-
if (!utils.isVueComponent(node)) return
93-
checkOrder(node.arguments.slice(-1)[0].properties, orderMap, context)
94-
},
95-
NewExpression (node) {
96-
// new Vue({})
97-
if (!utils.isVueInstance(node)) return
98-
checkOrder(node.arguments[0].properties, orderMap, context)
99-
}
100-
}
83+
return utils.executeOnVueComponent(context, (properties) => {
84+
checkOrder(properties, orderMap, context)
85+
})
10186
}
10287

10388
// ------------------------------------------------------------------------------

lib/rules/v-bind-style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
create,
5555
meta: {
5656
docs: {
57-
description: 'enforce v-bind directive style.',
57+
description: 'enforce `v-bind` directive style.',
5858
category: 'Stylistic Issues',
5959
recommended: false
6060
},

0 commit comments

Comments
 (0)