eslint-plugin-vue
Advanced tools
Comparing version 9.7.0 to 9.8.0
@@ -179,2 +179,3 @@ /* | ||
'require-name-property': require('./rules/require-name-property'), | ||
'require-prop-comment': require('./rules/require-prop-comment'), | ||
'require-prop-type-constructor': require('./rules/require-prop-type-constructor'), | ||
@@ -181,0 +182,0 @@ 'require-prop-types': require('./rules/require-prop-types'), |
@@ -97,4 +97,12 @@ /** | ||
}, | ||
fix: (fixer) => | ||
fixer.replaceText(node.key, text.replace(name, caseConverter(name))) | ||
fix: (fixer) => { | ||
if (text.includes('_')) { | ||
return null | ||
} | ||
return fixer.replaceText( | ||
node.key, | ||
text.replace(name, caseConverter(name)) | ||
) | ||
} | ||
}) | ||
@@ -101,0 +109,0 @@ } |
@@ -93,19 +93,17 @@ /** | ||
if ( | ||
(!utils.isHtmlElementNode(node) && !utils.isSvgElementNode(node)) || | ||
utils.isHtmlWellKnownElementName(node.rawName) || | ||
utils.isSvgWellKnownElementName(node.rawName) | ||
) { | ||
return false | ||
} | ||
if (!registeredComponentsOnly) { | ||
// If the user specifies registeredComponentsOnly as false, it checks all component tags. | ||
if ( | ||
(!utils.isHtmlElementNode(node) && !utils.isSvgElementNode(node)) || | ||
utils.isHtmlWellKnownElementName(node.rawName) || | ||
utils.isSvgWellKnownElementName(node.rawName) | ||
) { | ||
return false | ||
} | ||
return true | ||
} | ||
// We only verify the registered components. | ||
if (registeredComponents.has(casing.pascalCase(node.rawName))) { | ||
return true | ||
} | ||
return false | ||
return registeredComponents.has(casing.pascalCase(node.rawName)) | ||
} | ||
@@ -112,0 +110,0 @@ |
@@ -48,3 +48,4 @@ /** | ||
'DebuggerStatement', | ||
'EmptyStatement' | ||
'EmptyStatement', | ||
'ExportNamedDeclaration' | ||
]) | ||
@@ -51,0 +52,0 @@ |
@@ -25,3 +25,3 @@ /** | ||
/** @param {VExpressionContainer} node */ | ||
"VElement[name='textarea'] VExpressionContainer"(node) { | ||
"VElement[rawName='textarea'] VExpressionContainer"(node) { | ||
if (node.parent.type !== 'VElement') { | ||
@@ -28,0 +28,0 @@ return |
@@ -9,2 +9,3 @@ /** | ||
const eslintUtils = require('eslint-utils') | ||
const { isJSDocComment } = require('../utils/comments.js') | ||
const { getStyleVariablesContext } = require('../utils/style-variables') | ||
@@ -173,7 +174,3 @@ const { | ||
if ( | ||
tokenBefore && | ||
tokenBefore.type === 'Block' && | ||
tokenBefore.value.charAt(0) === '*' | ||
) { | ||
if (tokenBefore && isJSDocComment(tokenBefore)) { | ||
return tokenBefore | ||
@@ -180,0 +177,0 @@ } |
@@ -7,5 +7,27 @@ /** | ||
const path = require('path') | ||
const utils = require('../utils') | ||
const { getVueComponentDefinitionType } = require('../utils') | ||
/** | ||
* Get the text of the empty indentation part of the line which the given token is on. | ||
* @param {SourceCode} sourceCode the source code object | ||
* @param {Token} token the token to get the indentation text of the line which the token is on | ||
* @returns {string} The text of indentation part. | ||
*/ | ||
function getLineEmptyIndent(sourceCode, token) { | ||
const LT_CHAR = /[\n\r\u2028\u2029]/ | ||
const EMPTY_CHAR = /\s/ | ||
const text = sourceCode.text | ||
let i = token.range[0] - 1 | ||
while (i >= 0 && !LT_CHAR.test(text[i])) { | ||
i -= 1 | ||
} | ||
let j = i | ||
while (EMPTY_CHAR.test(text[j])) { | ||
j += 1 | ||
} | ||
return text.slice(i + 1, j) | ||
} | ||
/** | ||
@@ -32,2 +54,3 @@ * @param {Property | SpreadElement} node | ||
fixable: null, | ||
hasSuggestions: true, | ||
schema: [] | ||
@@ -52,3 +75,37 @@ }, | ||
node: component, | ||
message: 'Required name property is not set.' | ||
message: 'Required name property is not set.', | ||
suggest: [ | ||
{ | ||
desc: 'Add name property to component.', | ||
fix(fixer) { | ||
const extension = path.extname(context.getFilename()) | ||
const filename = path.basename(context.getFilename(), extension) | ||
const sourceCode = context.getSourceCode() | ||
// fix only when property is not empty | ||
if (component.properties.length > 0) { | ||
const firstToken = sourceCode.getFirstToken( | ||
component.properties[0] | ||
) | ||
const indentText = getLineEmptyIndent(sourceCode, firstToken) | ||
// insert name property before the first property | ||
return fixer.insertTextBefore( | ||
component.properties[0], | ||
`name: '${filename}',\n${indentText}` | ||
) | ||
} | ||
const firstToken = sourceCode.getFirstToken(component) | ||
const lastToken = sourceCode.getLastToken(component) | ||
// if the component is empty, insert name property and indent | ||
if (firstToken.value === '{' && lastToken.value === '}') { | ||
const indentText = getLineEmptyIndent(sourceCode, firstToken) | ||
return fixer.replaceTextRange( | ||
[firstToken.range[1], lastToken.range[0]], | ||
`\n${indentText} name: '${filename}'\n${indentText}` | ||
) | ||
} | ||
return null | ||
} | ||
} | ||
] | ||
}) | ||
@@ -55,0 +112,0 @@ }) |
@@ -44,2 +44,3 @@ [ | ||
"ComponentCustomProps", | ||
"ComponentInjectOptions", | ||
"ComponentInternalInstance", | ||
@@ -157,2 +158,3 @@ "ComponentObjectPropsOptions", | ||
"queuePostFlushCb", | ||
"Raw", | ||
"reactive", | ||
@@ -159,0 +161,0 @@ "ReactiveEffect", |
{ | ||
"name": "eslint-plugin-vue", | ||
"version": "9.7.0", | ||
"version": "9.8.0", | ||
"description": "Official ESLint plugin for Vue.js", | ||
@@ -21,5 +21,5 @@ "main": "lib/index.js", | ||
"update": "node ./tools/update.js", | ||
"docs:watch": "vuepress dev docs", | ||
"docs:watch": "vitepress dev docs", | ||
"predocs:build": "npm run update", | ||
"docs:build": "vuepress build docs" | ||
"docs:build": "vitepress build docs" | ||
}, | ||
@@ -67,2 +67,4 @@ "files": [ | ||
"devDependencies": { | ||
"@originjs/vite-plugin-commonjs": "^1.0.3", | ||
"@ota-meshi/site-kit-eslint-editor-vue": "^0.1.0", | ||
"@types/eslint": "^8.4.2", | ||
@@ -75,5 +77,5 @@ "@types/eslint-visitor-keys": "^1.0.0", | ||
"@typescript-eslint/parser": "^5.23.0", | ||
"@vuepress/plugin-pwa": "^1.9.7", | ||
"acorn": "^8.7.1", | ||
"assert": "^2.0.0", | ||
"env-cmd": "^10.1.0", | ||
"esbuild": "^0.15.15", | ||
"eslint": "^8.15.0", | ||
@@ -89,2 +91,3 @@ "eslint-config-prettier": "^8.5.0", | ||
"espree": "^9.3.2", | ||
"events": "^3.3.0", | ||
"markdownlint-cli": "^0.31.1", | ||
@@ -95,5 +98,4 @@ "mocha": "^10.0.0", | ||
"typescript": "^4.6.4", | ||
"vue-eslint-editor": "^1.1.0", | ||
"vuepress": "^1.9.7" | ||
"vitepress": "^1.0.0-alpha.29" | ||
} | ||
} |
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
1153360
276
37318
29