Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d26e94

Browse files
Breaking: support new syntax in Vue.js 2.6 (#807)
1 parent db700ff commit 5d26e94

Some content is hidden

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

56 files changed

+532
-182
lines changed

‎docs/rules/attributes-order.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This rule aims to enforce ordering of component attributes. The default order is
2525
- `GLOBAL`
2626
ex: 'id'
2727
- `UNIQUE`
28-
ex: 'ref', 'key', 'slot'
28+
ex: 'ref', 'key', 'v-slot', 'slot'
2929
- `TWO_WAY_BINDING`
3030
ex: 'v-model'
3131
- `OTHER_DIRECTIVES`

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

Lines changed: 5 additions & 2 deletions
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/array-bracket-spacing'))
8+
// eslint-disable-next-line no-invalid-meta
9+
module.exports = wrapCoreRule(
10+
require('eslint/lib/rules/array-bracket-spacing'),
11+
{ skipDynamicArguments: true }
12+
)

‎lib/rules/attribute-hyphenation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ module.exports = {
9292
VAttribute (node) {
9393
if (!utils.isCustomComponent(node.parent.parent)) return
9494

95-
const name = !node.directive ? node.key.rawName : node.key.name === 'bind' ? node.key.raw.argument : false
95+
const name =
96+
!node.directive ? node.key.rawName
97+
: node.key.name.name === 'bind' ? node.key.argument && node.key.argument.rawName
98+
: /* otherwise */ false
9699
if (!name || isIgnoredAttribute(name)) return
97100

98101
reportIssue(node, name)

‎lib/rules/attributes-order.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ const utils = require('../utils')
99
// Rule Definition
1010
// ------------------------------------------------------------------------------
1111

12-
function getAttributeType (name, isDirective) {
13-
if (isDirective) {
12+
function getAttributeType (attribute, sourceCode) {
13+
const isBind = attribute.directive && attribute.key.name.name === 'bind'
14+
const name = isBind
15+
? (attribute.key.argument ? sourceCode.getText(attribute.key.argument) : '')
16+
: (attribute.directive ? attribute.key.name.name : attribute.key.name)
17+
18+
if (attribute.directive && !isBind) {
1419
if (name === 'for') {
1520
return 'LIST_RENDERING'
1621
} else if (name === 'if' || name === 'else-if' || name === 'else' || name === 'show' || name === 'cloak') {
@@ -23,6 +28,8 @@ function getAttributeType (name, isDirective) {
2328
return 'EVENTS'
2429
} else if (name === 'html' || name === 'text') {
2530
return 'CONTENT'
31+
} else if (name === 'slot') {
32+
return 'UNIQUE'
2633
} else {
2734
return 'OTHER_DIRECTIVES'
2835
}
@@ -38,10 +45,9 @@ function getAttributeType (name, isDirective) {
3845
}
3946
}
4047
}
41-
function getPosition (attribute, attributePosition) {
42-
const attributeType = attribute.directive && attribute.key.name === 'bind'
43-
? getAttributeType(attribute.key.argument, false)
44-
: getAttributeType(attribute.key.name, attribute.directive)
48+
49+
function getPosition (attribute, attributePosition, sourceCode) {
50+
const attributeType = getAttributeType(attribute, sourceCode)
4551
return attributePosition.hasOwnProperty(attributeType) ? attributePosition[attributeType] : -1
4652
}
4753

@@ -91,8 +97,8 @@ function create (context) {
9197
previousNode = null
9298
},
9399
'VAttribute' (node) {
94-
if ((currentPosition === -1) || (currentPosition <= getPosition(node, attributePosition))) {
95-
currentPosition = getPosition(node, attributePosition)
100+
if ((currentPosition === -1) || (currentPosition <= getPosition(node, attributePosition,sourceCode))) {
101+
currentPosition = getPosition(node, attributePosition,sourceCode)
96102
previousNode = node
97103
} else {
98104
reportIssue(node, previousNode)

‎lib/rules/block-spacing.js

Lines changed: 5 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 5 additions & 2 deletions
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/max-attributes-per-line.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module.exports = {
6767
},
6868

6969
create: function (context) {
70+
const sourceCode = context.getSourceCode()
7071
const configuration = parseOptions(context.options[0])
7172
const multilineMaximum = configuration.multiline
7273
const singlelinemMaximum = configuration.singleline
@@ -130,23 +131,6 @@ module.exports = {
130131
return defaults
131132
}
132133

133-
function getPropData (prop) {
134-
let propType = 'Attribute'
135-
let propName = prop.key.name
136-
137-
if (utils.isBindingAttribute(prop)) {
138-
propType = 'Binding'
139-
propName = prop.key.raw.argument
140-
} else if (utils.isEventAttribute(prop)) {
141-
propType = 'Event'
142-
propName = prop.key.raw.argument
143-
} else if (prop.directive) {
144-
propType = 'Directive'
145-
}
146-
147-
return { propType, propName }
148-
}
149-
150134
function showErrors (attributes) {
151135
attributes.forEach((prop, i) => {
152136
const fix = (fixer) => {
@@ -166,8 +150,8 @@ module.exports = {
166150
context.report({
167151
node: prop,
168152
loc: prop.loc,
169-
message: '{{propType}} "{{propName}}" should be on a new line.',
170-
data: getPropData(prop),
153+
message: '\'{{name}}\' should be on a new line.',
154+
data: {name: sourceCode.getText(prop.key)},
171155
fix
172156
})
173157
})

‎lib/rules/no-confusing-v-for-v-if.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = {
5050

5151
create (context) {
5252
return utils.defineTemplateBodyVisitor(context, {
53-
"VAttribute[directive=true][key.name='if']" (node) {
53+
"VAttribute[directive=true][key.name.name='if']" (node) {
5454
const element = node.parent.parent
5555

5656
if (utils.hasDirective(element, 'for') && !isUsingIterationVar(node)) {

‎lib/rules/no-duplicate-attributes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ function getName (attribute) {
2424
if (!attribute.directive) {
2525
return attribute.key.name
2626
}
27-
if (attribute.key.name === 'bind') {
28-
return attribute.key.argument || null
27+
if (attribute.key.name.name === 'bind') {
28+
return (attribute.key.argument&&attribute.key.argument.name) || null
2929
}
3030
return null
3131
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /