Skip to content

Commit 9db6569

Browse files
committed
Add support for eslint 4.x
LineComment and BlockComment was removed in 4.0.0
1 parent b7b4991 commit 9db6569

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

lib/utils/index.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -431,38 +431,30 @@ module.exports = {
431431
*/
432432
executeOnVueComponent (context, cb) {
433433
const filePath = context.getFilename()
434+
const sourceCode = context.getSourceCode()
434435
const _this = this
435-
const componentComments = []
436+
const componentComments = sourceCode.getAllComments().filter(comment => this.isVueComponentComment(comment.value))
436437
const foundNodes = []
437438

438-
function isDuplicateNode (node) {
439-
return foundNodes.some(el => el.loc.start.line === node.loc.start.line)
439+
const isDuplicateNode = (node) => {
440+
if (foundNodes.some(el => el.loc.start.line === node.loc.start.line)) return true
441+
foundNodes.push(node)
442+
return false
440443
}
441444

442445
return {
443-
LineComment (node) {
444-
// line comment with @vue/component
445-
if (!_this.isVueComponentComment(node.value)) return
446-
componentComments.push(node)
447-
},
448-
BlockComment (node) {
449-
// block comment with @vue/component
450-
if (!_this.isVueComponentComment(node.value)) return
451-
componentComments.push(node)
452-
},
453446
ObjectExpression (node) {
454447
if (!componentComments.some(el => el.loc.end.line === node.loc.start.line - 1) || isDuplicateNode(node)) return
455-
foundNodes.push(node)
456448
cb(node)
457449
},
458450
'ExportDefaultDeclaration:exit' (node) {
459451
// export default {} in .vue || .jsx
460-
if (!_this.isVueComponentFile(node, filePath) || isDuplicateNode(node)) return
452+
if (!_this.isVueComponentFile(node, filePath) || isDuplicateNode(node.declaration)) return
461453
cb(node.declaration)
462454
},
463455
'CallExpression:exit' (node) {
464456
// Vue.component('xxx', {}) || component('xxx', {})
465-
if (!_this.isVueComponent(node) || isDuplicateNode(node)) return
457+
if (!_this.isVueComponent(node) || isDuplicateNode(node.arguments.slice(-1)[0])) return
466458
cb(node.arguments.slice(-1)[0])
467459
}
468460
}

0 commit comments

Comments
 (0)