vue hello world项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
803 B

3 years ago
/**
* @author Flo Edelmann
*/
'use strict'
const { wrapCoreRule } = require('../utils')
const conditionalDirectiveNames = new Set(['v-show', 'v-if', 'v-else-if'])
// eslint-disable-next-line no-invalid-meta, no-invalid-meta-docs-categories
module.exports = wrapCoreRule('no-constant-condition', {
create(_context, { coreHandlers }) {
return {
VDirectiveKey(node) {
if (
conditionalDirectiveNames.has(`v-${node.name.name}`) &&
node.parent.value &&
node.parent.value.expression &&
coreHandlers.IfStatement
) {
coreHandlers.IfStatement({
// @ts-expect-error -- Process expression of VExpressionContainer as IfStatement.
test: node.parent.value.expression
})
}
}
}
}
})