Skip to content

Commit 00f6db9

Browse files
committed
Changed to use skipDynamicArguments
- vue/block-spacing - vue/brace-style - vue/key-spacing - vue/object-curly-spacing - vue/space-infix-ops - vue/space-unary-ops Add testcases - vue/array-bracket-spacing - vue/comma-dangle - vue/no-restricted-syntax
1 parent 6037a9f commit 00f6db9

15 files changed

+229
-17
lines changed

lib/rules/block-spacing.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
const { wrapCoreRule } = require('../utils')
77

8-
// eslint-disable-next-line
9-
module.exports = wrapCoreRule(require('eslint/lib/rules/block-spacing'))
8+
// eslint-disable-next-line no-invalid-meta
9+
module.exports = wrapCoreRule(
10+
require('eslint/lib/rules/block-spacing'),
11+
{ skipDynamicArguments: true }
12+
)

lib/rules/brace-style.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55

66
const { wrapCoreRule } = require('../utils')
77

8-
// eslint-disable-next-line
9-
module.exports = wrapCoreRule(require('eslint/lib/rules/brace-style'))
8+
// eslint-disable-next-line no-invalid-meta
9+
module.exports = wrapCoreRule(
10+
require('eslint/lib/rules/brace-style'),
11+
{ skipDynamicArguments: true }
12+
)
13+

lib/rules/key-spacing.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
const { wrapCoreRule } = require('../utils')
77

8-
// eslint-disable-next-line
9-
module.exports = wrapCoreRule(require('eslint/lib/rules/key-spacing'))
8+
// eslint-disable-next-line no-invalid-meta
9+
module.exports = wrapCoreRule(
10+
require('eslint/lib/rules/key-spacing'),
11+
{ skipDynamicArguments: true }
12+
)

lib/rules/object-curly-spacing.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
const { wrapCoreRule } = require('../utils')
77

8-
// eslint-disable-next-line
9-
module.exports = wrapCoreRule(require('eslint/lib/rules/object-curly-spacing'))
8+
// eslint-disable-next-line no-invalid-meta
9+
module.exports = wrapCoreRule(
10+
require('eslint/lib/rules/object-curly-spacing'),
11+
{ skipDynamicArguments: true }
12+
)

lib/rules/space-infix-ops.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
const { wrapCoreRule } = require('../utils')
77

8-
// eslint-disable-next-line
9-
module.exports = wrapCoreRule(require('eslint/lib/rules/space-infix-ops'))
8+
// eslint-disable-next-line no-invalid-meta
9+
module.exports = wrapCoreRule(
10+
require('eslint/lib/rules/space-infix-ops'),
11+
{ skipDynamicArguments: true }
12+
)

lib/rules/space-unary-ops.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
const { wrapCoreRule } = require('../utils')
77

8-
// eslint-disable-next-line
9-
module.exports = wrapCoreRule(require('eslint/lib/rules/space-unary-ops'))
8+
// eslint-disable-next-line no-invalid-meta
9+
module.exports = wrapCoreRule(
10+
require('eslint/lib/rules/space-unary-ops'),
11+
{ skipDynamicArguments: true }
12+
)

tests/lib/rules/array-bracket-spacing.js

+18
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ tester.run('array-bracket-spacing', rule, {
3636
invalid: [
3737
{
3838
code: '<template><div :attr="[ a]" /></template>',
39+
output: '<template><div :attr="[a]" /></template>',
3940
errors: ["There should be no space after '['."]
4041
},
4142
{
4243
code: '<template><div :attr="[a ]" /></template>',
44+
output: '<template><div :attr="[a]" /></template>',
4345
errors: ["There should be no space before ']'."]
4446
},
4547
{
4648
code: '<template><div :attr="[ a ]" /></template>',
49+
output: '<template><div :attr="[a]" /></template>',
4750
errors: [
4851
"There should be no space after '['.",
4952
"There should be no space before ']'."
@@ -52,16 +55,19 @@ tester.run('array-bracket-spacing', rule, {
5255
{
5356
code: '<template><div :attr="[ a]" /></template>',
5457
options: ['never'],
58+
output: '<template><div :attr="[a]" /></template>',
5559
errors: ["There should be no space after '['."]
5660
},
5761
{
5862
code: '<template><div :attr="[a ]" /></template>',
5963
options: ['never'],
64+
output: '<template><div :attr="[a]" /></template>',
6065
errors: ["There should be no space before ']'."]
6166
},
6267
{
6368
code: '<template><div :attr="[ a ]" /></template>',
6469
options: ['never'],
70+
output: '<template><div :attr="[a]" /></template>',
6571
errors: [
6672
"There should be no space after '['.",
6773
"There should be no space before ']'."
@@ -70,16 +76,28 @@ tester.run('array-bracket-spacing', rule, {
7076
{
7177
code: '<template><div :attr="[ a]" /></template>',
7278
options: ['always'],
79+
output: '<template><div :attr="[ a ]" /></template>',
7380
errors: ["A space is required before ']'."]
7481
},
7582
{
7683
code: '<template><div :attr="[a ]" /></template>',
7784
options: ['always'],
85+
output: '<template><div :attr="[ a ]" /></template>',
7886
errors: ["A space is required after '['."]
7987
},
8088
{
8189
code: '<template><div :attr="[a]" /></template>',
8290
options: ['always'],
91+
output: '<template><div :attr="[ a ]" /></template>',
92+
errors: [
93+
"A space is required after '['.",
94+
"A space is required before ']'."
95+
]
96+
},
97+
{
98+
code: '<template><div :[[attr]]="[a]" /></template>',
99+
options: ['always'],
100+
output: '<template><div :[[attr]]="[ a ]" /></template>',
83101
errors: [
84102
"A space is required after '['.",
85103
"A space is required before ']'."

tests/lib/rules/block-spacing.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ tester.run('block-spacing', rule, {
1717
{
1818
code: '<template><div :attr="function foo() {return true;}" /></template>',
1919
options: ['never']
20-
}
20+
},
21+
'<template><div :[(function(){return(1)})()]="a" /></template>'
2122
],
2223
invalid: [
2324
{
@@ -110,6 +111,27 @@ tester.run('block-spacing', rule, {
110111
line: 3
111112
}
112113
]
114+
},
115+
{
116+
code: '<template><div :[(function(){return(1)})()]="(function(){return(1)})()" /></template>',
117+
output: '<template><div :[(function(){return(1)})()]="(function(){ return(1) })()" /></template>',
118+
errors: [
119+
{
120+
messageId: 'missing',
121+
data: {
122+
location: 'after',
123+
token: '{'
124+
}
125+
// message: 'Requires a space after \'{\'',
126+
},
127+
{
128+
messageId: 'missing',
129+
data: {
130+
location: 'before',
131+
token: '}'
132+
}
133+
// message: 'Requires a space before \'}\'',
134+
}]
113135
}
114136
]
115137
})

tests/lib/rules/brace-style.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ tester.run('brace-style', rule, {
1919
{
2020
code: `<template><div :attr="function foo() { return true; }" /></template>`,
2121
options: ['1tbs', { 'allowSingleLine': true }]
22-
}
22+
},
23+
`<template><div :[(function(){return(1)})()]="a" /></template>`
2324
],
2425
invalid: [
2526
{
@@ -64,6 +65,19 @@ tester.run('brace-style', rule, {
6465
line: 3
6566
}
6667
]
68+
},
69+
{
70+
code: '<template><div :[(function(){return(1)})()]="(function(){return(1)})()" /></template>',
71+
output: `<template><div :[(function(){return(1)})()]="(function(){
72+
return(1)
73+
})()" /></template>`,
74+
errors: [
75+
{
76+
message: 'Statement inside of curly braces should be on next line.'
77+
},
78+
{
79+
message: 'Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.'
80+
}]
6781
}
6882
]
6983
})

tests/lib/rules/comma-dangle.js

+44
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ tester.run('comma-dangle', rule, {
3333
options: [{
3434
'arrays': 'ignore'
3535
}]
36+
},
37+
{
38+
code: `
39+
<template>
40+
<button :[[a,b][1]]="a" ></button>
41+
</template>`
42+
},
43+
{
44+
code: `
45+
<template>
46+
<button :[[a,b,][1]]="a" ></button>
47+
</template>`,
48+
options: ['always']
3649
}
3750
],
3851
invalid: [
@@ -103,6 +116,37 @@ tester.run('comma-dangle', rule, {
103116
line: 7
104117
}
105118
]
119+
},
120+
{
121+
code: `
122+
<template>
123+
<button :[[a,b,][1]]="a" ></button>
124+
</template>`,
125+
output: `
126+
<template>
127+
<button :[[a,b][1]]="a" ></button>
128+
</template>`,
129+
errors: [
130+
{
131+
message: 'Unexpected trailing comma.'
132+
}
133+
]
134+
},
135+
{
136+
code: `
137+
<template>
138+
<button :[[a,b][1]]="a" ></button>
139+
</template>`,
140+
output: `
141+
<template>
142+
<button :[[a,b,][1]]="a" ></button>
143+
</template>`,
144+
options: ['always'],
145+
errors: [
146+
{
147+
message: 'Missing trailing comma.'
148+
}
149+
]
106150
}
107151
]
108152
})

tests/lib/rules/key-spacing.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,30 @@ const tester = new RuleTester({
1313

1414
tester.run('key-spacing', rule, {
1515
valid: [
16-
'<template><div :attr="{a: 1}" /></template>'
16+
'<template><div :attr="{a: 1}" /></template>',
17+
'<template><div :[{a:1}[`a`]]="a" /></template>',
18+
{
19+
code: '<template><div :[{a:1}[`a`]]="a" /></template>',
20+
options: [{ 'beforeColon': true }]
21+
}
1722
],
1823
invalid: [
1924
{
2025
code: '<template><div :attr="{a :1}" /></template>',
26+
output: '<template><div :attr="{a: 1}" /></template>',
2127
errors: [
2228
"Extra space after key 'a'.",
2329
"Missing space before value for key 'a'."
2430
]
31+
},
32+
{
33+
code: '<template><div :[{a:1}[`a`]]="{a:1}[`a`]" /></template>',
34+
options: [{ 'beforeColon': true }],
35+
output: '<template><div :[{a:1}[`a`]]="{a : 1}[`a`]" /></template>',
36+
errors: [
37+
"Missing space after key 'a'.",
38+
"Missing space before value for key 'a'."
39+
]
2540
}
2641
]
2742
})

tests/lib/rules/no-restricted-syntax.js

+26
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ tester.run('no-restricted-syntax', rule, {
2424
'message': 'Call expressions are not allowed.'
2525
}
2626
]
27+
},
28+
{
29+
code: `
30+
<template>
31+
<input :[value]="value">
32+
</template>`,
33+
options: [
34+
{
35+
'selector': 'CallExpression',
36+
'message': 'Call expressions are not allowed.'
37+
}
38+
]
2739
}
2840
],
2941
invalid: [
@@ -113,6 +125,20 @@ tester.run('no-restricted-syntax', rule, {
113125
endColumn: 53
114126
}
115127
]
128+
},
129+
130+
{
131+
code: `
132+
<template>
133+
<input :[fn()]="fn()">
134+
</template>`,
135+
options: [
136+
{
137+
'selector': 'CallExpression',
138+
'message': 'Call expressions are not allowed.'
139+
}
140+
],
141+
errors: ['Call expressions are not allowed.', 'Call expressions are not allowed.']
116142
}
117143
]
118144
})

0 commit comments

Comments
 (0)