Skip to content

Commit

Permalink
Changed to use skipDynamicArguments
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ota-meshi committed Feb 8, 2019
1 parent 6037a9f commit 00f6db9
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 17 deletions.
7 changes: 5 additions & 2 deletions lib/rules/block-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@

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

// eslint-disable-next-line
module.exports = wrapCoreRule(require('eslint/lib/rules/block-spacing'))
// eslint-disable-next-line no-invalid-meta
module.exports = wrapCoreRule(
require('eslint/lib/rules/block-spacing'),
{ skipDynamicArguments: true }
)
8 changes: 6 additions & 2 deletions lib/rules/brace-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@

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

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

7 changes: 5 additions & 2 deletions lib/rules/key-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@

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

// eslint-disable-next-line
module.exports = wrapCoreRule(require('eslint/lib/rules/key-spacing'))
// eslint-disable-next-line no-invalid-meta
module.exports = wrapCoreRule(
require('eslint/lib/rules/key-spacing'),
{ skipDynamicArguments: true }
)
7 changes: 5 additions & 2 deletions lib/rules/object-curly-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@

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

// eslint-disable-next-line
module.exports = wrapCoreRule(require('eslint/lib/rules/object-curly-spacing'))
// eslint-disable-next-line no-invalid-meta
module.exports = wrapCoreRule(
require('eslint/lib/rules/object-curly-spacing'),
{ skipDynamicArguments: true }
)
7 changes: 5 additions & 2 deletions lib/rules/space-infix-ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@

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

// eslint-disable-next-line
module.exports = wrapCoreRule(require('eslint/lib/rules/space-infix-ops'))
// eslint-disable-next-line no-invalid-meta
module.exports = wrapCoreRule(
require('eslint/lib/rules/space-infix-ops'),
{ skipDynamicArguments: true }
)
7 changes: 5 additions & 2 deletions lib/rules/space-unary-ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@

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

// eslint-disable-next-line
module.exports = wrapCoreRule(require('eslint/lib/rules/space-unary-ops'))
// eslint-disable-next-line no-invalid-meta
module.exports = wrapCoreRule(
require('eslint/lib/rules/space-unary-ops'),
{ skipDynamicArguments: true }
)
18 changes: 18 additions & 0 deletions tests/lib/rules/array-bracket-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ tester.run('array-bracket-spacing', rule, {
invalid: [
{
code: '<template><div :attr="[ a]" /></template>',
output: '<template><div :attr="[a]" /></template>',
errors: ["There should be no space after '['."]
},
{
code: '<template><div :attr="[a ]" /></template>',
output: '<template><div :attr="[a]" /></template>',
errors: ["There should be no space before ']'."]
},
{
code: '<template><div :attr="[ a ]" /></template>',
output: '<template><div :attr="[a]" /></template>',
errors: [
"There should be no space after '['.",
"There should be no space before ']'."
Expand All @@ -52,16 +55,19 @@ tester.run('array-bracket-spacing', rule, {
{
code: '<template><div :attr="[ a]" /></template>',
options: ['never'],
output: '<template><div :attr="[a]" /></template>',
errors: ["There should be no space after '['."]
},
{
code: '<template><div :attr="[a ]" /></template>',
options: ['never'],
output: '<template><div :attr="[a]" /></template>',
errors: ["There should be no space before ']'."]
},
{
code: '<template><div :attr="[ a ]" /></template>',
options: ['never'],
output: '<template><div :attr="[a]" /></template>',
errors: [
"There should be no space after '['.",
"There should be no space before ']'."
Expand All @@ -70,16 +76,28 @@ tester.run('array-bracket-spacing', rule, {
{
code: '<template><div :attr="[ a]" /></template>',
options: ['always'],
output: '<template><div :attr="[ a ]" /></template>',
errors: ["A space is required before ']'."]
},
{
code: '<template><div :attr="[a ]" /></template>',
options: ['always'],
output: '<template><div :attr="[ a ]" /></template>',
errors: ["A space is required after '['."]
},
{
code: '<template><div :attr="[a]" /></template>',
options: ['always'],
output: '<template><div :attr="[ a ]" /></template>',
errors: [
"A space is required after '['.",
"A space is required before ']'."
]
},
{
code: '<template><div :[[attr]]="[a]" /></template>',
options: ['always'],
output: '<template><div :[[attr]]="[ a ]" /></template>',
errors: [
"A space is required after '['.",
"A space is required before ']'."
Expand Down
24 changes: 23 additions & 1 deletion tests/lib/rules/block-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ tester.run('block-spacing', rule, {
{
code: '<template><div :attr="function foo() {return true;}" /></template>',
options: ['never']
}
},
'<template><div :[(function(){return(1)})()]="a" /></template>'
],
invalid: [
{
Expand Down Expand Up @@ -110,6 +111,27 @@ tester.run('block-spacing', rule, {
line: 3
}
]
},
{
code: '<template><div :[(function(){return(1)})()]="(function(){return(1)})()" /></template>',
output: '<template><div :[(function(){return(1)})()]="(function(){ return(1) })()" /></template>',
errors: [
{
messageId: 'missing',
data: {
location: 'after',
token: '{'
}
// message: 'Requires a space after \'{\'',
},
{
messageId: 'missing',
data: {
location: 'before',
token: '}'
}
// message: 'Requires a space before \'}\'',
}]
}
]
})
16 changes: 15 additions & 1 deletion tests/lib/rules/brace-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ tester.run('brace-style', rule, {
{
code: `<template><div :attr="function foo() { return true; }" /></template>`,
options: ['1tbs', { 'allowSingleLine': true }]
}
},
`<template><div :[(function(){return(1)})()]="a" /></template>`
],
invalid: [
{
Expand Down Expand Up @@ -64,6 +65,19 @@ tester.run('brace-style', rule, {
line: 3
}
]
},
{
code: '<template><div :[(function(){return(1)})()]="(function(){return(1)})()" /></template>',
output: `<template><div :[(function(){return(1)})()]="(function(){
return(1)
})()" /></template>`,
errors: [
{
message: 'Statement inside of curly braces should be on next line.'
},
{
message: 'Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.'
}]
}
]
})
44 changes: 44 additions & 0 deletions tests/lib/rules/comma-dangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ tester.run('comma-dangle', rule, {
options: [{
'arrays': 'ignore'
}]
},
{
code: `
<template>
<button :[[a,b][1]]="a" ></button>
</template>`
},
{
code: `
<template>
<button :[[a,b,][1]]="a" ></button>
</template>`,
options: ['always']
}
],
invalid: [
Expand Down Expand Up @@ -103,6 +116,37 @@ tester.run('comma-dangle', rule, {
line: 7
}
]
},
{
code: `
<template>
<button :[[a,b,][1]]="a" ></button>
</template>`,
output: `
<template>
<button :[[a,b][1]]="a" ></button>
</template>`,
errors: [
{
message: 'Unexpected trailing comma.'
}
]
},
{
code: `
<template>
<button :[[a,b][1]]="a" ></button>
</template>`,
output: `
<template>
<button :[[a,b,][1]]="a" ></button>
</template>`,
options: ['always'],
errors: [
{
message: 'Missing trailing comma.'
}
]
}
]
})
17 changes: 16 additions & 1 deletion tests/lib/rules/key-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,30 @@ const tester = new RuleTester({

tester.run('key-spacing', rule, {
valid: [
'<template><div :attr="{a: 1}" /></template>'
'<template><div :attr="{a: 1}" /></template>',
'<template><div :[{a:1}[`a`]]="a" /></template>',
{
code: '<template><div :[{a:1}[`a`]]="a" /></template>',
options: [{ 'beforeColon': true }]
}
],
invalid: [
{
code: '<template><div :attr="{a :1}" /></template>',
output: '<template><div :attr="{a: 1}" /></template>',
errors: [
"Extra space after key 'a'.",
"Missing space before value for key 'a'."
]
},
{
code: '<template><div :[{a:1}[`a`]]="{a:1}[`a`]" /></template>',
options: [{ 'beforeColon': true }],
output: '<template><div :[{a:1}[`a`]]="{a : 1}[`a`]" /></template>',
errors: [
"Missing space after key 'a'.",
"Missing space before value for key 'a'."
]
}
]
})
26 changes: 26 additions & 0 deletions tests/lib/rules/no-restricted-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ tester.run('no-restricted-syntax', rule, {
'message': 'Call expressions are not allowed.'
}
]
},
{
code: `
<template>
<input :[value]="value">
</template>`,
options: [
{
'selector': 'CallExpression',
'message': 'Call expressions are not allowed.'
}
]
}
],
invalid: [
Expand Down Expand Up @@ -113,6 +125,20 @@ tester.run('no-restricted-syntax', rule, {
endColumn: 53
}
]
},

{
code: `
<template>
<input :[fn()]="fn()">
</template>`,
options: [
{
'selector': 'CallExpression',
'message': 'Call expressions are not allowed.'
}
],
errors: ['Call expressions are not allowed.', 'Call expressions are not allowed.']
}
]
})
Loading

0 comments on commit 00f6db9

Please sign in to comment.