eslint-plugin-vue
Advanced tools
Comparing version 7.11.1 to 7.12.0
@@ -76,2 +76,23 @@ /** | ||
} | ||
/** | ||
* @param {Expression|SpreadElement|null} node | ||
*/ | ||
function isFunctionIdentifier(node) { | ||
return node && node.type === 'Identifier' && node.name === 'Function' | ||
} | ||
/** | ||
* @param {Expression} node | ||
* @returns {boolean} | ||
*/ | ||
function hasFunctionType(node) { | ||
if (isFunctionIdentifier(node)) { | ||
return true | ||
} | ||
if (node.type === 'ArrayExpression') { | ||
return node.elements.some(isFunctionIdentifier) | ||
} | ||
return false | ||
} | ||
return utils.defineVueVisitor(context, { | ||
@@ -90,2 +111,7 @@ onVueObjectEnter(node) { | ||
} | ||
const type = utils.findProperty(prop.value, 'type') | ||
if (type && hasFunctionType(type.value)) { | ||
// ignore function type | ||
continue | ||
} | ||
if (def.value.type !== 'FunctionExpression') { | ||
@@ -92,0 +118,0 @@ continue |
@@ -53,5 +53,9 @@ /** | ||
/** | ||
* @typedef {object} Step | ||
* @property {Matcher} [test] | ||
* @property {boolean} [wildcard] | ||
* @typedef {object} StepForTest | ||
* @property {Matcher} test | ||
* @property {undefined} [wildcard] | ||
* @typedef {object} StepForWildcard | ||
* @property {undefined} [test] | ||
* @property {true} wildcard | ||
* @typedef {StepForTest | StepForWildcard} Step | ||
*/ | ||
@@ -80,3 +84,3 @@ | ||
function buildTester(index) { | ||
const { wildcard, test } = steps[index] | ||
const step = steps[index] | ||
const next = index + 1 | ||
@@ -87,3 +91,3 @@ const needNext = steps.length > next | ||
let keyName | ||
if (wildcard) { | ||
if (step.wildcard) { | ||
keyName = '*' | ||
@@ -95,3 +99,3 @@ } else { | ||
const name = utils.getStaticPropertyName(node) | ||
if (!name || !test(name)) { | ||
if (!name || !step.test(name)) { | ||
return null | ||
@@ -104,3 +108,3 @@ } | ||
next: needNext ? buildTester(next) : undefined, | ||
wildcard, | ||
wildcard: step.wildcard, | ||
keyName | ||
@@ -107,0 +111,0 @@ } |
@@ -159,2 +159,3 @@ /** | ||
visitorKeys, | ||
/** @param {ASTNode} node */ | ||
enterNode(node) { | ||
@@ -197,2 +198,3 @@ if (!result || skipNode) { | ||
}, | ||
/** @param {ASTNode} node */ | ||
leaveNode(node) { | ||
@@ -199,0 +201,0 @@ if (skipNode === node) { |
@@ -116,2 +116,6 @@ /** | ||
} | ||
if (node.property.type === 'PrivateIdentifier') { | ||
// Unreachable | ||
return | ||
} | ||
verify(node, node.property) | ||
@@ -118,0 +122,0 @@ } |
@@ -209,4 +209,4 @@ /** | ||
} else { | ||
propName = upperVueState.propName | ||
chainLevel = upperVueState.chainLevel + 1 | ||
propName = upperVueState.propName || '' | ||
chainLevel = (upperVueState.chainLevel || 0) + 1 | ||
} | ||
@@ -213,0 +213,0 @@ vueState.propName = propName |
@@ -6,2 +6,5 @@ /** | ||
'use strict' | ||
const canConvertToVSlot = require('./utils/can-convert-to-v-slot') | ||
module.exports = { | ||
@@ -13,2 +16,5 @@ deprecated: '2.6.0', | ||
const sourceCode = context.getSourceCode() | ||
const tokenStore = | ||
context.parserServices.getTemplateBodyTokenStore && | ||
context.parserServices.getTemplateBodyTokenStore() | ||
@@ -21,3 +27,3 @@ /** | ||
function canConvertFromSlotToVSlot(slotAttr) { | ||
if (slotAttr.parent.parent.name !== 'template') { | ||
if (!canConvertToVSlot(slotAttr.parent.parent, sourceCode, tokenStore)) { | ||
return false | ||
@@ -39,3 +45,3 @@ } | ||
function canConvertFromVBindSlotToVSlot(slotAttr) { | ||
if (slotAttr.parent.parent.name !== 'template') { | ||
if (!canConvertToVSlot(slotAttr.parent.parent, sourceCode, tokenStore)) { | ||
return false | ||
@@ -42,0 +48,0 @@ } |
@@ -6,2 +6,5 @@ /** | ||
'use strict' | ||
const canConvertToVSlotForElement = require('./utils/can-convert-to-v-slot') | ||
module.exports = { | ||
@@ -18,2 +21,5 @@ deprecated: '2.6.0', | ||
const sourceCode = context.getSourceCode() | ||
const tokenStore = | ||
context.parserServices.getTemplateBodyTokenStore && | ||
context.parserServices.getTemplateBodyTokenStore() | ||
@@ -26,3 +32,5 @@ /** | ||
function canConvertToVSlot(startTag) { | ||
if (startTag.parent.name !== 'template') { | ||
if ( | ||
!canConvertToVSlotForElement(startTag.parent, sourceCode, tokenStore) | ||
) { | ||
return false | ||
@@ -29,0 +37,0 @@ } |
@@ -31,50 +31,18 @@ /** | ||
function getSlotDirectivesOnChildren(node) { | ||
return node.children | ||
.reduce( | ||
({ groups, vIf }, childNode) => { | ||
if (childNode.type === 'VElement') { | ||
let connected | ||
if (utils.hasDirective(childNode, 'if')) { | ||
connected = false | ||
vIf = true | ||
} else if (utils.hasDirective(childNode, 'else-if')) { | ||
connected = vIf | ||
vIf = true | ||
} else if (utils.hasDirective(childNode, 'else')) { | ||
connected = vIf | ||
vIf = false | ||
} else { | ||
connected = false | ||
vIf = false | ||
} | ||
/** @type {VDirective[][]} */ | ||
const groups = [] | ||
for (const group of utils.iterateChildElementsChains(node)) { | ||
const slotDirs = group | ||
.map((childElement) => | ||
childElement.name === 'template' | ||
? utils.getDirective(childElement, 'slot') | ||
: null | ||
) | ||
.filter(utils.isDef) | ||
if (slotDirs.length > 0) { | ||
groups.push(slotDirs) | ||
} | ||
} | ||
if (connected) { | ||
groups[groups.length - 1].push(childNode) | ||
} else { | ||
groups.push([childNode]) | ||
} | ||
} else if ( | ||
childNode.type !== 'VText' || | ||
childNode.value.trim() !== '' | ||
) { | ||
vIf = false | ||
} | ||
return { groups, vIf } | ||
}, | ||
{ | ||
/** @type {VElement[][]} */ | ||
groups: [], | ||
vIf: false | ||
} | ||
) | ||
.groups.map((group) => | ||
group | ||
.map((childElement) => | ||
childElement.name === 'template' | ||
? utils.getDirective(childElement, 'slot') | ||
: null | ||
) | ||
.filter(utils.isDef) | ||
) | ||
.filter((group) => group.length >= 1) | ||
return groups | ||
} | ||
@@ -81,0 +49,0 @@ |
@@ -113,4 +113,4 @@ /** | ||
* Parse HTMLComment. | ||
* @param {ASTToken} node a comment token | ||
* @returns {HTMLComment | null} the result of HTMLComment tokens. | ||
* @param {Token} node a comment token | ||
* @returns {ParsedHTMLComment | null} the result of HTMLComment tokens. | ||
*/ | ||
@@ -117,0 +117,0 @@ return function parseHTMLComment(node) { |
{ | ||
"name": "eslint-plugin-vue", | ||
"version": "7.11.1", | ||
"version": "7.12.0", | ||
"description": "Official ESLint plugin for Vue.js", | ||
@@ -63,6 +63,7 @@ "main": "lib/index.js", | ||
"@types/eslint": "^7.2.0", | ||
"@types/eslint-visitor-keys": "^1.0.0", | ||
"@types/natural-compare": "^1.4.0", | ||
"@types/node": "^13.13.5", | ||
"@types/semver": "^7.2.0", | ||
"@typescript-eslint/parser": "^3.0.2", | ||
"@typescript-eslint/parser": "^4.28.0", | ||
"@vuepress/plugin-pwa": "^1.4.1", | ||
@@ -78,2 +79,3 @@ "babel-eslint": "^10.1.0", | ||
"eslint4b": "^7.0.0", | ||
"espree": "^8.0.0-0", | ||
"lodash": "^4.17.15", | ||
@@ -83,3 +85,3 @@ "mocha": "^7.1.2", | ||
"prettier": "^2.1.1", | ||
"typescript": "^3.9.5", | ||
"typescript": "^4.3.4", | ||
"vue-eslint-editor": "^1.1.0", | ||
@@ -86,0 +88,0 @@ "vuepress": "^1.4.1" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
895940
223
27802
24