diff --git a/eslint-internal-rules/no-invalid-meta-docs-categories.js b/eslint-internal-rules/no-invalid-meta-docs-categories.js index 24350c8f6..1ea9a16e6 100644 --- a/eslint-internal-rules/no-invalid-meta-docs-categories.js +++ b/eslint-internal-rules/no-invalid-meta-docs-categories.js @@ -56,7 +56,7 @@ function checkMetaValidity(context, exportsNode) { if (!categories) { context.report({ node: metaDocs, - message: 'Rule is missing a meta.docs.categories property.', + messageId: 'missingCategories', fix(fixer) { const category = getPropertyFromObject('category', metaDocs.value) if (!category) { @@ -98,18 +98,27 @@ function checkMetaValidity(context, exportsNode) { categories.value.name === 'undefined' ) ) { - context.report(categories.value, 'meta.docs.categories must be an array.') + context.report({ + node: categories.value, + messageId: 'categoriesMustBeArray' + }) } } module.exports = { meta: { + type: 'problem', docs: { description: 'enforce correct use of `meta` property in core rules', categories: ['Internal'] }, fixable: 'code', - schema: [] + schema: [], + messages: { + missingCategories: 'Rule is missing a meta.docs.categories property.', + // eslint-disable-next-line eslint-plugin/report-message-format + categoriesMustBeArray: 'meta.docs.categories must be an array.' + } }, create(context) { diff --git a/eslint-internal-rules/no-invalid-meta.js b/eslint-internal-rules/no-invalid-meta.js index 24bf01faf..5969e5c5a 100644 --- a/eslint-internal-rules/no-invalid-meta.js +++ b/eslint-internal-rules/no-invalid-meta.js @@ -67,32 +67,44 @@ function checkMetaValidity(context, exportsNode) { const metaProperty = getMetaPropertyFromExportsNode(exportsNode) if (!metaProperty) { - context.report(exportsNode, 'Rule is missing a meta property.') + context.report({ + node: exportsNode, + messageId: 'missingMeta' + }) return } if (!hasMetaDocs(metaProperty)) { - context.report(metaProperty, 'Rule is missing a meta.docs property.') + context.report({ + node: 'metaDocs', + messageId: 'missingMetaDocs' + }) return } if (!hasMetaDocsCategories(metaProperty)) { - context.report( - metaProperty, - 'Rule is missing a meta.docs.categories property.' - ) + context.report({ + node: metaProperty, + messageId: 'missingMetaDocsCategories' + }) return } } module.exports = { meta: { + type: 'problem', docs: { description: 'enforce correct use of `meta` property in core rules', categories: ['Internal'] }, - - schema: [] + schema: [], + messages: { + missingMeta: 'Rule is missing a meta property.', + missingMetaDocs: 'Rule is missing a meta.docs property.', + missingMetaDocsCategories: + 'Rule is missing a meta.docs.categories property.' + } }, create(context) { diff --git a/eslint-internal-rules/require-eslint-community.js b/eslint-internal-rules/require-eslint-community.js index f99afd8f9..0c2f372c1 100644 --- a/eslint-internal-rules/require-eslint-community.js +++ b/eslint-internal-rules/require-eslint-community.js @@ -2,16 +2,17 @@ module.exports = { meta: { + type: 'problem', docs: { description: 'enforce use of the `@eslint-community/*` package', categories: ['Internal'] }, fixable: 'code', + schema: [], messages: { useCommunityPackageInstead: 'Please use `@eslint-community/{{name}}` instead.' - }, - schema: [] + } }, /** @param {import('eslint').Rule.RuleContext} context */ diff --git a/eslint.config.js b/eslint.config.js index dddc54647..be4b85d0a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -27,7 +27,7 @@ module.exports = [ }, ...eslintrc.plugins('eslint-plugin', 'prettier', 'unicorn'), ...eslintrc.extends( - 'plugin:eslint-plugin/recommended', + 'plugin:eslint-plugin/all', 'prettier', 'plugin:node-dependencies/recommended', 'plugin:jsonc/recommended-with-jsonc', @@ -143,8 +143,6 @@ module.exports = [ 'prettier/prettier': 'error', 'eslint-plugin/report-message-format': ['error', "^[A-Z`'{].*\\.$"], - 'eslint-plugin/prefer-placeholders': 'error', - 'eslint-plugin/consistent-output': 'error', 'no-debugger': 'error', 'no-console': 'error', @@ -199,23 +197,20 @@ module.exports = [ { files: ['lib/rules/*.js'], rules: { - 'eslint-plugin/no-deprecated-context-methods': 'error', - 'eslint-plugin/no-only-tests': 'error', - 'eslint-plugin/prefer-object-rule': 'error', - 'eslint-plugin/require-meta-docs-description': 'error', 'eslint-plugin/require-meta-docs-url': [ 'error', - { - pattern: `https://eslint.vuejs.org/rules/{{name}}.html` - } + { pattern: 'https://eslint.vuejs.org/rules/{{name}}.html' } ], - 'eslint-plugin/require-meta-has-suggestions': 'error', - 'eslint-plugin/require-meta-schema': 'error', - 'eslint-plugin/require-meta-type': 'error', 'internal/no-invalid-meta': 'error', 'internal/no-invalid-meta-docs-categories': 'error' } }, + { + files: ['eslint-internal-rules/*.js'], + rules: { + 'eslint-plugin/require-meta-docs-url': 'off' + } + }, { files: ['**/*.json'], rules: { diff --git a/lib/rules/attribute-hyphenation.js b/lib/rules/attribute-hyphenation.js index 8f57531c0..11f681ef7 100644 --- a/lib/rules/attribute-hyphenation.js +++ b/lib/rules/attribute-hyphenation.js @@ -60,7 +60,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + mustBeHyphenated: "Attribute '{{text}}' must be hyphenated.", + cannotBeHyphenated: "Attribute '{{text}}' can't be hyphenated." + } }, /** @param {RuleContext} context */ create(context) { @@ -88,9 +92,7 @@ module.exports = { context.report({ node: node.key, loc: node.loc, - message: useHyphenated - ? "Attribute '{{text}}' must be hyphenated." - : "Attribute '{{text}}' can't be hyphenated.", + messageId: useHyphenated ? 'mustBeHyphenated' : 'cannotBeHyphenated', data: { text }, diff --git a/lib/rules/attributes-order.js b/lib/rules/attributes-order.js index e6915aebf..28d4d1ffa 100644 --- a/lib/rules/attributes-order.js +++ b/lib/rules/attributes-order.js @@ -277,9 +277,10 @@ function create(context) { const prevNode = sourceCode.getText(previousNode.key) context.report({ node, - message: `Attribute "${currentNode}" should go before "${prevNode}".`, + messageId: 'expectedOrder', data: { - currentNode + currentNode, + prevNode }, fix(fixer) { @@ -439,7 +440,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + expectedOrder: `Attribute "{{currentNode}}" should go before "{{prevNode}}".` + } }, create } diff --git a/lib/rules/block-tag-newline.js b/lib/rules/block-tag-newline.js index 7096b2daf..007c1e8e1 100644 --- a/lib/rules/block-tag-newline.js +++ b/lib/rules/block-tag-newline.js @@ -72,8 +72,6 @@ module.exports = { messages: { unexpectedOpeningLinebreak: "There should be no line break after '<{{tag}}>'.", - unexpectedClosingLinebreak: - "There should be no line break before ''.", expectedOpeningLinebreak: "Expected {{expected}} after '<{{tag}}>', but {{actual}} found.", expectedClosingLinebreak: diff --git a/lib/rules/component-definition-name-casing.js b/lib/rules/component-definition-name-casing.js index c3a5cbc3d..99ba619c1 100644 --- a/lib/rules/component-definition-name-casing.js +++ b/lib/rules/component-definition-name-casing.js @@ -29,12 +29,15 @@ module.exports = { categories: ['vue3-strongly-recommended', 'strongly-recommended'], url: 'https://eslint.vuejs.org/rules/component-definition-name-casing.html' }, - fixable: 'code', // or "code" or "whitespace" + fixable: 'code', schema: [ { enum: allowedCaseOptions } - ] + ], + messages: { + incorrectCase: 'Property name "{{value}}" is not {{caseType}}.' + } }, /** @param {RuleContext} context */ create(context) { @@ -63,7 +66,7 @@ module.exports = { if (!casing.getChecker(caseType)(nodeValue)) { context.report({ node, - message: 'Property name "{{value}}" is not {{caseType}}.', + messageId: 'incorrectCase', data: { value: nodeValue, caseType diff --git a/lib/rules/component-name-in-template-casing.js b/lib/rules/component-name-in-template-casing.js index b457ffa61..fc1849b18 100644 --- a/lib/rules/component-name-in-template-casing.js +++ b/lib/rules/component-name-in-template-casing.js @@ -69,7 +69,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + incorrectCase: 'Component name "{{name}}" is not {{caseType}}.' + } }, /** @param {RuleContext} context */ create(context) { @@ -156,7 +159,7 @@ module.exports = { context.report({ node: open, loc: open.loc, - message: 'Component name "{{name}}" is not {{caseType}}.', + messageId: 'incorrectCase', data: { name, caseType diff --git a/lib/rules/define-emits-declaration.js b/lib/rules/define-emits-declaration.js index 9ef9bbc03..3d64fed51 100644 --- a/lib/rules/define-emits-declaration.js +++ b/lib/rules/define-emits-declaration.js @@ -15,15 +15,15 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/define-emits-declaration.html' }, fixable: null, - messages: { - hasArg: 'Use type-based declaration instead of runtime declaration.', - hasTypeArg: 'Use runtime declaration instead of type-based declaration.' - }, schema: [ { enum: ['type-based', 'runtime'] } - ] + ], + messages: { + hasArg: 'Use type-based declaration instead of runtime declaration.', + hasTypeArg: 'Use runtime declaration instead of type-based declaration.' + } }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/define-props-declaration.js b/lib/rules/define-props-declaration.js index f86f3ad98..7a0be2259 100644 --- a/lib/rules/define-props-declaration.js +++ b/lib/rules/define-props-declaration.js @@ -15,15 +15,15 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/define-props-declaration.html' }, fixable: null, - messages: { - hasArg: 'Use type-based declaration instead of runtime declaration.', - hasTypeArg: 'Use runtime declaration instead of type-based declaration.' - }, schema: [ { enum: ['type-based', 'runtime'] } - ] + ], + messages: { + hasArg: 'Use type-based declaration instead of runtime declaration.', + hasTypeArg: 'Use runtime declaration instead of type-based declaration.' + } }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/first-attribute-linebreak.js b/lib/rules/first-attribute-linebreak.js index 83f018e02..bdaf078c9 100644 --- a/lib/rules/first-attribute-linebreak.js +++ b/lib/rules/first-attribute-linebreak.js @@ -14,7 +14,7 @@ module.exports = { categories: ['vue3-strongly-recommended', 'strongly-recommended'], url: 'https://eslint.vuejs.org/rules/first-attribute-linebreak.html' }, - fixable: 'whitespace', // or "code" or "whitespace" + fixable: 'whitespace', schema: [ { type: 'object', diff --git a/lib/rules/html-closing-bracket-newline.js b/lib/rules/html-closing-bracket-newline.js index 73afb9d69..0c787526a 100644 --- a/lib/rules/html-closing-bracket-newline.js +++ b/lib/rules/html-closing-bracket-newline.js @@ -40,7 +40,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + expectedBeforeClosingBracket: + 'Expected {{expected}} before closing bracket, but {{actual}} found.' + } }, /** @param {RuleContext} context */ create(context) { @@ -83,8 +87,7 @@ module.exports = { start: prevToken.loc.end, end: closingBracketToken.loc.start }, - message: - 'Expected {{expected}} before closing bracket, but {{actual}} found.', + messageId: 'expectedBeforeClosingBracket', data: { expected: getPhrase(expectedLineBreaks), actual: getPhrase(actualLineBreaks) diff --git a/lib/rules/html-closing-bracket-spacing.js b/lib/rules/html-closing-bracket-spacing.js index bc6320df6..0d5d477ba 100644 --- a/lib/rules/html-closing-bracket-spacing.js +++ b/lib/rules/html-closing-bracket-spacing.js @@ -59,6 +59,7 @@ module.exports = { categories: ['vue3-strongly-recommended', 'strongly-recommended'], url: 'https://eslint.vuejs.org/rules/html-closing-bracket-spacing.html' }, + fixable: 'whitespace', schema: [ { type: 'object', @@ -70,7 +71,10 @@ module.exports = { additionalProperties: false } ], - fixable: 'whitespace' + messages: { + missing: "Expected a space before '{{bracket}}', but not found.", + unexpected: "Expected no space before '{{bracket}}', but found." + } }, /** @param {RuleContext} context */ create(context) { @@ -102,7 +106,7 @@ module.exports = { context.report({ node, loc: lastToken.loc, - message: "Expected a space before '{{bracket}}', but not found.", + messageId: 'missing', data: { bracket: sourceCode.getText(lastToken) }, fix: (fixer) => fixer.insertTextBefore(lastToken, ' ') }) @@ -113,7 +117,7 @@ module.exports = { start: prevToken.loc.end, end: lastToken.loc.end }, - message: "Expected no space before '{{bracket}}', but found.", + messageId: 'unexpected', data: { bracket: sourceCode.getText(lastToken) }, fix: (fixer) => fixer.removeRange([prevToken.range[1], lastToken.range[0]]) diff --git a/lib/rules/html-end-tags.js b/lib/rules/html-end-tags.js index 62a9311bb..58c1142ea 100644 --- a/lib/rules/html-end-tags.js +++ b/lib/rules/html-end-tags.js @@ -16,7 +16,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/html-end-tags.html' }, fixable: 'code', - schema: [] + schema: [], + messages: { + missingEndTag: "'<{{name}}>' should have end tag." + } }, /** @param {RuleContext} context */ create(context) { @@ -39,7 +42,7 @@ module.exports = { context.report({ node: node.startTag, loc: node.startTag.loc, - message: "'<{{name}}>' should have end tag.", + messageId: 'missingEndTag', data: { name }, fix: (fixer) => fixer.insertTextAfter(node, ``) }) diff --git a/lib/rules/html-indent.js b/lib/rules/html-indent.js index 263bdad8e..1670a3308 100644 --- a/lib/rules/html-indent.js +++ b/lib/rules/html-indent.js @@ -20,6 +20,7 @@ module.exports = { return utils.defineTemplateBodyVisitor(context, visitor) }, + // eslint-disable-next-line eslint-plugin/prefer-message-ids meta: { type: 'layout', docs: { diff --git a/lib/rules/html-quotes.js b/lib/rules/html-quotes.js index b365ec911..d1c2b6ffb 100644 --- a/lib/rules/html-quotes.js +++ b/lib/rules/html-quotes.js @@ -27,7 +27,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + expected: 'Expected to be enclosed by {{kind}}.' + } }, /** @param {RuleContext} context */ create(context) { @@ -63,7 +66,7 @@ module.exports = { context.report({ node: node.value, loc: node.value.loc, - message: 'Expected to be enclosed by {{kind}}.', + messageId: 'expected', data: { kind: quoteName }, fix(fixer) { const contentText = quoted ? text.slice(1, -1) : text diff --git a/lib/rules/html-self-closing.js b/lib/rules/html-self-closing.js index 6cbbb7a6d..3cda61ffe 100644 --- a/lib/rules/html-self-closing.js +++ b/lib/rules/html-self-closing.js @@ -119,6 +119,12 @@ module.exports = { } ], maxItems: 1 + }, + messages: { + requireSelfClosing: + 'Require self-closing on {{elementType}} (<{{name}}>).', + disallowSelfClosing: + 'Disallow self-closing on {{elementType}} (<{{name}}/>).' } }, /** @param {RuleContext} context */ @@ -146,7 +152,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: 'Require self-closing on {{elementType}} (<{{name}}>).', + messageId: 'requireSelfClosing', data: { elementType: ELEMENT_TYPE_MESSAGES[elementType], name: node.rawName @@ -170,8 +176,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: - 'Disallow self-closing on {{elementType}} (<{{name}}/>).', + messageId: 'disallowSelfClosing', data: { elementType: ELEMENT_TYPE_MESSAGES[elementType], name: node.rawName diff --git a/lib/rules/jsx-uses-vars.js b/lib/rules/jsx-uses-vars.js index 8f9010da9..b8858e1f3 100644 --- a/lib/rules/jsx-uses-vars.js +++ b/lib/rules/jsx-uses-vars.js @@ -31,6 +31,7 @@ SOFTWARE. 'use strict' module.exports = { + // eslint-disable-next-line eslint-plugin/prefer-message-ids meta: { type: 'problem', docs: { diff --git a/lib/rules/match-component-file-name.js b/lib/rules/match-component-file-name.js index f30a6b50a..181d88f1a 100644 --- a/lib/rules/match-component-file-name.js +++ b/lib/rules/match-component-file-name.js @@ -23,8 +23,6 @@ function canVerify(node) { module.exports = { meta: { - // eslint-disable-next-line eslint-plugin/require-meta-has-suggestions - hasSuggestions: true, type: 'suggestion', docs: { description: 'require component name property to match its file name', @@ -32,6 +30,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/match-component-file-name.html' }, fixable: null, + hasSuggestions: true, schema: [ { type: 'object', @@ -50,7 +49,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + shouldMatchFileName: + 'Component name `{{name}}` should match file name `{{filename}}`.' + } }, /** @param {RuleContext} context */ create(context) { @@ -102,8 +105,7 @@ module.exports = { if (!compareNames(name, filename)) { errors.push({ node, - message: - 'Component name `{{name}}` should match file name `{{filename}}`.', + messageId: 'shouldMatchFileName', data: { filename, name }, suggest: [ { diff --git a/lib/rules/match-component-import-name.js b/lib/rules/match-component-import-name.js index 22eb4214a..344661005 100644 --- a/lib/rules/match-component-import-name.js +++ b/lib/rules/match-component-import-name.js @@ -18,7 +18,6 @@ function getExpectedNames(identifier) { module.exports = { meta: { type: 'problem', - schema: [], docs: { description: 'require the registered component name to match the imported component name', @@ -26,6 +25,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/match-component-import-name.html' }, fixable: null, + schema: [], messages: { unexpected: 'Component alias {{importedName}} should be one of: {{expectedName}}.' diff --git a/lib/rules/max-attributes-per-line.js b/lib/rules/max-attributes-per-line.js index 0f204d500..b1665c17d 100644 --- a/lib/rules/max-attributes-per-line.js +++ b/lib/rules/max-attributes-per-line.js @@ -68,7 +68,7 @@ module.exports = { categories: ['vue3-strongly-recommended', 'strongly-recommended'], url: 'https://eslint.vuejs.org/rules/max-attributes-per-line.html' }, - fixable: 'whitespace', // or "code" or "whitespace" + fixable: 'whitespace', schema: [ { type: 'object', @@ -112,7 +112,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + shouldBeOnNewLine: "'{{name}}' should be on a new line." + } }, /** @param {RuleContext} context */ create(context) { @@ -155,7 +158,7 @@ module.exports = { context.report({ node: prop, loc: prop.loc, - message: "'{{name}}' should be on a new line.", + messageId: 'shouldBeOnNewLine', data: { name: sourceCode.getText(prop.key) }, fix(fixer) { if (i !== 0) return null diff --git a/lib/rules/mustache-interpolation-spacing.js b/lib/rules/mustache-interpolation-spacing.js index a61007be1..51b19c616 100644 --- a/lib/rules/mustache-interpolation-spacing.js +++ b/lib/rules/mustache-interpolation-spacing.js @@ -19,7 +19,13 @@ module.exports = { { enum: ['always', 'never'] } - ] + ], + messages: { + expectedSpaceAfter: "Expected 1 space after '{{', but not found.", + expectedSpaceBefore: "Expected 1 space before '}}', but not found.", + unexpectedSpaceAfter: "Expected no space after '{{', but found.", + unexpectedSpaceBefore: "Expected no space before '}}', but found." + } }, /** @param {RuleContext} context */ create(context) { @@ -54,14 +60,14 @@ module.exports = { if (openBrace.range[1] === firstToken.range[0]) { context.report({ node: openBrace, - message: "Expected 1 space after '{{', but not found.", + messageId: 'expectedSpaceAfter', fix: (fixer) => fixer.insertTextAfter(openBrace, ' ') }) } if (closeBrace.range[0] === lastToken.range[1]) { context.report({ node: closeBrace, - message: "Expected 1 space before '}}', but not found.", + messageId: 'expectedSpaceBefore', fix: (fixer) => fixer.insertTextBefore(closeBrace, ' ') }) } @@ -72,7 +78,7 @@ module.exports = { start: openBrace.loc.start, end: firstToken.loc.start }, - message: "Expected no space after '{{', but found.", + messageId: 'unexpectedSpaceAfter', fix: (fixer) => fixer.removeRange([openBrace.range[1], firstToken.range[0]]) }) @@ -83,7 +89,7 @@ module.exports = { start: lastToken.loc.end, end: closeBrace.loc.end }, - message: "Expected no space before '}}', but found.", + messageId: 'unexpectedSpaceBefore', fix: (fixer) => fixer.removeRange([lastToken.range[1], closeBrace.range[0]]) }) diff --git a/lib/rules/new-line-between-multi-line-property.js b/lib/rules/new-line-between-multi-line-property.js index 9c7ad1041..54812869b 100644 --- a/lib/rules/new-line-between-multi-line-property.js +++ b/lib/rules/new-line-between-multi-line-property.js @@ -54,7 +54,7 @@ module.exports = { categories: undefined, url: 'https://eslint.vuejs.org/rules/new-line-between-multi-line-property.html' }, - fixable: 'whitespace', // or "code" or "whitespace" + fixable: 'whitespace', schema: [ { type: 'object', @@ -67,7 +67,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + missingEmptyLine: + 'Enforce new lines between multi-line properties in Vue components.' + } }, /** @param {RuleContext} context */ @@ -121,8 +125,7 @@ module.exports = { start: pre.loc.end, end: cur.loc.start }, - message: - 'Enforce new lines between multi-line properties in Vue components.', + messageId: 'missingEmptyLine', fix(fixer) { /** @type {Token|null} */ let preToken = null diff --git a/lib/rules/next-tick-style.js b/lib/rules/next-tick-style.js index ecf447b9b..34e0c3db6 100644 --- a/lib/rules/next-tick-style.js +++ b/lib/rules/next-tick-style.js @@ -85,7 +85,13 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/next-tick-style.html' }, fixable: 'code', - schema: [{ enum: ['promise', 'callback'] }] + schema: [{ enum: ['promise', 'callback'] }], + messages: { + usePromise: + 'Use the Promise returned by `nextTick` instead of passing a callback function.', + useCallback: + 'Pass a callback function to `nextTick` instead of using the returned Promise.' + } }, /** @param {RuleContext} context */ create(context) { @@ -107,8 +113,7 @@ module.exports = { ) { context.report({ node, - message: - 'Pass a callback function to `nextTick` instead of using the returned Promise.' + messageId: 'useCallback' }) } @@ -121,8 +126,7 @@ module.exports = { ) { context.report({ node, - message: - 'Use the Promise returned by `nextTick` instead of passing a callback function.', + messageId: 'usePromise', fix(fixer) { return fixer.insertTextAfter(node, '().then') } diff --git a/lib/rules/no-arrow-functions-in-watch.js b/lib/rules/no-arrow-functions-in-watch.js index ca83a16a6..3b1fcd6d4 100644 --- a/lib/rules/no-arrow-functions-in-watch.js +++ b/lib/rules/no-arrow-functions-in-watch.js @@ -14,7 +14,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-arrow-functions-in-watch.html' }, fixable: null, - schema: [] + schema: [], + messages: { + noArrowFunctionsInWatch: + 'You should not use an arrow function to define a watcher.' + } }, /** @param {RuleContext} context */ create(context) { @@ -36,8 +40,7 @@ module.exports = { if (handler.type === 'ArrowFunctionExpression') { context.report({ node: handler, - message: - 'You should not use an arrow function to define a watcher.' + messageId: 'noArrowFunctionsInWatch' }) } } diff --git a/lib/rules/no-async-in-computed-properties.js b/lib/rules/no-async-in-computed-properties.js index 26255e365..2df1e55c0 100644 --- a/lib/rules/no-async-in-computed-properties.js +++ b/lib/rules/no-async-in-computed-properties.js @@ -85,7 +85,13 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-async-in-computed-properties.html' }, fixable: null, - schema: [] + schema: [], + messages: { + unexpectedInFunction: + 'Unexpected {{expressionName}} in computed function.', + unexpectedInProperty: + 'Unexpected {{expressionName}} in "{{propertyName}}" computed property.' + } }, /** @param {RuleContext} context */ create(context) { @@ -151,8 +157,7 @@ module.exports = { ) { context.report({ node, - message: - 'Unexpected {{expressionName}} in "{{propertyName}}" computed property.', + messageId: 'unexpectedInProperty', data: { expressionName: expressionTypes[type], propertyName: cp.key || 'unknown' @@ -170,7 +175,7 @@ module.exports = { ) { context.report({ node, - message: 'Unexpected {{expressionName}} in computed function.', + messageId: 'unexpectedInFunction', data: { expressionName: expressionTypes[type] } diff --git a/lib/rules/no-boolean-default.js b/lib/rules/no-boolean-default.js index 7dbeeceaf..5fd2560ad 100644 --- a/lib/rules/no-boolean-default.js +++ b/lib/rules/no-boolean-default.js @@ -43,7 +43,12 @@ module.exports = { { enum: ['default-false', 'no-default'] } - ] + ], + messages: { + noBooleanDefault: + 'Boolean prop should not set a default (Vue defaults it to false).', + defaultFalse: 'Boolean prop should only be defaulted to false.' + } }, /** @param {RuleContext} context */ create(context) { @@ -95,8 +100,7 @@ module.exports = { case 'no-default': context.report({ node: defaultNode, - message: - 'Boolean prop should not set a default (Vue defaults it to false).' + messageId: 'noBooleanDefault' }) break @@ -104,7 +108,7 @@ module.exports = { if (defaultNode.type !== 'Literal' || defaultNode.value !== false) { context.report({ node: defaultNode, - message: 'Boolean prop should only be defaulted to false.' + messageId: 'defaultFalse' }) } break diff --git a/lib/rules/no-child-content.js b/lib/rules/no-child-content.js index a649b21f0..6ccf10d18 100644 --- a/lib/rules/no-child-content.js +++ b/lib/rules/no-child-content.js @@ -70,7 +70,6 @@ function getLocationRange(nodes) { module.exports = { meta: { - hasSuggestions: true, type: 'problem', docs: { description: @@ -79,6 +78,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-child-content.html' }, fixable: null, + hasSuggestions: true, schema: [ { type: 'object', @@ -95,7 +95,12 @@ module.exports = { }, required: ['additionalDirectives'] } - ] + ], + messages: { + disallowedChildContent: + 'Child content is disallowed because it will be overwritten by the v-{{ directiveName }} directive.', + removeChildContent: 'Remove child content.' + } }, /** @param {RuleContext} context */ create(context) { @@ -138,12 +143,11 @@ module.exports = { context.report({ node: elementNode, loc: getLocationRange(childNodes), - message: - 'Child content is disallowed because it will be overwritten by the v-{{ directiveName }} directive.', + messageId: 'disallowedChildContent', data: { directiveName }, suggest: [ { - desc: 'Remove child content.', + messageId: 'removeChildContent', *fix(fixer) { for (const childNode of childNodes) { yield fixer.remove(childNode) diff --git a/lib/rules/no-dupe-keys.js b/lib/rules/no-dupe-keys.js index b007631f4..c1df4d670 100644 --- a/lib/rules/no-dupe-keys.js +++ b/lib/rules/no-dupe-keys.js @@ -66,7 +66,7 @@ module.exports = { categories: ['vue3-essential', 'essential'], url: 'https://eslint.vuejs.org/rules/no-dupe-keys.html' }, - fixable: null, // or "code" or "whitespace" + fixable: null, schema: [ { type: 'object', @@ -77,7 +77,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + duplicatedKey: "Duplicated key '{{name}}'." + } }, /** @param {RuleContext} context */ create(context) { @@ -93,7 +96,7 @@ module.exports = { if (usedNames.has(o.name)) { context.report({ node: o.node, - message: "Duplicated key '{{name}}'.", + messageId: 'duplicatedKey', data: { name: o.name } @@ -128,7 +131,7 @@ module.exports = { context.report({ node: variable.defs[0].node, - message: "Duplicated key '{{name}}'.", + messageId: 'duplicatedKey', data: { name: prop.propName } diff --git a/lib/rules/no-duplicate-attr-inheritance.js b/lib/rules/no-duplicate-attr-inheritance.js index a8661b091..654929bd1 100644 --- a/lib/rules/no-duplicate-attr-inheritance.js +++ b/lib/rules/no-duplicate-attr-inheritance.js @@ -17,9 +17,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-duplicate-attr-inheritance.html' }, fixable: null, - schema: [ - // fill in your schema - ] + schema: [], + messages: { + noDuplicateAttrInheritance: 'Set "inheritAttrs" to false.' + } }, /** @param {RuleContext} context */ create(context) { @@ -64,7 +65,7 @@ module.exports = { if (attrsRef) { context.report({ node: attrsRef.id, - message: 'Set "inheritAttrs" to false.' + messageId: 'noDuplicateAttrInheritance' }) } } diff --git a/lib/rules/no-duplicate-attributes.js b/lib/rules/no-duplicate-attributes.js index 510df18ab..39a3a0bb9 100644 --- a/lib/rules/no-duplicate-attributes.js +++ b/lib/rules/no-duplicate-attributes.js @@ -50,7 +50,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + duplicateAttribute: "Duplicate attribute '{{name}}'." + } }, /** @param {RuleContext} context */ create(context) { @@ -92,7 +95,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "Duplicate attribute '{{name}}'.", + messageId: 'duplicateAttribute', data: { name } }) } diff --git a/lib/rules/no-invalid-model-keys.js b/lib/rules/no-invalid-model-keys.js index 1695e6fa9..11f4ab218 100644 --- a/lib/rules/no-invalid-model-keys.js +++ b/lib/rules/no-invalid-model-keys.js @@ -3,17 +3,19 @@ const baseRule = require('./valid-model-definition') module.exports = { + // eslint-disable-next-line eslint-plugin/prefer-message-ids meta: { ...baseRule.meta, + // eslint-disable-next-line eslint-plugin/meta-property-ordering type: baseRule.meta.type, docs: { description: baseRule.meta.docs.description, categories: undefined, url: 'https://eslint.vuejs.org/rules/no-invalid-model-keys.html' }, + schema: [], deprecated: true, - replacedBy: ['valid-model-definition'], - schema: [] + replacedBy: ['valid-model-definition'] }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/no-multi-spaces.js b/lib/rules/no-multi-spaces.js index e13cdff74..1dbac86e2 100644 --- a/lib/rules/no-multi-spaces.js +++ b/lib/rules/no-multi-spaces.js @@ -23,7 +23,7 @@ module.exports = { categories: ['vue3-strongly-recommended', 'strongly-recommended'], url: 'https://eslint.vuejs.org/rules/no-multi-spaces.html' }, - fixable: 'whitespace', // or "code" or "whitespace" + fixable: 'whitespace', schema: [ { type: 'object', @@ -34,7 +34,12 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + multipleSpaces: "Multiple spaces found before '{{displayValue}}'.", + useLatestParser: + 'Use the latest vue-eslint-parser. See also https://eslint.vuejs.org/user-guide/#what-is-the-use-the-latest-vue-eslint-parser-error.' + } }, /** @@ -52,8 +57,7 @@ module.exports = { if (path.extname(filename) === '.vue') { context.report({ loc: { line: 1, column: 0 }, - message: - 'Use the latest vue-eslint-parser. See also https://eslint.vuejs.org/user-guide/#what-is-the-use-the-latest-vue-eslint-parser-error.' + messageId: 'useLatestParser' }) } return @@ -84,7 +88,7 @@ module.exports = { start: prevToken.loc.end, end: token.loc.start }, - message: "Multiple spaces found before '{{displayValue}}'.", + messageId: 'multipleSpaces', fix: (fixer) => fixer.replaceTextRange( [prevToken.range[1], token.range[0]], diff --git a/lib/rules/no-multiple-template-root.js b/lib/rules/no-multiple-template-root.js index d5ac49b5a..e4ed1b910 100644 --- a/lib/rules/no-multiple-template-root.js +++ b/lib/rules/no-multiple-template-root.js @@ -15,7 +15,13 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-multiple-template-root.html' }, fixable: null, - schema: [] + schema: [], + messages: { + multipleRoot: 'The template root requires exactly one element.', + textRoot: 'The template root requires an element rather than texts.', + disallowedElement: "The template root disallows '<{{name}}>' elements.", + disallowedDirective: "The template root disallows 'v-for' directives." + } }, /** * @param {RuleContext} context - The rule context. @@ -57,13 +63,13 @@ module.exports = { context.report({ node: extraText, loc: extraText.loc, - message: 'The template root requires an element rather than texts.' + messageId: 'textRoot' }) } else if (extraElement != null) { context.report({ node: extraElement, loc: extraElement.loc, - message: 'The template root requires exactly one element.' + messageId: 'multipleRoot' }) } else { for (const element of rootElements) { @@ -74,7 +80,7 @@ module.exports = { context.report({ node: tag, loc: tag.loc, - message: "The template root disallows '<{{name}}>' elements.", + messageId: 'disallowedElement', data: { name } }) } @@ -82,7 +88,7 @@ module.exports = { context.report({ node: tag, loc: tag.loc, - message: "The template root disallows 'v-for' directives." + messageId: 'disallowedDirective' }) } } diff --git a/lib/rules/no-mutating-props.js b/lib/rules/no-mutating-props.js index 61461010b..57a191991 100644 --- a/lib/rules/no-mutating-props.js +++ b/lib/rules/no-mutating-props.js @@ -109,7 +109,7 @@ module.exports = { categories: ['vue3-essential', 'essential'], url: 'https://eslint.vuejs.org/rules/no-mutating-props.html' }, - fixable: null, // or "code" or "whitespace" + fixable: null, schema: [ { type: 'object', @@ -120,7 +120,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + unexpectedMutation: 'Unexpected mutation of "{{key}}" prop.' + } }, /** @param {RuleContext} context */ create(context) { @@ -137,7 +140,7 @@ module.exports = { function report(node, name) { context.report({ node, - message: 'Unexpected mutation of "{{key}}" prop.', + messageId: 'unexpectedMutation', data: { key: name } diff --git a/lib/rules/no-parsing-error.js b/lib/rules/no-parsing-error.js index 17b63d6c0..f4e2f7e2f 100644 --- a/lib/rules/no-parsing-error.js +++ b/lib/rules/no-parsing-error.js @@ -67,7 +67,10 @@ module.exports = { ), additionalProperties: false } - ] + ], + messages: { + parsingError: 'Parsing error: {{message}}.' + } }, /** * @param {RuleContext} context - The rule context. @@ -91,7 +94,7 @@ module.exports = { context.report({ node, loc: { line: error.lineNumber, column: error.column }, - message: 'Parsing error: {{message}}.', + messageId: 'parsingError', data: { message: error.message.endsWith('.') ? error.message.slice(0, -1) diff --git a/lib/rules/no-potential-component-option-typo.js b/lib/rules/no-potential-component-option-typo.js index a381a0827..50c710802 100644 --- a/lib/rules/no-potential-component-option-typo.js +++ b/lib/rules/no-potential-component-option-typo.js @@ -8,7 +8,6 @@ const utils = require('../utils') const vueComponentOptions = require('../utils/vue-component-options.json') module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'disallow a potential typo in your component property', @@ -17,6 +16,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-potential-component-option-typo.html' }, fixable: null, + hasSuggestions: true, schema: [ { type: 'object', @@ -43,7 +43,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + potentialTypo: `'{{name}}' may be a typo, which is similar to option [{{option}}].` + } }, /** @param {RuleContext} context */ create(context) { @@ -103,7 +106,7 @@ module.exports = { if (potentialTypoList.length > 0) { context.report({ node: id, - message: `'{{name}}' may be a typo, which is similar to option [{{option}}].`, + messageId: 'potentialTypo', data: { name, option: potentialTypoList.map(({ option }) => option).join(',') diff --git a/lib/rules/no-required-prop-with-default.js b/lib/rules/no-required-prop-with-default.js index b098d6f45..0976e0d23 100644 --- a/lib/rules/no-required-prop-with-default.js +++ b/lib/rules/no-required-prop-with-default.js @@ -14,7 +14,6 @@ const utils = require('../utils') module.exports = { meta: { - hasSuggestions: true, type: 'problem', docs: { description: 'enforce props with default values to be optional', @@ -22,6 +21,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-required-prop-with-default.html' }, fixable: 'code', + hasSuggestions: true, schema: [ { type: 'object', diff --git a/lib/rules/no-restricted-class.js b/lib/rules/no-restricted-class.js index f25ad6498..984893b72 100644 --- a/lib/rules/no-restricted-class.js +++ b/lib/rules/no-restricted-class.js @@ -110,14 +110,14 @@ module.exports = { categories: undefined }, fixable: null, - messages: { - forbiddenClass: "'{{class}}' class is not allowed." - }, schema: { type: 'array', items: { type: 'string' } + }, + messages: { + forbiddenClass: "'{{class}}' class is not allowed." } }, diff --git a/lib/rules/no-restricted-component-names.js b/lib/rules/no-restricted-component-names.js index e7fc28608..e5111a748 100644 --- a/lib/rules/no-restricted-component-names.js +++ b/lib/rules/no-restricted-component-names.js @@ -68,7 +68,6 @@ function createSuggest(property, suggest) { module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'disallow specific component names', @@ -76,6 +75,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-restricted-component-names.html' }, fixable: null, + hasSuggestions: true, schema: { type: 'array', items: { diff --git a/lib/rules/no-restricted-custom-event.js b/lib/rules/no-restricted-custom-event.js index abe104b97..f153b6921 100644 --- a/lib/rules/no-restricted-custom-event.js +++ b/lib/rules/no-restricted-custom-event.js @@ -88,7 +88,6 @@ function getCalleeMemberNode(node) { } module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'disallow specific custom event', @@ -96,6 +95,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-restricted-custom-event.html' }, fixable: null, + hasSuggestions: true, schema: { type: 'array', items: { diff --git a/lib/rules/no-restricted-html-elements.js b/lib/rules/no-restricted-html-elements.js index e2f30ccd0..e906d86f2 100644 --- a/lib/rules/no-restricted-html-elements.js +++ b/lib/rules/no-restricted-html-elements.js @@ -33,6 +33,11 @@ module.exports = { }, uniqueItems: true, minItems: 0 + }, + messages: { + forbiddenElement: 'Unexpected use of forbidden HTML element {{name}}.', + // eslint-disable-next-line eslint-plugin/report-message-format + customMessage: '{{message}}' } }, /** @@ -50,14 +55,15 @@ module.exports = { } for (const option of context.options) { - const message = - option.message || - `Unexpected use of forbidden HTML element ${node.rawName}.` const element = option.element || option if (element === node.rawName) { context.report({ - message, + messageId: option.message ? 'customMessage' : 'forbiddenElement', + data: { + name: node.rawName, + message: option.message + }, node: node.startTag }) } diff --git a/lib/rules/no-restricted-props.js b/lib/rules/no-restricted-props.js index db673e4c2..c7203054b 100644 --- a/lib/rules/no-restricted-props.js +++ b/lib/rules/no-restricted-props.js @@ -53,7 +53,6 @@ function parseOption(option) { module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'disallow specific props', @@ -61,6 +60,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-restricted-props.html' }, fixable: null, + hasSuggestions: true, schema: { type: 'array', items: { diff --git a/lib/rules/no-root-v-if.js b/lib/rules/no-root-v-if.js index 304ef3f12..65e262590 100644 --- a/lib/rules/no-root-v-if.js +++ b/lib/rules/no-root-v-if.js @@ -16,7 +16,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-root-v-if.html' }, fixable: null, - schema: [] + schema: [], + messages: { + noRootVIf: '`v-if` should not be used on root element without `v-else`.' + } }, /** @param {RuleContext} context */ create(context) { @@ -36,8 +39,7 @@ module.exports = { context.report({ node: element, loc: element.loc, - message: - '`v-if` should not be used on root element without `v-else`.' + messageId: 'noRootVIf' }) } } diff --git a/lib/rules/no-shared-component-data.js b/lib/rules/no-shared-component-data.js index 3ad217d3c..b91602b14 100644 --- a/lib/rules/no-shared-component-data.js +++ b/lib/rules/no-shared-component-data.js @@ -46,7 +46,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-shared-component-data.html' }, fixable: 'code', - schema: [] + schema: [], + messages: { + dataPropertyMustBeFunction: + '`data` property in component must be a function.' + } }, /** @param {RuleContext} context */ create(context) { @@ -64,7 +68,7 @@ module.exports = { if (invalidData) { context.report({ node: invalidData, - message: '`data` property in component must be a function.', + messageId: 'dataPropertyMustBeFunction', fix(fixer) { const tokens = getFirstAndLastTokens(invalidData.value, sourceCode) diff --git a/lib/rules/no-side-effects-in-computed-properties.js b/lib/rules/no-side-effects-in-computed-properties.js index 9feb02a89..903cf43e7 100644 --- a/lib/rules/no-side-effects-in-computed-properties.js +++ b/lib/rules/no-side-effects-in-computed-properties.js @@ -24,7 +24,13 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-side-effects-in-computed-properties.html' }, fixable: null, - schema: [] + schema: [], + messages: { + unexpectedSideEffectInFunction: + 'Unexpected side effect in computed function.', + unexpectedSideEffectInProperty: + 'Unexpected side effect in "{{key}}" computed property.' + } }, /** @param {RuleContext} context */ create(context) { @@ -102,7 +108,7 @@ module.exports = { if (invalid) { context.report({ node: invalid.node, - message: 'Unexpected side effect in "{{key}}" computed property.', + messageId: 'unexpectedSideEffectInProperty', data: { key: computedProperty.key || 'Unknown' } }) } @@ -163,7 +169,7 @@ module.exports = { if (invalid) { context.report({ node: invalid.node, - message: 'Unexpected side effect in computed function.' + messageId: 'unexpectedSideEffectInFunction' }) } } diff --git a/lib/rules/no-spaces-around-equal-signs-in-attribute.js b/lib/rules/no-spaces-around-equal-signs-in-attribute.js index 733b3212b..9ee153a70 100644 --- a/lib/rules/no-spaces-around-equal-signs-in-attribute.js +++ b/lib/rules/no-spaces-around-equal-signs-in-attribute.js @@ -15,7 +15,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-spaces-around-equal-signs-in-attribute.html' }, fixable: 'whitespace', - schema: [] + schema: [], + messages: { + unexpectedSpaces: 'Unexpected spaces found around equal signs.' + } }, /** @param {RuleContext} context */ create(context) { @@ -37,8 +40,7 @@ module.exports = { start: node.key.loc.end, end: node.value.loc.start }, - message: 'Unexpected spaces found around equal signs.', - data: {}, + messageId: 'unexpectedSpaces', fix: (fixer) => fixer.replaceTextRange(range, expect) }) } diff --git a/lib/rules/no-template-shadow.js b/lib/rules/no-template-shadow.js index a1fb733d8..4b7528a0b 100644 --- a/lib/rules/no-template-shadow.js +++ b/lib/rules/no-template-shadow.js @@ -30,7 +30,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-template-shadow.html' }, fixable: null, - schema: [] + schema: [], + messages: { + alreadyDeclaredInUpperScope: + "Variable '{{name}}' is already declared in the upper scope." + } }, /** @param {RuleContext} context */ create(context) { @@ -105,8 +109,7 @@ module.exports = { context.report({ node: varNode, loc: varNode.loc, - message: - "Variable '{{name}}' is already declared in the upper scope.", + messageId: 'alreadyDeclaredInUpperScope', data: { name } diff --git a/lib/rules/no-template-target-blank.js b/lib/rules/no-template-target-blank.js index d535b14b9..b415bc4b5 100644 --- a/lib/rules/no-template-target-blank.js +++ b/lib/rules/no-template-target-blank.js @@ -116,7 +116,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + missingRel: + 'Using target="_blank" without rel="noopener noreferrer" is a security risk.' + } }, /** @@ -144,8 +148,7 @@ module.exports = { if (hasDangerHref) { context.report({ node, - message: - 'Using target="_blank" without rel="noopener noreferrer" is a security risk.', + messageId: 'missingRel', suggest: [getSuggestion(node)] }) } diff --git a/lib/rules/no-textarea-mustache.js b/lib/rules/no-textarea-mustache.js index 29c8a4da2..b5ad8d966 100644 --- a/lib/rules/no-textarea-mustache.js +++ b/lib/rules/no-textarea-mustache.js @@ -16,7 +16,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-textarea-mustache.html' }, fixable: null, - schema: [] + schema: [], + messages: { + unexpected: "Unexpected mustache. Use 'v-model' instead." + } }, /** @param {RuleContext} context */ create(context) { @@ -30,7 +33,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "Unexpected mustache. Use 'v-model' instead." + messageId: 'unexpected' }) } }) diff --git a/lib/rules/no-unused-components.js b/lib/rules/no-unused-components.js index ffab616c1..af26a964b 100644 --- a/lib/rules/no-unused-components.js +++ b/lib/rules/no-unused-components.js @@ -27,7 +27,10 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + unused: 'The "{{name}}" component has been registered but not used.' + } }, /** @param {RuleContext} context */ create(context) { @@ -124,8 +127,7 @@ module.exports = { context.report({ node, - message: - 'The "{{name}}" component has been registered but not used.', + messageId: 'unused', data: { name } diff --git a/lib/rules/no-unused-vars.js b/lib/rules/no-unused-vars.js index f58cc1398..454b1a189 100644 --- a/lib/rules/no-unused-vars.js +++ b/lib/rules/no-unused-vars.js @@ -51,7 +51,6 @@ function isDestructuringVar(variable) { module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: @@ -60,6 +59,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-unused-vars.html' }, fixable: null, + hasSuggestions: true, schema: [ { type: 'object', @@ -70,7 +70,12 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + unusedVariable: "'{{name}}' is defined but never used.", + replaceWithUnderscore: + 'Replace `{{name}}` with `_{{name}}` to ignore the unused variable.' + } }, /** @param {RuleContext} context */ create(context) { @@ -113,7 +118,7 @@ module.exports = { context.report({ node: variable.id, loc: variable.id.loc, - message: `'{{name}}' is defined but never used.`, + messageId: 'unusedVariable', data: { name: variable.id.name }, @@ -121,7 +126,8 @@ module.exports = { ignorePattern === '^_' ? [ { - desc: `Replace the ${variable.id.name} with _${variable.id.name}`, + messageId: 'replaceWithUnderscore', + data: { name: variable.id.name }, fix(fixer) { return fixer.replaceText( variable.id, diff --git a/lib/rules/no-use-v-if-with-v-for.js b/lib/rules/no-use-v-if-with-v-for.js index e3e7cafc6..dccda39be 100644 --- a/lib/rules/no-use-v-if-with-v-for.js +++ b/lib/rules/no-use-v-if-with-v-for.js @@ -53,7 +53,12 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + movedToWrapper: "This 'v-if' should be moved to the wrapper element.", + shouldUseComputed: + "The '{{iteratorName}}' {{kind}} inside 'v-for' directive should be replaced with a computed property that returns filtered array instead. You should not mix 'v-for' with 'v-if'." + } }, /** @param {RuleContext} context */ create(context) { @@ -80,8 +85,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: - "The '{{iteratorName}}' {{kind}} inside 'v-for' directive should be replaced with a computed property that returns filtered array instead. You should not mix 'v-for' with 'v-if'.", + messageId: 'shouldUseComputed', data: { iteratorName: iteratorNode.type === 'Identifier' @@ -98,7 +102,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "This 'v-if' should be moved to the wrapper element." + messageId: 'movedToWrapper' }) } } diff --git a/lib/rules/no-useless-mustaches.js b/lib/rules/no-useless-mustaches.js index 51e3853ba..884cdf7a5 100644 --- a/lib/rules/no-useless-mustaches.js +++ b/lib/rules/no-useless-mustaches.js @@ -31,16 +31,13 @@ function stripQuotesForHTML(text) { module.exports = { meta: { + type: 'suggestion', docs: { description: 'disallow unnecessary mustache interpolations', categories: undefined, url: 'https://eslint.vuejs.org/rules/no-useless-mustaches.html' }, fixable: 'code', - messages: { - unexpected: - 'Unexpected mustache interpolation with a string literal value.' - }, schema: [ { type: 'object', @@ -55,7 +52,10 @@ module.exports = { additionalProperties: false } ], - type: 'suggestion' + messages: { + unexpected: + 'Unexpected mustache interpolation with a string literal value.' + } }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/no-useless-v-bind.js b/lib/rules/no-useless-v-bind.js index 9f9da6e27..c78cd6b4b 100644 --- a/lib/rules/no-useless-v-bind.js +++ b/lib/rules/no-useless-v-bind.js @@ -11,15 +11,13 @@ const SINGLE_QUOTES_RE = /'/gu module.exports = { meta: { + type: 'suggestion', docs: { description: 'disallow unnecessary `v-bind` directives', categories: undefined, url: 'https://eslint.vuejs.org/rules/no-useless-v-bind.html' }, fixable: 'code', - messages: { - unexpected: 'Unexpected `v-bind` with a string literal value.' - }, schema: [ { type: 'object', @@ -34,7 +32,9 @@ module.exports = { additionalProperties: false } ], - type: 'suggestion' + messages: { + unexpected: 'Unexpected `v-bind` with a string literal value.' + } }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/no-v-html.js b/lib/rules/no-v-html.js index fb9f0a5fe..b135b9549 100644 --- a/lib/rules/no-v-html.js +++ b/lib/rules/no-v-html.js @@ -14,7 +14,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-v-html.html' }, fixable: null, - schema: [] + schema: [], + messages: { + unexpected: "'v-html' directive can lead to XSS attack." + } }, /** @param {RuleContext} context */ create(context) { @@ -24,7 +27,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "'v-html' directive can lead to XSS attack." + messageId: 'unexpected' }) } }) diff --git a/lib/rules/no-v-text.js b/lib/rules/no-v-text.js index 96fe6e019..e404e153b 100644 --- a/lib/rules/no-v-text.js +++ b/lib/rules/no-v-text.js @@ -14,7 +14,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/no-v-text.html' }, fixable: null, - schema: [] + schema: [], + messages: { + unexpected: "Don't use 'v-text'." + } }, /** @param {RuleContext} context */ create(context) { @@ -24,7 +27,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "Don't use 'v-text'." + messageId: 'unexpected' }) } }) diff --git a/lib/rules/order-in-components.js b/lib/rules/order-in-components.js index 50e270625..57247e0c2 100644 --- a/lib/rules/order-in-components.js +++ b/lib/rules/order-in-components.js @@ -228,7 +228,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + order: + 'The "{{name}}" property should be above the "{{firstUnorderedPropertyName}}" property on line {{line}}.' + } }, /** @param {RuleContext} context */ create(context) { @@ -285,7 +289,7 @@ module.exports = { const line = firstUnorderedProperty.node.loc.start.line context.report({ node: property.node, - message: `The "{{name}}" property should be above the "{{firstUnorderedPropertyName}}" property on line {{line}}.`, + messageId: 'order', data: { name: property.name, firstUnorderedPropertyName: firstUnorderedProperty.name, diff --git a/lib/rules/prefer-prop-type-boolean-first.js b/lib/rules/prefer-prop-type-boolean-first.js index aa16707c4..a1001b13b 100644 --- a/lib/rules/prefer-prop-type-boolean-first.js +++ b/lib/rules/prefer-prop-type-boolean-first.js @@ -53,7 +53,6 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/prefer-prop-type-boolean-first.html' }, fixable: null, - // eslint-disable-next-line eslint-plugin/require-meta-has-suggestions -- `context.report` with suggestion is not recognized in `checkArrayExpression` hasSuggestions: true, schema: [], messages: { diff --git a/lib/rules/prop-name-casing.js b/lib/rules/prop-name-casing.js index 4a8ffebb4..094421516 100644 --- a/lib/rules/prop-name-casing.js +++ b/lib/rules/prop-name-casing.js @@ -30,7 +30,7 @@ function create(context) { if (!checker(propName)) { context.report({ node: item.node, - message: 'Prop "{{name}}" is not in {{caseType}}.', + messageId: 'invalidCase', data: { name: propName, caseType @@ -65,7 +65,10 @@ module.exports = { { enum: allowedCaseOptions } - ] + ], + messages: { + invalidCase: 'Prop "{{name}}" is not in {{caseType}}.' + } }, create } diff --git a/lib/rules/require-component-is.js b/lib/rules/require-component-is.js index d4008903a..13e16224b 100644 --- a/lib/rules/require-component-is.js +++ b/lib/rules/require-component-is.js @@ -16,7 +16,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-component-is.html' }, fixable: null, - schema: [] + schema: [], + messages: { + requireComponentIs: + "Expected '' elements to have 'v-bind:is' attribute." + } }, /** @param {RuleContext} context */ create(context) { @@ -27,8 +31,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: - "Expected '' elements to have 'v-bind:is' attribute." + messageId: 'requireComponentIs' }) } } diff --git a/lib/rules/require-default-prop.js b/lib/rules/require-default-prop.js index 21ee6825e..81f40c71f 100644 --- a/lib/rules/require-default-prop.js +++ b/lib/rules/require-default-prop.js @@ -51,7 +51,7 @@ module.exports = { categories: ['vue3-strongly-recommended', 'strongly-recommended'], url: 'https://eslint.vuejs.org/rules/require-default-prop.html' }, - fixable: null, // or "code" or "whitespace" + fixable: null, schema: [], messages: { missingDefault: `Prop '{{propName}}' requires default value to be set.` diff --git a/lib/rules/require-direct-export.js b/lib/rules/require-direct-export.js index bc8f26a25..1c91bd4a3 100644 --- a/lib/rules/require-direct-export.js +++ b/lib/rules/require-direct-export.js @@ -14,7 +14,7 @@ module.exports = { categories: undefined, url: 'https://eslint.vuejs.org/rules/require-direct-export.html' }, - fixable: null, // or "code" or "whitespace" + fixable: null, schema: [ { type: 'object', @@ -23,7 +23,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + expectedDirectExport: + 'Expected the component literal to be directly exported.' + } }, /** @param {RuleContext} context */ create(context) { @@ -96,7 +100,7 @@ module.exports = { context.report({ node: node.parent, - message: `Expected the component literal to be directly exported.` + messageId: 'expectedDirectExport' }) }, ...(disallowFunctional @@ -133,7 +137,7 @@ module.exports = { if (!maybeVue3Functional.hasReturnArgument) { context.report({ node, - message: `Expected the component literal to be directly exported.` + messageId: 'expectedDirectExport' }) } } diff --git a/lib/rules/require-emit-validator.js b/lib/rules/require-emit-validator.js index 8b478be9d..6e403feef 100644 --- a/lib/rules/require-emit-validator.js +++ b/lib/rules/require-emit-validator.js @@ -12,7 +12,6 @@ const utils = require('../utils') module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'require type definitions in emits', @@ -20,13 +19,14 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-emit-validator.html' }, fixable: null, + hasSuggestions: true, + schema: [], messages: { missing: 'Emit "{{name}}" should define at least its validator function.', skipped: 'Emit "{{name}}" should not skip validation, or you may define a validator function with no parameters.', emptyValidation: 'Replace with a validator function with no parameters.' - }, - schema: [] + } }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/require-explicit-emits.js b/lib/rules/require-explicit-emits.js index 267f4e610..8b9645f51 100644 --- a/lib/rules/require-explicit-emits.js +++ b/lib/rules/require-explicit-emits.js @@ -73,7 +73,6 @@ function getNameParamNode(node) { module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'require `emits` option with name triggered by `$emit()`', @@ -81,6 +80,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-explicit-emits.html' }, fixable: null, + hasSuggestions: true, schema: [ { type: 'object', diff --git a/lib/rules/require-expose.js b/lib/rules/require-expose.js index 5dca62ad9..c7e4e1126 100644 --- a/lib/rules/require-expose.js +++ b/lib/rules/require-expose.js @@ -55,7 +55,6 @@ function getCalleeMemberNode(node) { module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'require declare public properties using `expose`', @@ -63,6 +62,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-expose.html' }, fixable: null, + hasSuggestions: true, schema: [], messages: { requireExpose: diff --git a/lib/rules/require-macro-variable-name.js b/lib/rules/require-macro-variable-name.js index e52c1196c..f48df6bba 100644 --- a/lib/rules/require-macro-variable-name.js +++ b/lib/rules/require-macro-variable-name.js @@ -16,7 +16,6 @@ const DEFAULT_OPTIONS = { module.exports = { meta: { - hasSuggestions: true, type: 'suggestion', docs: { description: 'require a certain macro variable name', @@ -24,6 +23,7 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-macro-variable-name.html' }, fixable: null, + hasSuggestions: true, schema: [ { type: 'object', diff --git a/lib/rules/require-name-property.js b/lib/rules/require-name-property.js index 62eb0cfd5..cc2d3db8d 100644 --- a/lib/rules/require-name-property.js +++ b/lib/rules/require-name-property.js @@ -51,7 +51,11 @@ module.exports = { }, fixable: null, hasSuggestions: true, - schema: [] + schema: [], + messages: { + missingName: 'Required name property is not set.', + addName: 'Add name property to component.' + } }, /** @param {RuleContext} context */ create(context) { @@ -70,10 +74,10 @@ module.exports = { context.report({ node: component, - message: 'Required name property is not set.', + messageId: 'missingName', suggest: [ { - desc: 'Add name property to component.', + messageId: 'addName', fix(fixer) { const extension = path.extname(context.getFilename()) const filename = path.basename(context.getFilename(), extension) diff --git a/lib/rules/require-prop-type-constructor.js b/lib/rules/require-prop-type-constructor.js index 45354a1d1..c23ba8080 100644 --- a/lib/rules/require-prop-type-constructor.js +++ b/lib/rules/require-prop-type-constructor.js @@ -11,8 +11,6 @@ const { isDef } = require('../utils') * @typedef {import('../utils').ComponentProp} ComponentProp */ -const message = 'The "{{name}}" property should be a constructor.' - const forbiddenTypes = new Set([ 'Literal', 'TemplateLiteral', @@ -38,8 +36,11 @@ module.exports = { categories: ['vue3-essential', 'essential'], url: 'https://eslint.vuejs.org/rules/require-prop-type-constructor.html' }, - fixable: 'code', // or "code" or "whitespace" - schema: [] + fixable: 'code', + schema: [], + messages: { + propTypeConstructor: 'The "{{name}}" property should be a constructor.' + } }, /** @param {RuleContext} context */ @@ -58,7 +59,7 @@ module.exports = { context.report({ node: prop, - message, + messageId: 'propTypeConstructor', data: { name: propName }, diff --git a/lib/rules/require-prop-types.js b/lib/rules/require-prop-types.js index f603fd184..326095e93 100644 --- a/lib/rules/require-prop-types.js +++ b/lib/rules/require-prop-types.js @@ -18,10 +18,11 @@ module.exports = { categories: ['vue3-strongly-recommended', 'strongly-recommended'], url: 'https://eslint.vuejs.org/rules/require-prop-types.html' }, - fixable: null, // or "code" or "whitespace" - schema: [ - // fill in your schema - ] + fixable: null, + schema: [], + messages: { + requireType: 'Prop "{{name}}" should define at least its type.' + } }, /** @param {RuleContext} context */ create(context) { @@ -84,7 +85,7 @@ module.exports = { 'Unknown prop' context.report({ node, - message: 'Prop "{{name}}" should define at least its type.', + messageId: 'requireType', data: { name } diff --git a/lib/rules/require-render-return.js b/lib/rules/require-render-return.js index 0b427ae1d..1487bfc3c 100644 --- a/lib/rules/require-render-return.js +++ b/lib/rules/require-render-return.js @@ -14,8 +14,11 @@ module.exports = { categories: ['vue3-essential', 'essential'], url: 'https://eslint.vuejs.org/rules/require-render-return.html' }, - fixable: null, // or "code" or "whitespace" - schema: [] + fixable: null, + schema: [], + messages: { + expectedReturn: 'Expected to return a value in render function.' + } }, /** @param {RuleContext} context */ create(context) { @@ -33,7 +36,7 @@ module.exports = { if (key) { context.report({ node: key, - message: 'Expected to return a value in render function.' + messageId: 'expectedReturn' }) } }) diff --git a/lib/rules/require-typed-object-prop.js b/lib/rules/require-typed-object-prop.js index dda7b8346..ee88a0f35 100644 --- a/lib/rules/require-typed-object-prop.js +++ b/lib/rules/require-typed-object-prop.js @@ -120,9 +120,8 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-typed-object-prop.html' }, fixable: null, - schema: [], - // eslint-disable-next-line eslint-plugin/require-meta-has-suggestions -- `context.report` with suggestion is not recognized in `checkPropIdentifierType` hasSuggestions: true, + schema: [], messages: { expectedTypeAnnotation: 'Expected type annotation on object prop.', addTypeAnnotation: 'Add `{{ type }}` type annotation.' diff --git a/lib/rules/require-typed-ref.js b/lib/rules/require-typed-ref.js index 678c02947..4ae12b040 100644 --- a/lib/rules/require-typed-ref.js +++ b/lib/rules/require-typed-ref.js @@ -31,11 +31,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-typed-ref.html' }, fixable: null, + schema: [], messages: { noType: 'Specify type parameter for `{{name}}` function, otherwise created variable will not be typechecked.' - }, - schema: [] + } }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/require-v-for-key.js b/lib/rules/require-v-for-key.js index 1fb7f7a5b..e4b1f2e43 100644 --- a/lib/rules/require-v-for-key.js +++ b/lib/rules/require-v-for-key.js @@ -16,7 +16,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-v-for-key.html' }, fixable: null, - schema: [] + schema: [], + messages: { + requireKey: + "Elements in iteration expect to have 'v-bind:key' directives." + } }, /** @param {RuleContext} context */ create(context) { @@ -38,8 +42,7 @@ module.exports = { context.report({ node: element.startTag, loc: element.startTag.loc, - message: - "Elements in iteration expect to have 'v-bind:key' directives." + messageId: 'requireKey' }) } } diff --git a/lib/rules/require-valid-default-prop.js b/lib/rules/require-valid-default-prop.js index 9535f51d6..24b911b2b 100644 --- a/lib/rules/require-valid-default-prop.js +++ b/lib/rules/require-valid-default-prop.js @@ -79,7 +79,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/require-valid-default-prop.html' }, fixable: null, - schema: [] + schema: [], + messages: { + invalidType: + "Type of the default value for '{{name}}' prop must be a {{types}}." + } }, /** @param {RuleContext} context */ create(context) { @@ -237,8 +241,7 @@ module.exports = { : `[${context.getSourceCode().getText(prop.node.key)}]` context.report({ node, - message: - "Type of the default value for '{{name}}' prop must be a {{types}}.", + messageId: 'invalidType', data: { name: propName, types: [...expectedTypeNames].join(' or ').toLowerCase() diff --git a/lib/rules/return-in-computed-property.js b/lib/rules/return-in-computed-property.js index 87cce8b6f..41860eba8 100644 --- a/lib/rules/return-in-computed-property.js +++ b/lib/rules/return-in-computed-property.js @@ -19,7 +19,7 @@ module.exports = { categories: ['vue3-essential', 'essential'], url: 'https://eslint.vuejs.org/rules/return-in-computed-property.html' }, - fixable: null, // or "code" or "whitespace" + fixable: null, schema: [ { type: 'object', @@ -30,7 +30,13 @@ module.exports = { }, additionalProperties: false } - ] + ], + messages: { + expectedReturnInFunction: + 'Expected to return a value in computed function.', + expectedReturnInProperty: + 'Expected to return a value in "{{name}}" computed property.' + } }, /** @param {RuleContext} context */ create(context) { @@ -83,8 +89,7 @@ module.exports = { if (cp.value && cp.value.parent === node) { context.report({ node, - message: - 'Expected to return a value in "{{name}}" computed property.', + messageId: 'expectedReturnInProperty', data: { name: cp.key || 'Unknown' } @@ -95,7 +100,7 @@ module.exports = { if (cf === node) { context.report({ node, - message: 'Expected to return a value in computed function.' + messageId: 'expectedReturnInFunction' }) } } diff --git a/lib/rules/return-in-emits-validator.js b/lib/rules/return-in-emits-validator.js index 86db20ac9..141aec23c 100644 --- a/lib/rules/return-in-emits-validator.js +++ b/lib/rules/return-in-emits-validator.js @@ -40,8 +40,14 @@ module.exports = { categories: ['vue3-essential', 'essential'], url: 'https://eslint.vuejs.org/rules/return-in-emits-validator.html' }, - fixable: null, // or "code" or "whitespace" - schema: [] + fixable: null, + schema: [], + messages: { + expectedTrue: + 'Expected to return a true value in "{{name}}" emits validator.', + expectedBoolean: + 'Expected to return a boolean value in "{{name}}" emits validator.' + } }, /** @param {RuleContext} context */ create(context) { @@ -127,9 +133,9 @@ module.exports = { if (emits) { context.report({ node, - message: scopeStack.hasReturnValue - ? 'Expected to return a true value in "{{name}}" emits validator.' - : 'Expected to return a boolean value in "{{name}}" emits validator.', + messageId: scopeStack.hasReturnValue + ? 'expectedTrue' + : 'expectedBoolean', data: { name: emits.emitName || 'Unknown' } diff --git a/lib/rules/script-indent.js b/lib/rules/script-indent.js index 2a81cddd3..d5fdf541f 100644 --- a/lib/rules/script-indent.js +++ b/lib/rules/script-indent.js @@ -7,6 +7,7 @@ const indentCommon = require('../utils/indent-common') module.exports = { + // eslint-disable-next-line eslint-plugin/prefer-message-ids meta: { type: 'layout', docs: { diff --git a/lib/rules/script-setup-uses-vars.js b/lib/rules/script-setup-uses-vars.js index 6af828177..05ccc9653 100644 --- a/lib/rules/script-setup-uses-vars.js +++ b/lib/rules/script-setup-uses-vars.js @@ -19,6 +19,7 @@ function camelize(str) { } module.exports = { + // eslint-disable-next-line eslint-plugin/prefer-message-ids meta: { type: 'problem', docs: { @@ -27,8 +28,8 @@ module.exports = { categories: undefined, url: 'https://eslint.vuejs.org/rules/script-setup-uses-vars.html' }, - deprecated: true, - schema: [] + schema: [], + deprecated: true }, /** * @param {RuleContext} context - The rule context. diff --git a/lib/rules/static-class-names-order.js b/lib/rules/static-class-names-order.js index e0ff3ed25..741f6802d 100644 --- a/lib/rules/static-class-names-order.js +++ b/lib/rules/static-class-names-order.js @@ -15,7 +15,10 @@ module.exports = { categories: undefined }, fixable: 'code', - schema: [] + schema: [], + messages: { + shouldBeOrdered: 'Classes should be ordered alphabetically.' + } }, /** @param {RuleContext} context */ create: (context) => @@ -44,7 +47,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: 'Classes should be ordered alphabetically.', + messageId: 'shouldBeOrdered', fix: (fixer) => fixer.replaceText(value, `"${classListSorted}"`) }) } diff --git a/lib/rules/this-in-template.js b/lib/rules/this-in-template.js index 381871c42..d93f07f78 100644 --- a/lib/rules/this-in-template.js +++ b/lib/rules/this-in-template.js @@ -20,7 +20,11 @@ module.exports = { { enum: ['always', 'never'] } - ] + ], + messages: { + unexpected: "Unexpected usage of 'this'.", + expected: "Expected 'this'." + } }, /** @@ -87,7 +91,7 @@ module.exports = { // node.parent should be some code like `this.test`, `this?.['result']` return fixer.replaceText(node.parent, propertyName) }, - message: "Unexpected usage of 'this'." + messageId: 'unexpected' }) } } @@ -112,7 +116,7 @@ module.exports = { context.report({ node: reference.id, loc: reference.id.loc, - message: "Expected 'this'.", + messageId: 'expected', fix(fixer) { return fixer.insertTextBefore(reference.id, 'this.') } diff --git a/lib/rules/use-v-on-exact.js b/lib/rules/use-v-on-exact.js index 89ac9bf74..5aaa17131 100644 --- a/lib/rules/use-v-on-exact.js +++ b/lib/rules/use-v-on-exact.js @@ -168,7 +168,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/use-v-on-exact.html' }, fixable: null, - schema: [] + schema: [], + messages: { + considerExact: "Consider to use '.exact' modifier." + } }, /** @@ -209,7 +212,7 @@ module.exports = { context.report({ node: e.node, loc: e.node.loc, - message: "Consider to use '.exact' modifier." + messageId: 'considerExact' }) } } diff --git a/lib/rules/v-bind-style.js b/lib/rules/v-bind-style.js index 3c60b5956..18911cfc3 100644 --- a/lib/rules/v-bind-style.js +++ b/lib/rules/v-bind-style.js @@ -16,7 +16,12 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/v-bind-style.html' }, fixable: 'code', - schema: [{ enum: ['shorthand', 'longform'] }] + schema: [{ enum: ['shorthand', 'longform'] }], + messages: { + expectedLonghand: "Expected 'v-bind' before ':'.", + unexpectedLonghand: "Unexpected 'v-bind' before ':'.", + expectedLonghandForProp: "Expected 'v-bind:' instead of '.'." + } }, /** @param {RuleContext} context */ create(context) { @@ -33,17 +38,17 @@ module.exports = { return } - let message = "Expected 'v-bind' before ':'." + let messageId = 'expectedLonghand' if (preferShorthand) { - message = "Unexpected 'v-bind' before ':'." + messageId = 'unexpectedLonghand' } else if (shorthandProp) { - message = "Expected 'v-bind:' instead of '.'." + messageId = 'expectedLonghandForProp' } context.report({ node, loc: node.loc, - message, + messageId, *fix(fixer) { if (preferShorthand) { yield fixer.remove(node.key.name) diff --git a/lib/rules/v-for-delimiter-style.js b/lib/rules/v-for-delimiter-style.js index f4f262100..c0e3df654 100644 --- a/lib/rules/v-for-delimiter-style.js +++ b/lib/rules/v-for-delimiter-style.js @@ -18,7 +18,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/v-for-delimiter-style.html' }, fixable: 'code', - schema: [{ enum: ['in', 'of'] }] + schema: [{ enum: ['in', 'of'] }], + messages: { + expected: + "Expected '{{preferredDelimiter}}' instead of '{{usedDelimiter}}' in 'v-for'." + } }, /** @param {RuleContext} context */ create(context) { @@ -48,7 +52,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: `Expected '{{preferredDelimiter}}' instead of '{{usedDelimiter}}' in 'v-for'.`, + messageId: 'expected', data: { preferredDelimiter, usedDelimiter: delimiterToken.value diff --git a/lib/rules/v-on-event-hyphenation.js b/lib/rules/v-on-event-hyphenation.js index 7060ab620..5a3e023f9 100644 --- a/lib/rules/v-on-event-hyphenation.js +++ b/lib/rules/v-on-event-hyphenation.js @@ -5,6 +5,7 @@ const casing = require('../utils/casing') module.exports = { meta: { + type: 'suggestion', docs: { description: 'enforce v-on event naming style on custom components in template', @@ -36,7 +37,12 @@ module.exports = { additionalProperties: false } ], - type: 'suggestion' + messages: { + // eslint-disable-next-line eslint-plugin/report-message-format + mustBeHyphenated: "v-on event '{{text}}' must be hyphenated.", + // eslint-disable-next-line eslint-plugin/report-message-format + cannotBeHyphenated: "v-on event '{{text}}' can't be hyphenated." + } }, /** @param {RuleContext} context */ @@ -64,9 +70,7 @@ module.exports = { context.report({ node: node.key, loc: node.loc, - message: useHyphenated - ? "v-on event '{{text}}' must be hyphenated." - : "v-on event '{{text}}' can't be hyphenated.", + messageId: useHyphenated ? 'mustBeHyphenated' : 'cannotBeHyphenated', data: { text }, diff --git a/lib/rules/v-on-function-call.js b/lib/rules/v-on-function-call.js index e2409794b..ba91b92b3 100644 --- a/lib/rules/v-on-function-call.js +++ b/lib/rules/v-on-function-call.js @@ -83,6 +83,11 @@ module.exports = { additionalProperties: false } ], + messages: { + always: "Method calls inside of 'v-on' directives must have parentheses.", + never: + "Method calls without arguments inside of 'v-on' directives must not have parentheses." + }, deprecated: true, replacedBy: ['v-on-handler-style'] }, @@ -98,8 +103,7 @@ module.exports = { ) { context.report({ node, - message: - "Method calls inside of 'v-on' directives must have parentheses." + messageId: 'always' }) } }) @@ -153,8 +157,7 @@ module.exports = { context.report({ node: expression, - message: - "Method calls without arguments inside of 'v-on' directives must not have parentheses.", + messageId: 'never', fix: hasComment ? null /* The comment is included and cannot be fixed. */ : (fixer) => { diff --git a/lib/rules/v-on-style.js b/lib/rules/v-on-style.js index 6fdf48db5..b2ff507f6 100644 --- a/lib/rules/v-on-style.js +++ b/lib/rules/v-on-style.js @@ -16,7 +16,11 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/v-on-style.html' }, fixable: 'code', - schema: [{ enum: ['shorthand', 'longform'] }] + schema: [{ enum: ['shorthand', 'longform'] }], + messages: { + expectedShorthand: "Expected '@' instead of 'v-on:'.", + expectedLonghand: "Expected 'v-on:' instead of '@'." + } }, /** @param {RuleContext} context */ create(context) { @@ -36,9 +40,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: preferShorthand - ? "Expected '@' instead of 'v-on:'." - : "Expected 'v-on:' instead of '@'.", + messageId: preferShorthand ? 'expectedShorthand' : 'expectedLonghand', fix: (fixer) => preferShorthand ? fixer.replaceTextRange([pos, pos + 5], '@') diff --git a/lib/rules/valid-model-definition.js b/lib/rules/valid-model-definition.js index 7eb9d7949..c1ba6918d 100644 --- a/lib/rules/valid-model-definition.js +++ b/lib/rules/valid-model-definition.js @@ -17,7 +17,10 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/valid-model-definition.html' }, fixable: null, - schema: [] + schema: [], + messages: { + invalidKey: "Invalid key '{{name}}' in model option." + } }, /** @param {RuleContext} context */ create(context) { @@ -38,7 +41,7 @@ module.exports = { if (!VALID_MODEL_KEYS.has(name)) { context.report({ node: p, - message: "Invalid key '{{name}}' in model option.", + messageId: 'invalidKey', data: { name } diff --git a/lib/rules/valid-next-tick.js b/lib/rules/valid-next-tick.js index f2743a827..f9743fc1d 100644 --- a/lib/rules/valid-next-tick.js +++ b/lib/rules/valid-next-tick.js @@ -110,7 +110,6 @@ function isAwaitedPromise(callExpression) { module.exports = { meta: { - hasSuggestions: true, type: 'problem', docs: { description: 'enforce valid `nextTick` function calls', @@ -118,7 +117,17 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/valid-next-tick.html' }, fixable: 'code', - schema: [] + hasSuggestions: true, + schema: [], + messages: { + shouldBeFunction: '`nextTick` is a function.', + missingCallbackOrAwait: + 'Await the Promise returned by `nextTick` or pass a callback function.', + addAwait: 'Add missing `await` statement.', + tooManyParameters: '`nextTick` expects zero or one parameters.', + eitherAwaitOrCallback: + 'Either await the Promise or pass a callback function to `nextTick`.' + } }, /** @param {RuleContext} context */ create(context) { @@ -156,7 +165,7 @@ module.exports = { if (parentNode.type !== 'CallExpression') { context.report({ node, - message: '`nextTick` is a function.', + messageId: 'shouldBeFunction', fix(fixer) { return fixer.insertTextAfter(node, '()') } @@ -168,11 +177,10 @@ module.exports = { if (!isAwaitedPromise(parentNode)) { context.report({ node, - message: - 'Await the Promise returned by `nextTick` or pass a callback function.', + messageId: 'missingCallbackOrAwait', suggest: [ { - desc: 'Add missing `await` statement.', + messageId: 'addAwait', fix(fixer) { return fixer.insertTextBefore(parentNode, 'await ') } @@ -186,7 +194,7 @@ module.exports = { if (parentNode.arguments.length > 1) { context.report({ node, - message: '`nextTick` expects zero or one parameters.' + messageId: 'tooManyParameters' }) return } @@ -194,8 +202,7 @@ module.exports = { if (isAwaitedPromise(parentNode)) { context.report({ node, - message: - 'Either await the Promise or pass a callback function to `nextTick`.' + messageId: 'eitherAwaitOrCallback' }) } } diff --git a/lib/rules/valid-template-root.js b/lib/rules/valid-template-root.js index a2038f6ee..214a5bfc5 100644 --- a/lib/rules/valid-template-root.js +++ b/lib/rules/valid-template-root.js @@ -16,7 +16,12 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/valid-template-root.html' }, fixable: null, - schema: [] + schema: [], + messages: { + emptySrc: + "The template root with 'src' attribute is required to be empty.", + noChild: 'The template requires child element.' + } }, /** @param {RuleContext} context */ create(context) { @@ -44,15 +49,14 @@ module.exports = { context.report({ node: element, loc: element.loc, - message: - "The template root with 'src' attribute is required to be empty." + messageId: 'emptySrc' }) } } else if (rootElements.length === 0 && !hasSrc) { context.report({ node: element, loc: element.loc, - message: 'The template requires child element.' + messageId: 'noChild' }) } } diff --git a/package.json b/package.json index 75e3ebb78..f638f6bd7 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "esbuild": "^0.15.15", "eslint": "^8.15.0", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-eslint-plugin": "^3.5.3", + "eslint-plugin-eslint-plugin": "~5.1.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsonc": "^2.2.1", "eslint-plugin-node-dependencies": ">=0.5.0 <1.0.0", diff --git a/tests/lib/rules/array-bracket-newline.js b/tests/lib/rules/array-bracket-newline.js index 06e1890ca..0144f45ee 100644 --- a/tests/lib/rules/array-bracket-newline.js +++ b/tests/lib/rules/array-bracket-newline.js @@ -55,20 +55,20 @@ tester.run('array-bracket-newline', rule, { }, { code: '', - options: ['never'], output: '', + options: ['never'], errors: ["There should be no linebreak after '['."] }, { code: '', - options: ['never'], output: '', + options: ['never'], errors: ["There should be no linebreak before ']'."] }, { code: '', - options: ['never'], output: '', + options: ['never'], errors: [ "There should be no linebreak after '['.", "There should be no linebreak before ']'." @@ -76,20 +76,20 @@ tester.run('array-bracket-newline', rule, { }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: ["A linebreak is required before ']'."] }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: ["A linebreak is required after '['."] }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: [ "A linebreak is required after '['.", "A linebreak is required before ']'." @@ -97,8 +97,8 @@ tester.run('array-bracket-newline', rule, { }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: [ "A linebreak is required after '['.", "A linebreak is required before ']'." diff --git a/tests/lib/rules/array-bracket-spacing.js b/tests/lib/rules/array-bracket-spacing.js index 8e437d88e..7d490a4bb 100644 --- a/tests/lib/rules/array-bracket-spacing.js +++ b/tests/lib/rules/array-bracket-spacing.js @@ -54,20 +54,20 @@ tester.run('array-bracket-spacing', rule, { }, { code: '', - options: ['never'], output: '', + options: ['never'], errors: ["There should be no space after '['."] }, { code: '', - options: ['never'], output: '', + options: ['never'], errors: ["There should be no space before ']'."] }, { code: '', - options: ['never'], output: '', + options: ['never'], errors: [ "There should be no space after '['.", "There should be no space before ']'." @@ -75,20 +75,20 @@ tester.run('array-bracket-spacing', rule, { }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: ["A space is required before ']'."] }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: ["A space is required after '['."] }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: [ "A space is required after '['.", "A space is required before ']'." @@ -96,8 +96,8 @@ tester.run('array-bracket-spacing', rule, { }, { code: '', - options: ['always'], output: '', + options: ['always'], errors: [ "A space is required after '['.", "A space is required before ']'." diff --git a/tests/lib/rules/arrow-spacing.js b/tests/lib/rules/arrow-spacing.js index 7d64f88f1..c0452ad1d 100644 --- a/tests/lib/rules/arrow-spacing.js +++ b/tests/lib/rules/arrow-spacing.js @@ -105,11 +105,11 @@ tester.run('arrow-spacing', rule, { `, - options: [{ before: false, after: false }], output: ` `, + options: [{ before: false, after: false }], errors: [ { message: 'Unexpected space before =>.', diff --git a/tests/lib/rules/attributes-order.js b/tests/lib/rules/attributes-order.js index 9abb3a266..33eefb026 100644 --- a/tests/lib/rules/attributes-order.js +++ b/tests/lib/rules/attributes-order.js @@ -716,6 +716,8 @@ tester.run('attributes-order', rule, { { filename: 'test.vue', code: '', + output: + '', options: [ { order: [ @@ -733,8 +735,6 @@ tester.run('attributes-order', rule, { ] } ], - output: - '', errors: [ { message: 'Attribute "is" should go before "propone".', @@ -837,6 +837,21 @@ tester.run('attributes-order', rule, { > `, + output: ``, options: [ { order: [ @@ -854,21 +869,6 @@ tester.run('attributes-order', rule, { ] } ], - output: ``, errors: [ { message: 'Attribute "is" should go before "v-once".', @@ -902,6 +902,15 @@ tester.run('attributes-order', rule, { > `, + output: ``, options: [ { order: [ @@ -917,15 +926,6 @@ tester.run('attributes-order', rule, { ] } ], - output: ``, errors: [ { message: 'Attribute "v-if" should go before "class".', @@ -965,13 +965,13 @@ tester.run('attributes-order', rule, { a-prop="A"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "a-prop" should go before "z-prop".', @@ -987,13 +987,13 @@ tester.run('attributes-order', rule, { :a-prop="A"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute ":a-prop" should go before ":z-prop".', @@ -1009,13 +1009,13 @@ tester.run('attributes-order', rule, { @change="foo"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "@change" should go before "@input".', @@ -1031,13 +1031,13 @@ tester.run('attributes-order', rule, { boolean-prop> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "boolean-prop" should go before "z-prop".', @@ -1053,13 +1053,13 @@ tester.run('attributes-order', rule, { v-on:[c]="functionCall"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "v-on:[c]" should go before "v-on:click".', @@ -1075,13 +1075,13 @@ tester.run('attributes-order', rule, { v-on:click="functionCall"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "v-on:click" should go before "v-text".', @@ -1097,13 +1097,13 @@ tester.run('attributes-order', rule, { class="bar"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "class" should go before ":class".' @@ -1118,13 +1118,13 @@ tester.run('attributes-order', rule, { v-if="bar"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "v-if" should go before "v-show".' @@ -1139,13 +1139,13 @@ tester.run('attributes-order', rule, { v-bar="bar"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "v-bar" should go before "v-foo".' @@ -1160,13 +1160,13 @@ tester.run('attributes-order', rule, { v-foo.a="a"> `, - options: [{ alphabetical: true }], output: ``, + options: [{ alphabetical: true }], errors: [ { message: 'Attribute "v-foo.a" should go before "v-foo.b".' @@ -1256,7 +1256,6 @@ tester.run('attributes-order', rule, { v-bind="b"> `, - options: [{ alphabetical: true }], output: ` `, + options: [{ alphabetical: true }], errors: ['Attribute "v-bind:id" should go before "v-on:click".'] }, { @@ -1277,7 +1277,6 @@ tester.run('attributes-order', rule, { v-bind="b"> `, - options: [{ alphabetical: true }], output: ` `, + options: [{ alphabetical: true }], errors: ['Attribute "v-bind" should go before "v-on:click".'] }, { @@ -1298,7 +1298,6 @@ tester.run('attributes-order', rule, { v-bind:id="a"> `, - options: [{ alphabetical: true }], output: ` `, + options: [{ alphabetical: true }], errors: ['Attribute "v-bind:id" should go before "v-on:click".'] }, { @@ -1320,7 +1320,6 @@ tester.run('attributes-order', rule, { v-if="x"> `, - options: [{ alphabetical: true }], output: ` `, + options: [{ alphabetical: true }], errors: [ 'Attribute "v-bind:a" should go before "v-on:click".', 'Attribute "v-if" should go before "v-on:click".' @@ -1346,7 +1346,6 @@ tester.run('attributes-order', rule, { v-if="x"> `, - options: [{ alphabetical: true }], output: ` `, + options: [{ alphabetical: true }], errors: [ 'Attribute "v-bind" should go before "v-on:click".', 'Attribute "v-if" should go before "v-on:click".' @@ -1371,7 +1371,6 @@ tester.run('attributes-order', rule, { v-if="x"> `, - options: [{ alphabetical: true }], output: ` `, + options: [{ alphabetical: true }], errors: ['Attribute "v-if" should go before "a".'] }, { @@ -1392,7 +1392,6 @@ tester.run('attributes-order', rule, { v-if="x"> `, - options: [{ alphabetical: true }], output: ` `, + options: [{ alphabetical: true }], errors: [ 'Attribute "v-bind" should go before "v-on:click".', 'Attribute "v-if" should go before "v-on:click".' @@ -1462,7 +1462,6 @@ tester.run('attributes-order', rule, { v-for="a in items"> `, - options: [{ order: ['LIST_RENDERING', 'CONDITIONALS'] }], output: ` `, + options: [{ order: ['LIST_RENDERING', 'CONDITIONALS'] }], errors: ['Attribute "v-for" should go before "v-if".'] }, { @@ -1483,7 +1483,6 @@ tester.run('attributes-order', rule, { v-for="a in items"> `, - options: [{ order: ['LIST_RENDERING', 'CONDITIONALS'] }], output: ` `, + options: [{ order: ['LIST_RENDERING', 'CONDITIONALS'] }], errors: ['Attribute "v-for" should go before "v-if".'] }, // slot { filename: 'test.vue', + code: '', + output: + '', options: [ { order: [ @@ -1516,9 +1519,6 @@ tester.run('attributes-order', rule, { ] } ], - code: '', - output: - '', errors: [ { message: 'Attribute "bar" should go before "v-slot".' @@ -1528,6 +1528,9 @@ tester.run('attributes-order', rule, { { filename: 'test.vue', + code: '', + output: + '', options: [ { order: [ @@ -1546,9 +1549,6 @@ tester.run('attributes-order', rule, { ] } ], - code: '', - output: - '', errors: [ { message: 'Attribute "ref" should go before "bar".' @@ -1630,7 +1630,6 @@ tester.run('attributes-order', rule, { v-bind="object" @input="handleInput"/> `, - options: [{ order: ['UNIQUE', 'EVENTS', 'OTHER_ATTR'] }], output: ` `, + options: [{ order: ['UNIQUE', 'EVENTS', 'OTHER_ATTR'] }], errors: ['Attribute "@input" should go before "v-bind".'] }, @@ -1651,7 +1651,6 @@ tester.run('attributes-order', rule, { @click="handleClick" attr="foo"/> `, - options: [{ order: ['UNIQUE', 'EVENTS', 'OTHER_ATTR'] }], output: ` `, + options: [{ order: ['UNIQUE', 'EVENTS', 'OTHER_ATTR'] }], errors: ['Attribute "@click" should go before "v-bind".'] }, @@ -1671,7 +1671,6 @@ tester.run('attributes-order', rule, { prop-two="b" :prop-three="c"/> `, - options: [{ order: ['ATTR_STATIC', 'ATTR_DYNAMIC'] }], output: ` `, + options: [{ order: ['ATTR_STATIC', 'ATTR_DYNAMIC'] }], errors: ['Attribute "prop-two" should go before "v-bind:prop-one".'] }, @@ -1694,6 +1694,16 @@ tester.run('attributes-order', rule, { class="class" boolean-prop/> `, + output: ` + `, options: [ { order: [ @@ -1709,16 +1719,6 @@ tester.run('attributes-order', rule, { ] } ], - output: ` - `, errors: [ 'Attribute "v-model" should go before ":prop-one".', 'Attribute ":prop-three" should go before "prop-two".' @@ -1736,6 +1736,15 @@ tester.run('attributes-order', rule, { prop-two="b" :prop-three="c"/> `, + output: ` + `, options: [ { order: [ @@ -1754,15 +1763,6 @@ tester.run('attributes-order', rule, { ] } ], - output: ` - `, errors: ['Attribute "v-model" should go before ":prop-one".'] } ] diff --git a/tests/lib/rules/block-lang.js b/tests/lib/rules/block-lang.js index 235ea7783..6799e5e16 100644 --- a/tests/lib/rules/block-lang.js +++ b/tests/lib/rules/block-lang.js @@ -27,11 +27,11 @@ tester.run('block-lang', rule, { code: '', options: [{ i18n: { lang: 'json', allowNoLang: true } }] }, - { - code: ` + ` + - ` - } + + ` ], invalid: [ { diff --git a/tests/lib/rules/block-spacing.js b/tests/lib/rules/block-spacing.js index c06d54ec9..5fc7d069d 100644 --- a/tests/lib/rules/block-spacing.js +++ b/tests/lib/rules/block-spacing.js @@ -86,11 +86,11 @@ tester.run('block-spacing', rule, { `, - options: ['never'], output: ` `, + options: ['never'], errors: [ { messageId: 'extra', diff --git a/tests/lib/rules/comma-dangle.js b/tests/lib/rules/comma-dangle.js index bbfdbfe01..0c32e8a42 100644 --- a/tests/lib/rules/comma-dangle.js +++ b/tests/lib/rules/comma-dangle.js @@ -38,12 +38,11 @@ tester.run('comma-dangle', rule, { } ] }, - { - code: ` + ` ` - }, + + `, { code: ` `, - options: ['always-multiline'], output: ` `, + options: ['always-multiline'], errors: [ { message: 'Unexpected trailing comma.', diff --git a/tests/lib/rules/comma-spacing.js b/tests/lib/rules/comma-spacing.js index 68b70b324..217fd6b53 100644 --- a/tests/lib/rules/comma-spacing.js +++ b/tests/lib/rules/comma-spacing.js @@ -268,13 +268,13 @@ tester.run('comma-spacing', rule, { fn(a, b) "/> `, - options: [{ before: true, after: false }], output: ` `, + options: [{ before: true, after: false }], errors: [ { message: "A space is required before ','.", diff --git a/tests/lib/rules/comma-style.js b/tests/lib/rules/comma-style.js index f02c3e6d9..fc4f7dcd2 100644 --- a/tests/lib/rules/comma-style.js +++ b/tests/lib/rules/comma-style.js @@ -35,14 +35,13 @@ tester.run('comma-style', rule, { `, options: ['first', { exceptions: { ArrowFunctionExpression: false } }] }, - { - code: ` - ` - }, + ` + + `, { code: ` `, - options: ['last', { exceptions: { ArrowFunctionExpression: false } }], output: ` `, + options: ['last', { exceptions: { ArrowFunctionExpression: false } }], errors: [ { message: "',' should be placed last.", @@ -101,12 +100,12 @@ tester.run('comma-style', rule, { `, - options: ['first', { exceptions: { ArrowFunctionExpression: false } }], output: ` `, + options: ['first', { exceptions: { ArrowFunctionExpression: false } }], errors: [ { message: "',' should be placed first." @@ -122,7 +121,6 @@ tester.run('comma-style', rule, {
`, - options: ['first', { exceptions: { FunctionExpression: false } }], output: ` `, - options: ['last', { exceptions: { FunctionExpression: false } }], output: ` `, + options: ['last', { exceptions: { FunctionExpression: false } }], errors: [ { message: "',' should be placed last." diff --git a/tests/lib/rules/component-api-style.js b/tests/lib/rules/component-api-style.js index a33321251..47621d604 100644 --- a/tests/lib/rules/component-api-style.js +++ b/tests/lib/rules/component-api-style.js @@ -43,7 +43,6 @@ tester.run('component-api-style', rule, { }, { filename: 'test.vue', - options: [['options']], code: ` - ` + `, + options: [['options']] }, { filename: 'test.js', @@ -76,7 +76,6 @@ tester.run('component-api-style', rule, { }, { filename: 'test.js', - options: [['options']], code: ` import { defineComponent } from 'vue' defineComponent({ @@ -88,21 +87,21 @@ tester.run('component-api-style', rule, { }, // ... }) - ` + `, + options: [['options']] }, { filename: 'test.vue', - options: [['script-setup']], code: ` - ` + `, + options: [['script-setup']] }, { filename: 'test.js', - options: [['script-setup']], code: ` import { ref, defineComponent } from 'vue' defineComponent({ @@ -115,11 +114,11 @@ tester.run('component-api-style', rule, { } } }) - ` + `, + options: [['script-setup']] }, { filename: 'test.js', - options: [['script-setup']], code: ` import { defineComponent } from 'vue' defineComponent({ @@ -131,11 +130,11 @@ tester.run('component-api-style', rule, { }, // ... }) - ` + `, + options: [['script-setup']] }, { filename: 'test.vue', - options: [['composition']], code: ` - ` + `, + options: [['composition']] }, { filename: 'test.vue', - options: [['composition-vue2']], code: ` - ` + `, + options: [['composition-vue2']] }, { // https://github.com/vuejs/eslint-plugin-vue/issues/1720 filename: 'test.vue', - options: [['composition']], code: ` `, - options: ['always', { exceptions: ['*'] }], output: null, + options: ['always', { exceptions: ['*'] }], errors: [ 'Expected line break after exception block.', 'Expected line break before exception block.' @@ -415,12 +409,12 @@ comment `, - options: ['always', { exceptions: ['#+#-'] }], output: ` `, + options: ['always', { exceptions: ['#+#-'] }], errors: [ 'Expected line break after exception block.', "Expected line break before '-->'." @@ -432,8 +426,8 @@ comment `, - options: ['always', { exceptions: ['*', '++'] }], output: null, + options: ['always', { exceptions: ['*', '++'] }], errors: [ 'Expected line break after exception block.', { @@ -449,8 +443,8 @@ comment `, - options: ['always', { exceptions: ['*', '++'] }], output: null, + options: ['always', { exceptions: ['*', '++'] }], errors: [ 'Expected line break after exception block.', { diff --git a/tests/lib/rules/html-comment-content-spacing.js b/tests/lib/rules/html-comment-content-spacing.js index b29c1a960..ed3e5d4c4 100644 --- a/tests/lib/rules/html-comment-content-spacing.js +++ b/tests/lib/rules/html-comment-content-spacing.js @@ -16,13 +16,11 @@ const tester = new RuleTester({ }) tester.run('html-comment-content-spacing', rule, { valid: [ - { - code: ` - - ` - }, + ` + + `, { code: ` `, - options: ['always'], output: ` `, + options: ['always'], errors: [ { message: "Expected space after ' `, - options: ['never'], output: ` `, + options: ['never'], errors: [ { message: "Unexpected space after ' `, - options: ['never'], output: ` `, + options: ['never'], errors: [ { message: "Unexpected space after ' `, - options: ['always', { exceptions: ['+'] }], output: null, + options: ['always', { exceptions: ['+'] }], errors: [ 'Expected space after exception block.', 'Expected space before exception block.' @@ -300,8 +294,8 @@ tester.run('html-comment-content-spacing', rule, { `, - options: ['always', { exceptions: ['*'] }], output: null, + options: ['always', { exceptions: ['*'] }], errors: [ 'Expected space after exception block.', 'Expected space before exception block.' @@ -313,12 +307,12 @@ tester.run('html-comment-content-spacing', rule, { `, - options: ['always', { exceptions: ['#+#-'] }], output: ` `, + options: ['always', { exceptions: ['#+#-'] }], errors: [ 'Expected space after exception block.', "Expected space before '-->'." @@ -330,8 +324,8 @@ tester.run('html-comment-content-spacing', rule, { `, - options: ['always', { exceptions: ['*', '++'] }], output: null, + options: ['always', { exceptions: ['*', '++'] }], errors: [ 'Expected space after exception block.', { @@ -347,8 +341,8 @@ tester.run('html-comment-content-spacing', rule, { `, - options: ['always', { exceptions: ['*', '++'] }], output: null, + options: ['always', { exceptions: ['*', '++'] }], errors: [ 'Expected space after exception block.', { diff --git a/tests/lib/rules/html-comment-indent.js b/tests/lib/rules/html-comment-indent.js index 4ec5c6ee2..12880167e 100644 --- a/tests/lib/rules/html-comment-indent.js +++ b/tests/lib/rules/html-comment-indent.js @@ -16,23 +16,21 @@ const tester = new RuleTester({ }) tester.run('html-comment-indent', rule, { valid: [ - { - code: ` - + `, { code: ` + `, // IE conditional comments - { - code: ` - - ` - }, - { - code: ` - - ` - } + ` + + `, + ` + + ` ], invalid: [ @@ -232,7 +224,6 @@ tester.run('html-comment-indent', rule, { --> `, - options: ['tab'], output: ` `, + options: ['tab'], errors: [ { message: 'Expected relative indentation of 1 tab but found 0 tabs.', @@ -318,7 +310,6 @@ tester.run('html-comment-indent', rule, { --> `, - options: [4], output: ` `, + options: [4], errors: [ { message: @@ -407,7 +399,6 @@ tester.run('html-comment-indent', rule, { --> `, - options: [0], output: ` `, + options: [0], errors: [ { message: diff --git a/tests/lib/rules/html-end-tags.js b/tests/lib/rules/html-end-tags.js index b60c9848a..0d795875d 100644 --- a/tests/lib/rules/html-end-tags.js +++ b/tests/lib/rules/html-end-tags.js @@ -62,6 +62,7 @@ tester.run('html-end-tags', rule, { // https://github.com/vuejs/eslint-plugin-vue/issues/1403 { + filename: 'test.vue', code: ` - `, - filename: 'test.vue' + ` } ], invalid: [ diff --git a/tests/lib/rules/html-self-closing.js b/tests/lib/rules/html-self-closing.js index 5589c3da1..11ae3c6cf 100644 --- a/tests/lib/rules/html-self-closing.js +++ b/tests/lib/rules/html-self-closing.js @@ -69,6 +69,7 @@ tester.run('html-self-closing', rule, { // https://github.com/vuejs/eslint-plugin-vue/issues/1403 { + filename: 'test.vue', code: ` - `, - filename: 'test.vue' + ` } // other cases are in `invalid` tests. diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js index 895093da7..3a2c7e82b 100644 --- a/tests/lib/rules/jsx-uses-vars.js +++ b/tests/lib/rules/jsx-uses-vars.js @@ -27,8 +27,7 @@ linter.defineRule('jsx-uses-vars', rule) describe('jsx-uses-vars', () => { ruleTester.run('no-unused-vars', ruleNoUnusedVars, { valid: [ - { - code: ` + ` /* eslint jsx-uses-vars: 1 */ import SomeComponent from './SomeComponent.jsx'; export default { @@ -38,10 +37,8 @@ describe('jsx-uses-vars', () => { ) }, }; + `, ` - }, - { - code: ` /* eslint jsx-uses-vars: 1 */ import SomeComponent from './SomeComponent.vue'; import OtherComponent from './OtherComponent.vue'; @@ -63,10 +60,8 @@ describe('jsx-uses-vars', () => { ) } } + `, ` - }, - { - code: ` /* eslint jsx-uses-vars: 1 */ export default { render () { @@ -76,7 +71,6 @@ describe('jsx-uses-vars', () => { } } ` - } ], invalid: [ diff --git a/tests/lib/rules/key-spacing.js b/tests/lib/rules/key-spacing.js index 519230e23..3d8d48a22 100644 --- a/tests/lib/rules/key-spacing.js +++ b/tests/lib/rules/key-spacing.js @@ -31,8 +31,8 @@ tester.run('key-spacing', rule, { }, { code: '', - options: [{ beforeColon: true }], output: '', + options: [{ beforeColon: true }], errors: [ "Missing space after key 'a'.", "Missing space before value for key 'a'." diff --git a/tests/lib/rules/keyword-spacing.js b/tests/lib/rules/keyword-spacing.js index dad5574e5..dadd553b7 100644 --- a/tests/lib/rules/keyword-spacing.js +++ b/tests/lib/rules/keyword-spacing.js @@ -101,7 +101,6 @@ tester.run('keyword-spacing', rule, { } " /> `, - options: [{ before: false, after: false }], output: ``, + options: [{ before: false, after: false }], errors: [ { message: 'Unexpected space(s) after "if".', diff --git a/tests/lib/rules/max-attributes-per-line.js b/tests/lib/rules/max-attributes-per-line.js index 252bd22c1..fdee711e7 100644 --- a/tests/lib/rules/max-attributes-per-line.js +++ b/tests/lib/rules/max-attributes-per-line.js @@ -14,23 +14,17 @@ const ruleTester = new RuleTester({ ruleTester.run('max-attributes-per-line', rule, { valid: [ - { - code: `` - }, - { - code: ``, + `` - }, - { - code: ``, + `` - }, + `, { code: ``, }, { code: ``, - options: [{ singleline: { max: 2 } }], output: ``, + options: [{ singleline: { max: 2 } }], errors: [ { message: "'job' should be on a new line.", @@ -110,13 +102,13 @@ job="Vet">`, job="Vet"> `, - options: [{ singleline: 3, multiline: 1 }], output: ``, + options: [{ singleline: 3, multiline: 1 }], errors: [ { message: "'age' should be on a new line.", @@ -131,13 +123,13 @@ age="30" job="Vet"> `, - options: [{ multiline: { max: 1 } }], output: ``, + options: [{ multiline: { max: 1 } }], errors: [ { message: "'age' should be on a new line.", diff --git a/tests/lib/rules/max-len.js b/tests/lib/rules/max-len.js index 3ff9f2dff..a1141ec22 100644 --- a/tests/lib/rules/max-len.js +++ b/tests/lib/rules/max-len.js @@ -1075,33 +1075,33 @@ var a = /regexploooooooooooooooooooooooooooooooooooooooooooooooooooooong/.test(b { filename: 'test.vue', code: ``, - errors: ['This line has a length of 41. Maximum allowed is 40.'], - options: [40] + options: [40], + errors: ['This line has a length of 41. Maximum allowed is 40.'] }, { filename: 'test.vue', code: ``, - errors: ['This line has a length of 41. Maximum allowed is 40.'], - options: [{ code: 40 }] + options: [{ code: 40 }], + errors: ['This line has a length of 41. Maximum allowed is 40.'] }, // tabWidth { filename: 'test.vue', code: ``, - errors: ['This line has a length of 45. Maximum allowed is 40.'], - options: [40, 4] + options: [40, 4], + errors: ['This line has a length of 45. Maximum allowed is 40.'] }, { filename: 'test.vue', code: ``, - errors: ['This line has a length of 45. Maximum allowed is 40.'], - options: [{ code: 40, tabWidth: 4 }] + options: [{ code: 40, tabWidth: 4 }], + errors: ['This line has a length of 45. Maximum allowed is 40.'] }, { filename: 'test.vue', code: ``, - errors: ['This line has a length of 44. Maximum allowed is 40.'], - options: [{ code: 40, tabWidth: 3 }] + options: [{ code: 40, tabWidth: 3 }], + errors: ['This line has a length of 44. Maximum allowed is 40.'] }, // comments { @@ -1122,6 +1122,7 @@ var a; // 41 cols comment * */ `, + options: [{ comments: 40 }], errors: [ { message: @@ -1148,8 +1149,7 @@ var a; // 41 cols comment * 'This line has a comment length of 41. Maximum allowed is 40.', line: 13 } - ], - options: [{ comments: 40 }] + ] }, // .js { @@ -1159,6 +1159,7 @@ var a = '81 columns ' var b = \`81 columns \`; /* 81 columns */ `, + options: [], errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', @@ -1172,8 +1173,7 @@ var b = \`81 columns message: 'This line has a length of 81. Maximum allowed is 80.', line: 4 } - ], - options: [] + ] }, { filename: 'test.js', @@ -1182,6 +1182,7 @@ var a = '81 columns ignoreStrings ' var b = \`81 columns \`; /* 81 columns */ `, + options: [{ ignoreStrings: true }], errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', @@ -1191,8 +1192,7 @@ var b = \`81 columns message: 'This line has a length of 81. Maximum allowed is 80.', line: 4 } - ], - options: [{ ignoreStrings: true }] + ] }, { filename: 'test.js', @@ -1201,6 +1201,7 @@ var a = '81 columns ' var b = \`81 columns \`; /* 81 columns */ `, + options: [{ ignoreComments: true }], errors: [ { message: 'This line has a length of 81. Maximum allowed is 80.', @@ -1210,8 +1211,7 @@ var b = \`81 columns message: 'This line has a length of 81. Maximum allowed is 80.', line: 3 } - ], - options: [{ ignoreComments: true }] + ] }, // only script comment { @@ -1222,6 +1222,7 @@ var b = \`81 columns 41 cols * */ `, + options: [{ comments: 40 }], errors: [ { message: @@ -1238,8 +1239,7 @@ var b = \`81 columns 'This line has a comment length of 41. Maximum allowed is 40.', line: 4 } - ], - options: [{ comments: 40 }] + ] } ] }) diff --git a/tests/lib/rules/multi-word-component-names.js b/tests/lib/rules/multi-word-component-names.js index 96302eec8..3d68364bc 100644 --- a/tests/lib/rules/multi-word-component-names.js +++ b/tests/lib/rules/multi-word-component-names.js @@ -165,14 +165,14 @@ tester.run('multi-word-component-names', rule, { }, { filename: 'test.vue', - options: [{ ignores: ['Todo'] }], code: ` - ` + `, + options: [{ ignores: ['Todo'] }] }, { filename: 'test.js', @@ -314,7 +314,6 @@ tester.run('multi-word-component-names', rule, { }, { filename: 'test.vue', - options: [{ ignores: ['Todo'] }], code: ` `, + options: [{ ignores: ['Todo'] }], errors: [ { message: 'Component name "Item" should always be multi-word.', diff --git a/tests/lib/rules/multiline-html-element-content-newline.js b/tests/lib/rules/multiline-html-element-content-newline.js index d06982955..2d68c7685 100644 --- a/tests/lib/rules/multiline-html-element-content-newline.js +++ b/tests/lib/rules/multiline-html-element-content-newline.js @@ -566,7 +566,6 @@ content
`, - options: [{ allowEmptyLines: true, ignoreWhenEmpty: false }], output: ` `, + options: [{ allowEmptyLines: true, ignoreWhenEmpty: false }], errors: [ 'Expected 1 line break after opening tag (`
`), but no line breaks found.' ] @@ -594,7 +594,6 @@ content content
`, - options: [{ allowEmptyLines: true }], output: ` `, + options: [{ allowEmptyLines: true }], errors: [ 'Expected 1 line break after opening tag (`
`), but no line breaks found.', 'Expected 1 line break before closing tag (`
`), but no line breaks found.' diff --git a/tests/lib/rules/multiline-ternary.js b/tests/lib/rules/multiline-ternary.js index 2922f0e65..d79e82eff 100644 --- a/tests/lib/rules/multiline-ternary.js +++ b/tests/lib/rules/multiline-ternary.js @@ -92,6 +92,7 @@ tester.run('multiline-ternary', rule, { ` : null, + options: ['always-multiline'], errors: [ { message: @@ -99,8 +100,7 @@ tester.run('multiline-ternary', rule, { line: 5, column: 15 } - ], - options: ['always-multiline'] + ] }, { filename: 'test.vue', @@ -123,6 +123,7 @@ tester.run('multiline-ternary', rule, { ` : null, + options: ['never'], errors: [ { message: @@ -130,8 +131,7 @@ tester.run('multiline-ternary', rule, { line: 4, column: 21 } - ], - options: ['never'] + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/new-line-between-multi-line-property.js b/tests/lib/rules/new-line-between-multi-line-property.js index a302cca7e..31983d7b0 100644 --- a/tests/lib/rules/new-line-between-multi-line-property.js +++ b/tests/lib/rules/new-line-between-multi-line-property.js @@ -280,7 +280,6 @@ ruleTester.run('new-line-between-multi-line-property', rule, { // test set insertLine and minLineOfMultilineProperty to 5 { filename: 'test.vue', - options: [{ minLineOfMultilineProperty: 5 }], code: ` `, + options: [{ minLineOfMultilineProperty: 5 }], errors: [ { message: @@ -331,7 +331,6 @@ ruleTester.run('new-line-between-multi-line-property', rule, { // test js comments { filename: 'test.vue', - options: [{ minLineOfMultilineProperty: 5 }], code: ` `, + options: [{ minLineOfMultilineProperty: 5 }], errors: [ { message: @@ -384,7 +384,6 @@ ruleTester.run('new-line-between-multi-line-property', rule, { // test js doc { filename: 'test.vue', - options: [], code: ` `, + options: [], errors: [ { message: diff --git a/tests/lib/rules/next-tick-style.js b/tests/lib/rules/next-tick-style.js index 24ef50a8e..28e2d338c 100644 --- a/tests/lib/rules/next-tick-style.js +++ b/tests/lib/rules/next-tick-style.js @@ -40,7 +40,6 @@ tester.run('next-tick-style', rule, { }, { filename: 'test.vue', - options: ['promise'], code: `` + }`, + options: ['promise'] }, { filename: 'test.vue', - options: ['callback'], code: `` + }`, + options: ['callback'] }, // https://github.com/vuejs/eslint-plugin-vue/pull/1400#discussion_r550937977 { filename: 'test.vue', - options: ['promise'], code: `` + }`, + options: ['promise'] }, { filename: 'test.vue', - options: ['callback'], code: `` + }`, + options: ['callback'] } ], invalid: [ @@ -173,7 +173,6 @@ tester.run('next-tick-style', rule, { }, { filename: 'test.vue', - options: ['promise'], code: ``, + options: ['promise'], errors: [ { message: @@ -239,7 +239,6 @@ tester.run('next-tick-style', rule, { }, { filename: 'test.vue', - options: ['callback'], code: ``, output: null, + options: ['callback'], errors: [ { message: diff --git a/tests/lib/rules/no-async-in-computed-properties.js b/tests/lib/rules/no-async-in-computed-properties.js index 31950ec5d..2e150b021 100644 --- a/tests/lib/rules/no-async-in-computed-properties.js +++ b/tests/lib/rules/no-async-in-computed-properties.js @@ -303,11 +303,6 @@ ruleTester.run('no-async-in-computed-properties', rule, { { // https://github.com/vuejs/eslint-plugin-vue/issues/1690 filename: 'test.vue', - parser, - parserOptions: { - sourceType: 'module', - ecmaVersion: 2020 - }, code: ` `, - output: ` - `, + output: null, errors: [ '`slot` attributes are deprecated.', '`slot` attributes are deprecated.' diff --git a/tests/lib/rules/no-deprecated-v-bind-sync.js b/tests/lib/rules/no-deprecated-v-bind-sync.js index 626993731..c02342a86 100644 --- a/tests/lib/rules/no-deprecated-v-bind-sync.js +++ b/tests/lib/rules/no-deprecated-v-bind-sync.js @@ -68,7 +68,7 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { { filename: 'test.vue', code: "", - output: "", + output: null, errors: [ "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." ] @@ -76,7 +76,7 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { { filename: 'test.vue', code: '', - output: '', + output: null, errors: [ "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." ] @@ -84,8 +84,7 @@ ruleTester.run('no-deprecated-v-bind-sync', rule, { { filename: 'test.vue', code: '', - output: - '', + output: null, errors: [ "'.sync' modifier on 'v-bind' directive is deprecated. Use 'v-model:propName' instead." ] diff --git a/tests/lib/rules/no-duplicate-attributes.js b/tests/lib/rules/no-duplicate-attributes.js index 25f6fe5dc..b47611184 100644 --- a/tests/lib/rules/no-duplicate-attributes.js +++ b/tests/lib/rules/no-duplicate-attributes.js @@ -73,26 +73,26 @@ tester.run('no-duplicate-attributes', rule, { { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'style'."], - options: [{ allowCoexistStyle: false }] + options: [{ allowCoexistStyle: false }], + errors: ["Duplicate attribute 'style'."] }, { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'class'."], - options: [{ allowCoexistClass: false }] + options: [{ allowCoexistClass: false }], + errors: ["Duplicate attribute 'class'."] }, { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'style'."], - options: [{ allowCoexistStyle: false }] + options: [{ allowCoexistStyle: false }], + errors: ["Duplicate attribute 'style'."] }, { filename: 'test.vue', code: '', - errors: ["Duplicate attribute 'class'."], - options: [{ allowCoexistClass: false }] + options: [{ allowCoexistClass: false }], + errors: ["Duplicate attribute 'class'."] } ] }) diff --git a/tests/lib/rules/no-multiple-template-root.js b/tests/lib/rules/no-multiple-template-root.js index 167dc6385..e57afd188 100644 --- a/tests/lib/rules/no-multiple-template-root.js +++ b/tests/lib/rules/no-multiple-template-root.js @@ -49,6 +49,7 @@ ruleTester.run('no-multiple-template-root', rule, { // https://github.com/vuejs/eslint-plugin-vue/issues/1439 { + filename: 'test.vue', code: ` - `, - filename: 'test.vue' + ` } ], invalid: [ diff --git a/tests/lib/rules/no-parsing-error.js b/tests/lib/rules/no-parsing-error.js index 7eb295c4b..54500f18c 100644 --- a/tests/lib/rules/no-parsing-error.js +++ b/tests/lib/rules/no-parsing-error.js @@ -206,6 +206,7 @@ tester.run('no-parsing-error', rule, { // https://github.com/vuejs/eslint-plugin-vue/issues/1403 { + filename: 'test.vue', code: ` - `, - filename: 'test.vue' + ` } ], invalid: [ diff --git a/tests/lib/rules/no-potential-component-option-typo.js b/tests/lib/rules/no-potential-component-option-typo.js index 2b85fc999..68ea21901 100644 --- a/tests/lib/rules/no-potential-component-option-typo.js +++ b/tests/lib/rules/no-potential-component-option-typo.js @@ -174,6 +174,7 @@ tester.run('no-potential-component-option-typo', rule, { method: {} } `, + options: [{ custom: ['data', 'methods'] }], errors: [ { message: "'dat' may be a typo, which is similar to option [data].", @@ -209,8 +210,7 @@ tester.run('no-potential-component-option-typo', rule, { } ] } - ], - options: [{ custom: ['data', 'methods'] }] + ] }, // test if user define custom rule is duplicate with presets // test custom option that is not available in the presets @@ -224,6 +224,9 @@ tester.run('no-potential-component-option-typo', rule, { custo: {} } `, + options: [ + { custom: ['data', 'methods', 'custom', 'foo'], presets: ['all'] } + ], errors: [ { message: "'dat' may be a typo, which is similar to option [data].", @@ -279,9 +282,6 @@ tester.run('no-potential-component-option-typo', rule, { } ] } - ], - options: [ - { custom: ['data', 'methods', 'custom', 'foo'], presets: ['all'] } ] }, // test if report correctly, only have preset option @@ -294,6 +294,7 @@ tester.run('no-potential-component-option-typo', rule, { method: {} } `, + options: [{ presets: ['vue'] }], errors: [ { message: "'dat' may be a typo, which is similar to option [data].", @@ -329,8 +330,7 @@ tester.run('no-potential-component-option-typo', rule, { } ] } - ], - options: [{ presets: ['vue'] }] + ] }, // multi preset report typo { @@ -343,6 +343,7 @@ tester.run('no-potential-component-option-typo', rule, { method: {} } `, + options: [{ presets: ['vue', 'vue-router'] }], errors: [ { message: "'dat' may be a typo, which is similar to option [data].", @@ -399,8 +400,7 @@ tester.run('no-potential-component-option-typo', rule, { } ] } - ], - options: [{ presets: ['vue', 'vue-router'] }] + ] }, // test multi suggestion { @@ -411,6 +411,7 @@ tester.run('no-potential-component-option-typo', rule, { method: {} } `, + options: [{ custom: ['data', 'methods'], threshold: 10, presets: [] }], errors: [ { message: `'method' may be a typo, which is similar to option [methods,data].`, @@ -437,8 +438,7 @@ tester.run('no-potential-component-option-typo', rule, { } ] } - ], - options: [{ custom: ['data', 'methods'], threshold: 10, presets: [] }] + ] } ] }) diff --git a/tests/lib/rules/no-ref-as-operand.js b/tests/lib/rules/no-ref-as-operand.js index 1cdbb1041..a932ff1c2 100644 --- a/tests/lib/rules/no-ref-as-operand.js +++ b/tests/lib/rules/no-ref-as-operand.js @@ -131,26 +131,21 @@ tester.run('no-ref-as-operand', rule, { const count = ref(0) const foo = count `, - { - code: ` + ` - ` - }, - { - code: ` + `, + ` - ` - }, - { - code: ` + `, + ` - ` - }, - { - code: ` + `, + ` - ` - } + ` ], invalid: [ { diff --git a/tests/lib/rules/no-required-prop-with-default.js b/tests/lib/rules/no-required-prop-with-default.js index 236de8cd4..ec1e749cc 100644 --- a/tests/lib/rules/no-required-prop-with-default.js +++ b/tests/lib/rules/no-required-prop-with-default.js @@ -196,7 +196,6 @@ tester.run('no-required-prop-with-default', rule, { ); `, - options: [{ autofix: true }], output: ` `, + options: [{ autofix: true }], parserOptions: { parser: require.resolve('@typescript-eslint/parser') }, @@ -237,7 +237,6 @@ tester.run('no-required-prop-with-default', rule, { ); `, - options: [{ autofix: true }], output: ` `, + options: [{ autofix: true }], parserOptions: { parser: require.resolve('@typescript-eslint/parser') }, @@ -647,7 +647,6 @@ tester.run('no-required-prop-with-default', rule, { ); `, - options: [{ autofix: true }], output: ` `, + options: [{ autofix: true }], parserOptions: { parser: require.resolve('@typescript-eslint/parser') }, @@ -868,19 +868,7 @@ tester.run('no-required-prop-with-default', rule, { }) `, - output: ` - - `, + output: null, errors: [ { message: 'Prop "name" should be optional.', diff --git a/tests/lib/rules/no-restricted-call-after-await.js b/tests/lib/rules/no-restricted-call-after-await.js index 69eaf3a42..5409f7f29 100644 --- a/tests/lib/rules/no-restricted-call-after-await.js +++ b/tests/lib/rules/no-restricted-call-after-await.js @@ -147,8 +147,8 @@ tester.run('no-restricted-call-after-await', rule, { useI18n() `, - parserOptions: { ecmaVersion: 2022 }, - options: [{ module: 'vue-i18n', path: 'useI18n' }] + options: [{ module: 'vue-i18n', path: 'useI18n' }], + parserOptions: { ecmaVersion: 2022 } } ], invalid: [ diff --git a/tests/lib/rules/no-restricted-class.js b/tests/lib/rules/no-restricted-class.js index 02815b2c6..2d53598c8 100644 --- a/tests/lib/rules/no-restricted-class.js +++ b/tests/lib/rules/no-restricted-class.js @@ -14,7 +14,7 @@ const ruleTester = new RuleTester({ ruleTester.run('no-restricted-class', rule, { valid: [ - { code: `` }, + ``, { code: ``, options: ['forbidden'] @@ -40,93 +40,93 @@ ruleTester.run('no-restricted-class', rule, { invalid: [ { code: ``, + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'VAttribute' } - ], - options: ['forbidden'] + ] }, { code: ``, + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'Literal' } - ], - options: ['forbidden'] + ] }, { code: ``, + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'Literal' } - ], - options: ['forbidden'] + ] }, { code: ``, + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'Identifier' } - ], - options: ['forbidden'] + ] }, { code: '', + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'TemplateElement' } - ], - options: ['forbidden'] + ] }, { code: ``, + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'Literal' } - ], - options: ['forbidden'] + ] }, { code: ``, + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'Literal' } - ], - options: ['forbidden'] + ] }, { code: ``, + options: ['forbidden'], errors: [ { message: "'forbidden' class is not allowed.", type: 'Literal' } - ], - options: ['forbidden'] + ] }, { code: ``, + options: ['/^for(bidden|gotten)/'], errors: [ { message: "'forbidden' class is not allowed.", type: 'VAttribute' } - ], - options: ['/^for(bidden|gotten)/'] + ] } ] }) diff --git a/tests/lib/rules/no-restricted-html-elements.js b/tests/lib/rules/no-restricted-html-elements.js index 775d94580..3dee64643 100644 --- a/tests/lib/rules/no-restricted-html-elements.js +++ b/tests/lib/rules/no-restricted-html-elements.js @@ -38,38 +38,38 @@ tester.run('no-restricted-html-elements', rule, { { filename: 'test.vue', code: '', + options: ['button'], errors: [ { message: 'Unexpected use of forbidden HTML element button.', line: 1, column: 16 } - ], - options: ['button'] + ] }, { filename: 'test.vue', code: '', + options: ['div'], errors: [ { message: 'Unexpected use of forbidden HTML element div.', line: 1, column: 11 } - ], - options: ['div'] + ] }, { filename: 'test.vue', code: '', + options: [{ element: 'marquee', message: 'Custom error' }], errors: [ { message: 'Custom error', line: 1, column: 11 } - ], - options: [{ element: 'marquee', message: 'Custom error' }] + ] } ] }) diff --git a/tests/lib/rules/no-restricted-props.js b/tests/lib/rules/no-restricted-props.js index 0f1947ed1..934a255b0 100644 --- a/tests/lib/rules/no-restricted-props.js +++ b/tests/lib/rules/no-restricted-props.js @@ -386,10 +386,10 @@ tester.run('no-restricted-props', rule, { }>() `, + options: [{ name: 'foo', suggest: 'Foo' }], parserOptions: { parser: require.resolve('@typescript-eslint/parser') }, - options: [{ name: 'foo', suggest: 'Foo' }], errors: [ { message: 'Using `foo` props is not allowed.', diff --git a/tests/lib/rules/no-setup-props-destructure.js b/tests/lib/rules/no-setup-props-destructure.js index d990f8857..5e84a565e 100644 --- a/tests/lib/rules/no-setup-props-destructure.js +++ b/tests/lib/rules/no-setup-props-destructure.js @@ -160,12 +160,11 @@ tester.run('no-setup-props-destructure', rule, { ` }, - { - code: ` + ` Vue.component('test', { el: a = b - })` - }, + }) + `, { filename: 'test.vue', code: ` diff --git a/tests/lib/rules/no-side-effects-in-computed-properties.js b/tests/lib/rules/no-side-effects-in-computed-properties.js index cec6747f3..a72004060 100644 --- a/tests/lib/rules/no-side-effects-in-computed-properties.js +++ b/tests/lib/rules/no-side-effects-in-computed-properties.js @@ -19,8 +19,8 @@ const ruleTester = new RuleTester({ ruleTester.run('no-side-effects-in-computed-properties', rule, { valid: [ - { - code: `Vue.component('test', { + ` + Vue.component('test', { ...foo, computed: { ...test0({}), @@ -97,10 +97,10 @@ ruleTester.run('no-side-effects-in-computed-properties', rule, { this.someArray.forEach(arr => console.log(arr)) } } - })` - }, - { - code: `Vue.component('test', { + }) + `, + ` + Vue.component('test', { computed: { ...mapGetters(['example']), test1() { @@ -115,18 +115,18 @@ ruleTester.run('no-side-effects-in-computed-properties', rule, { return something.b } } - })` - }, - { - code: `Vue.component('test', { + }) + `, + ` + Vue.component('test', { name: 'something', data() { return {} } - })` - }, - { - code: `Vue.component('test', { + }) + `, + ` + Vue.component('test', { computed: { test () { let a; @@ -134,10 +134,10 @@ ruleTester.run('no-side-effects-in-computed-properties', rule, { return a }, } - })` - }, - { - code: `Vue.component('test', { + }) + `, + ` + Vue.component('test', { computed: { test () { return { @@ -153,32 +153,32 @@ ruleTester.run('no-side-effects-in-computed-properties', rule, { } }, } - })` - }, - { - code: `Vue.component('test', { + }) + `, + ` + Vue.component('test', { computed: { test () { return this.something['a']().reverse() }, } - })` - }, - { - code: `const test = { el: '#app' } + }) + `, + ` + const test = { el: '#app' } Vue.component('test', { el: test.el - })` - }, - { - code: `Vue.component('test', { + }) + `, + ` + Vue.component('test', { computed: { test () { return [...this.items].reverse() }, } - })` - }, + }) + `, { filename: 'test.vue', code: ` @@ -392,13 +392,13 @@ ruleTester.run('no-side-effects-in-computed-properties', rule, { } }); `, + parser: require.resolve('@typescript-eslint/parser'), errors: [ { line: 5, message: 'Unexpected side effect in "test1" computed property.' } - ], - parser: require.resolve('@typescript-eslint/parser') + ] }, { diff --git a/tests/lib/rules/no-template-target-blank.js b/tests/lib/rules/no-template-target-blank.js index 5445ae6d7..b9896d7ed 100644 --- a/tests/lib/rules/no-template-target-blank.js +++ b/tests/lib/rules/no-template-target-blank.js @@ -15,31 +15,21 @@ const ruleTester = new RuleTester({ ruleTester.run('no-template-target-blank', rule, { valid: [ - { code: '' }, - { code: '' }, - { code: '' }, - { - code: '' - }, - { code: '' }, - { - code: '' - }, - { - code: '' - }, + '', + '', + '', + '', + '', + '', + '', { code: '', options: [{ allowReferrer: true }] }, - { code: '' }, - { - code: '' - }, - { code: '' }, - { - code: '' - }, + '', + '', + '', + '', { code: '', options: [{ enforceDynamicLinks: 'never' }] diff --git a/tests/lib/rules/no-this-in-before-route-enter.js b/tests/lib/rules/no-this-in-before-route-enter.js index 1171959ae..f3861672e 100644 --- a/tests/lib/rules/no-this-in-before-route-enter.js +++ b/tests/lib/rules/no-this-in-before-route-enter.js @@ -83,8 +83,8 @@ export default { ], invalid: [ { - code: template(`this.xxx();`), filename: 'ValidComponent.vue', + code: template(`this.xxx();`), errors: [ { message: @@ -97,8 +97,8 @@ export default { ] }, { - code: functionTemplate('this.method();'), filename: 'ValidComponent.vue', + code: functionTemplate('this.method();'), errors: [ { message: @@ -111,8 +111,8 @@ export default { ] }, { - code: template('this.attr = this.method();'), filename: 'ValidComponent.vue', + code: template('this.attr = this.method();'), errors: [ { message: @@ -133,8 +133,8 @@ export default { ] }, { - code: functionTemplate('this.attr = this.method();'), filename: 'ValidComponent.vue', + code: functionTemplate('this.attr = this.method();'), errors: [ { message: @@ -155,10 +155,10 @@ export default { ] }, { + filename: 'ValidComponent.vue', code: template(` if (this.method()) {} `), - filename: 'ValidComponent.vue', errors: [ { message: @@ -171,10 +171,10 @@ export default { ] }, { + filename: 'ValidComponent.vue', code: functionTemplate(` if (true) { this.method(); } `), - filename: 'ValidComponent.vue', errors: [ { message: diff --git a/tests/lib/rules/no-undef-components.js b/tests/lib/rules/no-undef-components.js index f90cb56df..0941f003d 100644 --- a/tests/lib/rules/no-undef-components.js +++ b/tests/lib/rules/no-undef-components.js @@ -656,12 +656,12 @@ tester.run('no-undef-components', rule, { `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } } ], invalid: [ @@ -803,12 +803,12 @@ tester.run('no-undef-components', rule, { `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') }, - parser: require.resolve('vue-eslint-parser'), errors: [ { message: diff --git a/tests/lib/rules/no-undef-properties.js b/tests/lib/rules/no-undef-properties.js index 9a97fe1a9..7ba344197 100644 --- a/tests/lib/rules/no-undef-properties.js +++ b/tests/lib/rules/no-undef-properties.js @@ -1169,13 +1169,13 @@ tester.run('no-undef-properties', rule, {
{{ foo }}
{{ unknown }}
`, - ...getTypeScriptFixtureTestOptions(), errors: [ { message: "'unknown' is not defined.", line: 11 } - ] + ], + ...getTypeScriptFixtureTestOptions() } ] }) diff --git a/tests/lib/rules/no-unsupported-features.js b/tests/lib/rules/no-unsupported-features.js index d12109311..77ee72055 100644 --- a/tests/lib/rules/no-unsupported-features.js +++ b/tests/lib/rules/no-unsupported-features.js @@ -45,7 +45,6 @@ tester.run('no-unsupported-features', rule, { `, - options: [{ version: '^2.5.0' }], output: ` `, + options: [{ version: '^2.5.0' }], errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', diff --git a/tests/lib/rules/no-unsupported-features/define-options.js b/tests/lib/rules/no-unsupported-features/define-options.js index 10b2069b2..a53bd776c 100644 --- a/tests/lib/rules/no-unsupported-features/define-options.js +++ b/tests/lib/rules/no-unsupported-features/define-options.js @@ -47,7 +47,6 @@ tester.run('no-unsupported-features/define-options', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: @@ -68,7 +68,6 @@ export default { name: 'Foo' } `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: diff --git a/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js b/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js index 5307aa616..8f8b0b136 100644 --- a/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js +++ b/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js @@ -66,8 +66,8 @@ tester.run('no-unsupported-features/slot-scope-attribute', rule, { `, - options: buildOptions(), output: null, + options: buildOptions(), errors: [ { message: @@ -83,8 +83,8 @@ tester.run('no-unsupported-features/slot-scope-attribute', rule, { `, - options: buildOptions(), output: null, + options: buildOptions(), errors: [ { message: @@ -100,8 +100,8 @@ tester.run('no-unsupported-features/slot-scope-attribute', rule, { `, - options: buildOptions({ version: '^3.0.0' }), output: null, + options: buildOptions({ version: '^3.0.0' }), errors: [ { message: diff --git a/tests/lib/rules/no-unsupported-features/v-bind-prop-modifier-shorthand.js b/tests/lib/rules/no-unsupported-features/v-bind-prop-modifier-shorthand.js index 1cefc8ff1..58ffda146 100644 --- a/tests/lib/rules/no-unsupported-features/v-bind-prop-modifier-shorthand.js +++ b/tests/lib/rules/no-unsupported-features/v-bind-prop-modifier-shorthand.js @@ -63,11 +63,11 @@ tester.run('no-unsupported-features/v-bind-prop-modifier-shorthand', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`.prop` shorthand are not supported until Vue.js "3.2.0".', @@ -80,11 +80,11 @@ tester.run('no-unsupported-features/v-bind-prop-modifier-shorthand', rule, { `, - options: buildOptions({ version: '2.5.99' }), output: ` `, + options: buildOptions({ version: '2.5.99' }), errors: [ { message: '`.prop` shorthand are not supported until Vue.js "3.2.0".', @@ -97,11 +97,11 @@ tester.run('no-unsupported-features/v-bind-prop-modifier-shorthand', rule, { `, - options: buildOptions({ version: '3.1.0' }), output: ` `, + options: buildOptions({ version: '3.1.0' }), errors: [ { message: '`.prop` shorthand are not supported until Vue.js "3.2.0".', diff --git a/tests/lib/rules/no-unsupported-features/v-slot.js b/tests/lib/rules/no-unsupported-features/v-slot.js index 66b3b0b9e..a382a7eda 100644 --- a/tests/lib/rules/no-unsupported-features/v-slot.js +++ b/tests/lib/rules/no-unsupported-features/v-slot.js @@ -81,13 +81,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -102,13 +102,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -123,13 +123,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -144,13 +144,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -165,13 +165,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -186,13 +186,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -207,13 +207,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -228,13 +228,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -249,13 +249,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -271,13 +271,13 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: ` `, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -292,8 +292,8 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: null, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -310,8 +310,8 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: null, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', @@ -328,8 +328,8 @@ tester.run('no-unsupported-features/v-slot', rule, { `, - options: buildOptions(), output: null, + options: buildOptions(), errors: [ { message: '`v-slot` are not supported until Vue.js "2.6.0".', diff --git a/tests/lib/rules/no-unused-properties.js b/tests/lib/rules/no-unused-properties.js index 2db132c48..0139559b1 100644 --- a/tests/lib/rules/no-unused-properties.js +++ b/tests/lib/rules/no-unused-properties.js @@ -1651,9 +1651,6 @@ tester.run('no-unused-properties', rule, { { // https://github.com/vuejs/eslint-plugin-vue/issues/1643 filename: 'test.vue', - parserOptions: { - parser: '@typescript-eslint/parser' - }, code: ` `, - options: [ - 'never', - { - objectsInObjects: true - } - ], output: ` `, + options: [ + 'never', + { + objectsInObjects: true + } + ], errors: [ "There should be no space after '{'.", "There should be no space after '{'.", @@ -145,13 +145,13 @@ tester.run('object-curly-spacing', rule, { Hello World
`, - options: ['never'], output: ` `, + options: ['never'], errors: [ "There should be no space after '{'.", "There should be no space after '{'.", diff --git a/tests/lib/rules/order-in-components.js b/tests/lib/rules/order-in-components.js index b12c41a33..669383e52 100644 --- a/tests/lib/rules/order-in-components.js +++ b/tests/lib/rules/order-in-components.js @@ -197,7 +197,6 @@ ruleTester.run('order-in-components', rule, { }, } `, - parserOptions, output: ` export default { name: 'app', @@ -211,6 +210,7 @@ ruleTester.run('order-in-components', rule, { }, } `, + parserOptions, errors: [ { message: @@ -239,11 +239,6 @@ ruleTester.run('order-in-components', rule, { }, } `, - parserOptions: { - ecmaVersion: 6, - sourceType: 'module', - ecmaFeatures: { jsx: true } - }, output: ` export default { name: 'app', @@ -262,6 +257,11 @@ ruleTester.run('order-in-components', rule, { }, } `, + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + ecmaFeatures: { jsx: true } + }, errors: [ { message: @@ -294,7 +294,6 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, - parserOptions: { ecmaVersion: 6 }, output: ` Vue.component('smart-list', { name: 'app', @@ -307,6 +306,7 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + parserOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -329,7 +329,6 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, - parserOptions: { ecmaVersion: 6 }, output: ` app.component('smart-list', { name: 'app', @@ -342,6 +341,7 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + parserOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -365,7 +365,6 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, - parserOptions: { ecmaVersion: 6 }, output: ` const { component } = Vue; component('smart-list', { @@ -379,6 +378,7 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + parserOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -402,7 +402,6 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, - parserOptions: { ecmaVersion: 6 }, output: ` new Vue({ el: '#app', @@ -416,6 +415,7 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + parserOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -449,7 +449,6 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: ` export default { name: 'burger', @@ -468,6 +467,7 @@ ruleTester.run('order-in-components', rule, { }, }; `, + parserOptions, errors: [ { message: @@ -486,7 +486,6 @@ ruleTester.run('order-in-components', rule, { test: 'ok' }; `, - parserOptions, output: ` export default { data() { @@ -496,6 +495,7 @@ ruleTester.run('order-in-components', rule, { }; `, options: [{ order: ['data', 'test', 'name'] }], + parserOptions, errors: [ { message: @@ -515,7 +515,6 @@ ruleTester.run('order-in-components', rule, { name: 'burger' }; `, - parserOptions, output: ` export default { /** name of vue component */ @@ -525,6 +524,7 @@ ruleTester.run('order-in-components', rule, { } }; `, + parserOptions, errors: [ { message: @@ -544,7 +544,6 @@ ruleTester.run('order-in-components', rule, { name: 'burger' }; `, - parserOptions, output: ` export default { /** name of vue component */ @@ -554,6 +553,7 @@ ruleTester.run('order-in-components', rule, { }/*test*/ }; `, + parserOptions, errors: [ { message: @@ -565,8 +565,8 @@ ruleTester.run('order-in-components', rule, { { filename: 'example.vue', code: `export default {data(){},name:'burger'};`, - parserOptions, output: `export default {name:'burger',data(){}};`, + parserOptions, errors: [ { message: @@ -586,8 +586,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -607,8 +607,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -628,8 +628,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -649,8 +649,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -670,8 +670,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -691,8 +691,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -712,8 +712,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -733,8 +733,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -754,8 +754,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -775,8 +775,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -796,8 +796,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -817,8 +817,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -838,8 +838,8 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: null, + parserOptions, errors: [ { message: @@ -859,7 +859,6 @@ ruleTester.run('order-in-components', rule, { test: fn(), }; `, - parserOptions, output: ` export default { name: 'burger', @@ -868,6 +867,7 @@ ruleTester.run('order-in-components', rule, { test: fn(), }; `, + parserOptions, errors: [ { message: @@ -896,7 +896,6 @@ ruleTester.run('order-in-components', rule, { name: 'burger', }; `, - parserOptions, output: ` export default { name: 'burger', @@ -914,6 +913,7 @@ ruleTester.run('order-in-components', rule, { testOptionalChaining: a?.b?.c, }; `, + parserOptions, errors: [ { message: @@ -934,11 +934,6 @@ ruleTester.run('order-in-components', rule, { }; `, - parser: require.resolve('vue-eslint-parser'), - parserOptions: { - ...parserOptions, - parser: { ts: require.resolve('@typescript-eslint/parser') } - }, output: ` `, + parser: require.resolve('vue-eslint-parser'), + parserOptions: { + ...parserOptions, + parser: { ts: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: @@ -967,8 +967,6 @@ ruleTester.run('order-in-components', rule, { }) `, - parser: require.resolve('vue-eslint-parser'), - parserOptions, output: ` `, + parser: require.resolve('vue-eslint-parser'), + parserOptions, errors: [ { message: diff --git a/tests/lib/rules/padding-line-between-blocks.js b/tests/lib/rules/padding-line-between-blocks.js index 622839bdc..f53461bae 100644 --- a/tests/lib/rules/padding-line-between-blocks.js +++ b/tests/lib/rules/padding-line-between-blocks.js @@ -125,12 +125,12 @@ tester.run('padding-line-between-blocks', rule, { `, - options: ['never'], output: ` `, + options: ['never'], errors: [ { message: 'Unexpected blank line before this block.', @@ -214,7 +214,6 @@ tester.run('padding-line-between-blocks', rule, { `, - options: ['never'], output: ` @@ -225,6 +224,7 @@ tester.run('padding-line-between-blocks', rule, { `, + options: ['never'], errors: [ { message: 'Unexpected blank line before this block.', @@ -290,7 +290,6 @@ tester.run('padding-line-between-blocks', rule, { `, - options: ['never'], output: ` @@ -304,6 +303,7 @@ tester.run('padding-line-between-blocks', rule, { TEXT `, + options: ['never'], errors: [ { message: 'Unexpected blank line before this block.', diff --git a/tests/lib/rules/padding-line-between-tags.js b/tests/lib/rules/padding-line-between-tags.js index 67aa6b228..70c7a57bb 100644 --- a/tests/lib/rules/padding-line-between-tags.js +++ b/tests/lib/rules/padding-line-between-tags.js @@ -498,18 +498,18 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'always', prev: '*', next: '*' }, + { blankLine: 'never', prev: 'br', next: '*' } + ] + ], errors: [ { message: 'Expected blank line before this tag.', line: 7, column: 13 } - ], - options: [ - [ - { blankLine: 'always', prev: '*', next: '*' }, - { blankLine: 'never', prev: 'br', next: '*' } - ] ] }, { @@ -541,18 +541,18 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'always', prev: '*', next: '*' }, + { blankLine: 'never', prev: '*', next: 'br' } + ] + ], errors: [ { message: 'Expected blank line before this tag.', line: 8, column: 13 } - ], - options: [ - [ - { blankLine: 'always', prev: '*', next: '*' }, - { blankLine: 'never', prev: '*', next: 'br' } - ] ] }, { @@ -586,6 +586,7 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'never', prev: '*', next: '*' }]], errors: [ { message: 'Unexpected blank line before this tag.', @@ -597,8 +598,7 @@ tester.run('padding-line-between-tags', rule, { line: 11, column: 13 } - ], - options: [[{ blankLine: 'never', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -624,6 +624,7 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'never', prev: '*', next: '*' }]], errors: [ { message: 'Unexpected blank line before this tag.', @@ -635,8 +636,7 @@ tester.run('padding-line-between-tags', rule, { line: 9, column: 11 } - ], - options: [[{ blankLine: 'never', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -669,18 +669,18 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'never', prev: '*', next: '*' }, + { blankLine: 'always', prev: 'br', next: 'div' } + ] + ], errors: [ { message: 'Expected blank line before this tag.', line: 8, column: 13 } - ], - options: [ - [ - { blankLine: 'never', prev: '*', next: '*' }, - { blankLine: 'always', prev: 'br', next: 'div' } - ] ] }, { @@ -712,6 +712,13 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'always', prev: '*', next: '*' }, + { blankLine: 'never', prev: 'br', next: 'div' }, + { blankLine: 'never', prev: 'br', next: 'img' } + ] + ], errors: [ { message: 'Expected blank line before this tag.', @@ -728,13 +735,6 @@ tester.run('padding-line-between-tags', rule, { line: 9, column: 11 } - ], - options: [ - [ - { blankLine: 'always', prev: '*', next: '*' }, - { blankLine: 'never', prev: 'br', next: 'div' }, - { blankLine: 'never', prev: 'br', next: 'img' } - ] ] }, { @@ -764,18 +764,18 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'always', prev: 'br', next: 'div' }, + { blankLine: 'always', prev: 'div', next: 'br' } + ] + ], errors: [ { message: 'Expected blank line before this tag.', line: 8, column: 11 } - ], - options: [ - [ - { blankLine: 'always', prev: 'br', next: 'div' }, - { blankLine: 'always', prev: 'div', next: 'br' } - ] ] }, { @@ -805,18 +805,18 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'always', prev: 'br', next: 'div' }, + { blankLine: 'always', prev: 'br', next: 'br' } + ] + ], errors: [ { message: 'Expected blank line before this tag.', line: 9, column: 11 } - ], - options: [ - [ - { blankLine: 'always', prev: 'br', next: 'div' }, - { blankLine: 'always', prev: 'br', next: 'br' } - ] ] }, { @@ -848,6 +848,12 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'always', prev: '*', next: '*' }, + { blankLine: 'never', prev: 'br', next: 'br' } + ] + ], errors: [ { message: 'Expected blank line before this tag.', @@ -864,12 +870,6 @@ tester.run('padding-line-between-tags', rule, { line: 10, column: 11 } - ], - options: [ - [ - { blankLine: 'always', prev: '*', next: '*' }, - { blankLine: 'never', prev: 'br', next: 'br' } - ] ] }, { @@ -901,14 +901,14 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'never', prev: 'br', next: 'br' }]], errors: [ { message: 'Unexpected blank line before this tag.', line: 11, column: 11 } - ], - options: [[{ blankLine: 'never', prev: 'br', next: 'br' }]] + ] }, { filename: 'test.vue', @@ -935,14 +935,14 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'always', prev: '*', next: 'br' }]], errors: [ { message: 'Expected blank line before this tag.', line: 7, column: 11 } - ], - options: [[{ blankLine: 'always', prev: '*', next: 'br' }]] + ] }, { filename: 'test.vue', @@ -1015,14 +1015,14 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'never', prev: '*', next: '*' }]], errors: [ { message: 'Unexpected blank line before this tag.', line: 6, column: 12 } - ], - options: [[{ blankLine: 'never', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -1045,14 +1045,14 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'never', prev: '*', next: '*' }]], errors: [ { message: 'Unexpected blank line before this tag.', line: 7, column: 12 } - ], - options: [[{ blankLine: 'never', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -1076,14 +1076,14 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'never', prev: '*', next: '*' }]], errors: [ { message: 'Unexpected blank line before this tag.', line: 8, column: 12 } - ], - options: [[{ blankLine: 'never', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -1109,14 +1109,14 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'never', prev: '*', next: '*' }]], errors: [ { message: 'Unexpected blank line before this tag.', line: 10, column: 12 } - ], - options: [[{ blankLine: 'never', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -1147,14 +1147,14 @@ tester.run('padding-line-between-tags', rule, {
`, + options: [[{ blankLine: 'consistent', prev: '*', next: '*' }]], errors: [ { message: 'Expected blank line before this tag.', line: 7, column: 11 } - ], - options: [[{ blankLine: 'consistent', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -1191,6 +1191,7 @@ tester.run('padding-line-between-tags', rule, {
`, + options: [[{ blankLine: 'consistent', prev: '*', next: '*' }]], errors: [ { message: 'Expected blank line before this tag.', @@ -1207,8 +1208,7 @@ tester.run('padding-line-between-tags', rule, { line: 9, column: 11 } - ], - options: [[{ blankLine: 'consistent', prev: '*', next: '*' }]] + ] }, { filename: 'test.vue', @@ -1243,6 +1243,12 @@ tester.run('padding-line-between-tags', rule, { `, + options: [ + [ + { blankLine: 'consistent', prev: '*', next: '*' }, + { blankLine: 'never', prev: 'br', next: 'br' } + ] + ], errors: [ { message: 'Unexpected blank line before this tag.', @@ -1259,12 +1265,6 @@ tester.run('padding-line-between-tags', rule, { line: 13, column: 11 } - ], - options: [ - [ - { blankLine: 'consistent', prev: '*', next: '*' }, - { blankLine: 'never', prev: 'br', next: 'br' } - ] ] }, { @@ -1288,14 +1288,14 @@ tester.run('padding-line-between-tags', rule, { `, + options: [[{ blankLine: 'consistent', prev: '*', next: '*' }]], errors: [ { message: 'Unexpected blank line before this tag.', line: 7, column: 11 } - ], - options: [[{ blankLine: 'consistent', prev: '*', next: '*' }]] + ] } ] }) diff --git a/tests/lib/rules/prefer-true-attribute-shorthand.js b/tests/lib/rules/prefer-true-attribute-shorthand.js index e7d52ef7f..0bad5c173 100644 --- a/tests/lib/rules/prefer-true-attribute-shorthand.js +++ b/tests/lib/rules/prefer-true-attribute-shorthand.js @@ -157,6 +157,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { `, + output: null, errors: [ { messageId: 'expectShort', @@ -172,8 +173,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { } ] } - ], - output: null + ] }, { filename: 'test.vue', @@ -181,6 +181,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { `, + output: null, errors: [ { messageId: 'expectShort', @@ -196,8 +197,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { } ] } - ], - output: null + ] }, { filename: 'test.vue', @@ -205,6 +205,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { `, + output: null, options: ['always'], errors: [ { @@ -221,8 +222,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { } ] } - ], - output: null + ] }, { filename: 'test.vue', @@ -230,6 +230,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { `, + output: null, options: ['always'], errors: [ { @@ -246,8 +247,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { } ] } - ], - output: null + ] }, { filename: 'test.vue', @@ -255,6 +255,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { `, + output: null, options: ['never'], errors: [ { @@ -276,8 +277,7 @@ tester.run('prefer-true-attribute-shorthand', rule, { } ] } - ], - output: null + ] } ] }) diff --git a/tests/lib/rules/require-emit-validator.js b/tests/lib/rules/require-emit-validator.js index 2b60e8910..d539b55ea 100644 --- a/tests/lib/rules/require-emit-validator.js +++ b/tests/lib/rules/require-emit-validator.js @@ -118,8 +118,8 @@ ruleTester.run('require-emit-validator', rule, { } }) `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', @@ -132,8 +132,8 @@ ruleTester.run('require-emit-validator', rule, { }, }) `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', @@ -333,8 +333,8 @@ ruleTester.run('require-emit-validator', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'missing', diff --git a/tests/lib/rules/require-explicit-emits.js b/tests/lib/rules/require-explicit-emits.js index 43a3c2599..af90569dd 100644 --- a/tests/lib/rules/require-explicit-emits.js +++ b/tests/lib/rules/require-explicit-emits.js @@ -1975,14 +1975,14 @@ emits: {'foo': null} emit('baz') emit('qux') `, - ...getTypeScriptFixtureTestOptions(), errors: [ { message: 'The "qux" event has been triggered but not declared on `defineEmits`.', line: 8 } - ] + ], + ...getTypeScriptFixtureTestOptions() } ] }) diff --git a/tests/lib/rules/require-expose.js b/tests/lib/rules/require-expose.js index 64d073c24..76932cd95 100644 --- a/tests/lib/rules/require-expose.js +++ b/tests/lib/rules/require-expose.js @@ -95,15 +95,13 @@ tester.run('require-expose', rule, { ` }, - { - code: ` + ` Vue.mixin({ methods: { foo () {} } }) - ` - }, + `, { filename: 'test.vue', code: ` diff --git a/tests/lib/rules/require-macro-variable-name.js b/tests/lib/rules/require-macro-variable-name.js index c54c224a5..ed99a64e5 100644 --- a/tests/lib/rules/require-macro-variable-name.js +++ b/tests/lib/rules/require-macro-variable-name.js @@ -237,6 +237,7 @@ tester.run('require-macro-variable-name', rule, { const attrs = useAttrs({}) `, + options: [customOptions], errors: [ { message: `The variable name of "defineSlots" must be "${customOptions.defineSlots}".`, @@ -289,8 +290,7 @@ tester.run('require-macro-variable-name', rule, { } ] } - ], - options: [customOptions] + ] }, { filename: 'test.vue', @@ -300,6 +300,7 @@ tester.run('require-macro-variable-name', rule, { const attrsCustom = useAttrs({}) `, + options: [{ defineSlots: 'slotsCustom' }], errors: [ { message: `The variable name of "useAttrs" must be "attrs".`, @@ -317,8 +318,7 @@ tester.run('require-macro-variable-name', rule, { } ] } - ], - options: [{ defineSlots: 'slotsCustom' }] + ] } ] }) diff --git a/tests/lib/rules/require-prop-comment.js b/tests/lib/rules/require-prop-comment.js index 900f25ec3..3863abc3d 100644 --- a/tests/lib/rules/require-prop-comment.js +++ b/tests/lib/rules/require-prop-comment.js @@ -20,8 +20,7 @@ const tester = new RuleTester({ tester.run('require-prop-comment', rule, { valid: [ - { - code: ` + ` - ` - }, + `, { code: ` - ` - }, + `, { code: ` `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, errors: [ { line: 4, column: 9, message: 'The "a" property should have a JSDoc comment.' } - ], - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } + ] } ] }) diff --git a/tests/lib/rules/require-prop-type-constructor.js b/tests/lib/rules/require-prop-type-constructor.js index 9cd4eae6e..a4d6766df 100644 --- a/tests/lib/rules/require-prop-type-constructor.js +++ b/tests/lib/rules/require-prop-type-constructor.js @@ -224,13 +224,13 @@ ruleTester.run('require-prop-type-constructor', rule, { } } `, + parser: require.resolve('@typescript-eslint/parser'), errors: [ { message: 'The "a" property should be a constructor.', line: 5 } - ], - parser: require.resolve('@typescript-eslint/parser') + ] }, { filename: 'ExtraCommas.vue', @@ -248,13 +248,13 @@ ruleTester.run('require-prop-type-constructor', rule, { } } `, + parser: require.resolve('@typescript-eslint/parser'), errors: [ { message: 'The "name" property should be a constructor.', line: 4 } - ], - parser: require.resolve('@typescript-eslint/parser') + ] }, { filename: 'LiteralsComponent.vue', diff --git a/tests/lib/rules/require-prop-types.js b/tests/lib/rules/require-prop-types.js index 9b7077fc1..fdb91dd30 100644 --- a/tests/lib/rules/require-prop-types.js +++ b/tests/lib/rules/require-prop-types.js @@ -137,8 +137,8 @@ ruleTester.run('require-prop-types', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', @@ -151,8 +151,8 @@ ruleTester.run('require-prop-types', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', @@ -163,8 +163,8 @@ ruleTester.run('require-prop-types', rule, { }) `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', @@ -173,12 +173,12 @@ ruleTester.run('require-prop-types', rule, { defineProps<{foo:string}>() `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } }, { code: ` @@ -308,8 +308,8 @@ ruleTester.run('require-prop-types', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', @@ -326,8 +326,8 @@ ruleTester.run('require-prop-types', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', @@ -344,8 +344,8 @@ ruleTester.run('require-prop-types', rule, { }) `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', @@ -360,8 +360,8 @@ ruleTester.run('require-prop-types', rule, { defineProps(['foo']) `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', diff --git a/tests/lib/rules/require-typed-object-prop.js b/tests/lib/rules/require-typed-object-prop.js index 5d93965a5..f574e82d8 100644 --- a/tests/lib/rules/require-typed-object-prop.js +++ b/tests/lib/rules/require-typed-object-prop.js @@ -14,235 +14,235 @@ ruleTester.run('require-typed-object-prop', rule, { // empty { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default { props: {} } - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default Vue.extend({ props: {} }); - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` `, - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, // array props { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default { props: ['foo'] } - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default Vue.extend({ props: ['foo'] }); - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` `, - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, // primitive props { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default { props: { foo: String } } - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default Vue.extend({ props: { foo: String } }); - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` `, - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, // union { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default { props: { foo: [Number, String, Boolean] } } - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default Vue.extend({ props: { foo: [Number, String, Boolean] } }); - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` `, - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, // function { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default { props: { foo: someFunction() } } - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default Vue.extend({ props: { foo: someFunction() } }); - ` + `, + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` `, - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, // typed object { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default { props: { foo: Object as PropType } } `, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default { props: { foo: Array as PropType } } `, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, code: ` export default Vue.extend({ props: { foo: Object as PropType } }); `, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', - parserOptions: { - ecmaVersion: 6, - sourceType: 'module', - parser: require.resolve('@typescript-eslint/parser') - }, code: ` `, - parser: require.resolve('vue-eslint-parser') - }, - - { - filename: 'test.vue', + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, + } + }, + + { + filename: 'test.vue', code: ` export default { props: { foo: Object as () => User } } `, - parser: require.resolve('@typescript-eslint/parser') - }, - { - filename: 'test.vue', + parser: require.resolve('@typescript-eslint/parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, + } + }, + { + filename: 'test.vue', code: ` export default Vue.extend({ props: { foo: Object as () => User } }); `, - parser: require.resolve('@typescript-eslint/parser') - }, - { - filename: 'test.vue', + parser: require.resolve('@typescript-eslint/parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, + } + }, + { + filename: 'test.vue', code: ` `, - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + parser: require.resolve('@typescript-eslint/parser') + } }, // any { @@ -252,12 +252,12 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: { type: Object as any } }); `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } }, { filename: 'test.vue', @@ -270,12 +270,12 @@ ruleTester.run('require-typed-object-prop', rule, { }; `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } }, { filename: 'test.vue', @@ -288,12 +288,12 @@ ruleTester.run('require-typed-object-prop', rule, { }); `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } }, // unknown { @@ -303,12 +303,12 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: { type: Object as unknown } }); `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } }, { filename: 'test.vue', @@ -321,12 +321,12 @@ ruleTester.run('require-typed-object-prop', rule, { }; `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } }, { filename: 'test.vue', @@ -339,12 +339,12 @@ ruleTester.run('require-typed-object-prop', rule, { }); `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } } ], invalid: [ @@ -355,8 +355,8 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: Object }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -394,8 +394,8 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: Array }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -585,8 +585,8 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: { type: Object } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'expectedTypeAnnotation', diff --git a/tests/lib/rules/require-typed-ref.js b/tests/lib/rules/require-typed-ref.js index 571b5c5de..3da293b9a 100644 --- a/tests/lib/rules/require-typed-ref.js +++ b/tests/lib/rules/require-typed-ref.js @@ -75,13 +75,13 @@ tester.run('require-typed-ref', rule, { }, { filename: 'test.vue', - parser: require.resolve('vue-eslint-parser'), code: ` - ` + `, + parser: require.resolve('vue-eslint-parser') }, { filename: 'test.js', @@ -197,13 +197,13 @@ tester.run('require-typed-ref', rule, { }, { filename: 'test.vue', - parser: require.resolve('vue-eslint-parser'), code: ` `, + parser: require.resolve('vue-eslint-parser'), errors: [ { messageId: 'noType', diff --git a/tests/lib/rules/require-valid-default-prop.js b/tests/lib/rules/require-valid-default-prop.js index cec05ba05..1e6f7cd7a 100644 --- a/tests/lib/rules/require-valid-default-prop.js +++ b/tests/lib/rules/require-valid-default-prop.js @@ -122,8 +122,8 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' } }, { filename: 'test.vue', @@ -214,8 +214,8 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: errorMessage('function') }, { @@ -229,8 +229,8 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: errorMessage('function') }, { @@ -244,8 +244,8 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: errorMessage('function') }, { @@ -264,12 +264,12 @@ ruleTester.run('require-valid-default-prop', rule, { num: 1 }); `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') - }, - parser: require.resolve('vue-eslint-parser') + } }, { code: ` @@ -614,8 +614,8 @@ ruleTester.run('require-valid-default-prop', rule, { } as PropOptions } });`, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: errorMessage('function or number') }, @@ -874,8 +874,8 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: errorMessage('function') }, { @@ -889,8 +889,8 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: errorMessage('function') }, { @@ -904,8 +904,8 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('@typescript-eslint/parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: errorMessage('function') }, { @@ -920,8 +920,8 @@ ruleTester.run('require-valid-default-prop', rule, { }) `, - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, parser: require.resolve('vue-eslint-parser'), + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: "Type of the default value for 'foo' prop must be a string.", @@ -938,12 +938,12 @@ ruleTester.run('require-valid-default-prop', rule, { }) `, + parser: require.resolve('vue-eslint-parser'), parserOptions: { ecmaVersion: 6, sourceType: 'module', parser: require.resolve('@typescript-eslint/parser') }, - parser: require.resolve('vue-eslint-parser'), errors: [ { message: "Type of the default value for 'foo' prop must be a string.", @@ -967,7 +967,6 @@ ruleTester.run('require-valid-default-prop', rule, { i: ['foo', 'bar'], }) `, - ...getTypeScriptFixtureTestOptions(), errors: [ { message: "Type of the default value for 'a' prop must be a string.", @@ -1006,7 +1005,8 @@ ruleTester.run('require-valid-default-prop', rule, { message: "Type of the default value for 'i' prop must be a function.", line: 13 } - ] + ], + ...getTypeScriptFixtureTestOptions() } ] }) diff --git a/tests/lib/rules/return-in-computed-property.js b/tests/lib/rules/return-in-computed-property.js index 9fbe2c84e..71afcc3eb 100644 --- a/tests/lib/rules/return-in-computed-property.js +++ b/tests/lib/rules/return-in-computed-property.js @@ -94,8 +94,8 @@ ruleTester.run('return-in-computed-property', rule, { } } `, - parserOptions, - options: [{ treatUndefinedAsUnspecified: false }] + options: [{ treatUndefinedAsUnspecified: false }], + parserOptions }, { filename: 'test.vue', @@ -144,8 +144,8 @@ ruleTester.run('return-in-computed-property', rule, { } } `, - parserOptions, - options: [{ treatUndefinedAsUnspecified: false }] + options: [{ treatUndefinedAsUnspecified: false }], + parserOptions } ], @@ -264,8 +264,8 @@ ruleTester.run('return-in-computed-property', rule, { } } `, - parserOptions, options: [{ treatUndefinedAsUnspecified: false }], + parserOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', @@ -284,8 +284,8 @@ ruleTester.run('return-in-computed-property', rule, { } } `, - parserOptions, options: [{ treatUndefinedAsUnspecified: true }], + parserOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', @@ -378,8 +378,8 @@ ruleTester.run('return-in-computed-property', rule, { } } `, - parserOptions, options: [{ treatUndefinedAsUnspecified: false }], + parserOptions, errors: [ { message: 'Expected to return a value in computed function.', diff --git a/tests/lib/rules/singleline-html-element-content-newline.js b/tests/lib/rules/singleline-html-element-content-newline.js index a740ff0ed..5bf2c9392 100644 --- a/tests/lib/rules/singleline-html-element-content-newline.js +++ b/tests/lib/rules/singleline-html-element-content-newline.js @@ -372,7 +372,6 @@ content
singleline content
`, - options: [{ ignoreWhenNoAttributes: false }], output: ` `, + options: [{ ignoreWhenNoAttributes: false }], errors: [ 'Expected 1 line break after opening tag (`
`), but no line breaks found.', 'Expected 1 line break before closing tag (`
`), but no line breaks found.' @@ -391,7 +391,6 @@ singleline content singlelinechildren `, - options: [{ ignoreWhenNoAttributes: false }], output: ` `, + options: [{ ignoreWhenNoAttributes: false }], errors: [ 'Expected 1 line break after opening tag (``), but no line breaks found.', 'Expected 1 line break after opening tag (``), but no line breaks found.', @@ -418,7 +418,6 @@ children
`, - options: [{ ignoreWhenNoAttributes: false }], output: ` `, + options: [{ ignoreWhenNoAttributes: false }], errors: [ 'Expected 1 line break after opening tag (`
`), but no line breaks found.', 'Expected 1 line break before closing tag (`
`), but no line breaks found.' @@ -437,7 +437,6 @@ children
singleline element
`, - options: [{ ignoreWhenNoAttributes: false }], output: ` `, + options: [{ ignoreWhenNoAttributes: false }], errors: [ 'Expected 1 line break after opening tag (`
`), but no line breaks found.', 'Expected 1 line break before closing tag (`
`), but no line breaks found.' @@ -456,13 +456,13 @@ singleline element
`, - options: [{ ignoreWhenEmpty: false, ignoreWhenNoAttributes: false }], output: ` `, + options: [{ ignoreWhenEmpty: false, ignoreWhenNoAttributes: false }], errors: [ 'Expected 1 line break after opening tag (`
`), but no line breaks found.' ] @@ -473,13 +473,13 @@ singleline element
`, - options: [{ ignoreWhenEmpty: false, ignoreWhenNoAttributes: false }], output: ` `, + options: [{ ignoreWhenEmpty: false, ignoreWhenNoAttributes: false }], errors: [ 'Expected 1 line break after opening tag (`
`), but no line breaks found.' ] diff --git a/tests/lib/rules/space-in-parens.js b/tests/lib/rules/space-in-parens.js index 8791652ed..ef6fe628e 100644 --- a/tests/lib/rules/space-in-parens.js +++ b/tests/lib/rules/space-in-parens.js @@ -94,13 +94,13 @@ tester.run('space-in-parens', rule, { @click="foo(arg)" /> `, - options: ['always'], output: ` `, + options: ['always'], errors: [ errorMessage({ messageId: 'missingOpeningSpace', @@ -143,13 +143,13 @@ tester.run('space-in-parens', rule, { :value="(1 + 2) + 3" > `, - options: ['always'], output: ` `, + options: ['always'], errors: [ errorMessage({ messageId: 'missingOpeningSpace', @@ -192,13 +192,13 @@ tester.run('space-in-parens', rule, { :[(1+2)]="(1 + 2) + 3" > `, - options: ['always'], output: ` `, + options: ['always'], errors: [ errorMessage({ messageId: 'missingOpeningSpace', diff --git a/tests/lib/rules/space-unary-ops.js b/tests/lib/rules/space-unary-ops.js index 6b3e7c25f..63539a5a7 100644 --- a/tests/lib/rules/space-unary-ops.js +++ b/tests/lib/rules/space-unary-ops.js @@ -50,8 +50,8 @@ tester.run('space-unary-ops', rule, { }, { code: '', - options: [{ nonwords: true }], output: '', + options: [{ nonwords: true }], errors: ["Unary operator '!' must be followed by whitespace."] }, diff --git a/tests/lib/rules/template-curly-spacing.js b/tests/lib/rules/template-curly-spacing.js index 6c4376969..0fe530511 100644 --- a/tests/lib/rules/template-curly-spacing.js +++ b/tests/lib/rules/template-curly-spacing.js @@ -41,14 +41,13 @@ tester.run('template-curly-spacing', rule, { }, // CSS vars injection - { - code: ` + ` ` - } + + ` ], invalid: [ { @@ -79,12 +78,12 @@ tester.run('template-curly-spacing', rule, {
`, - options: ['always'], output: ` `, + options: ['always'], errors: [ { message: "Expected space(s) after '${'.", diff --git a/tests/lib/rules/this-in-template.js b/tests/lib/rules/this-in-template.js index 904aa00c4..5686bf137 100644 --- a/tests/lib/rules/this-in-template.js +++ b/tests/lib/rules/this-in-template.js @@ -248,14 +248,14 @@ ruleTester.run('this-in-template', rule, { { code: ``, output: ``, - errors: ["Unexpected usage of 'this'."], - options: ['never'] + options: ['never'], + errors: ["Unexpected usage of 'this'."] }, { code: ``, output: ``, - errors: ["Unexpected usage of 'this'."], - options: ['never'] + options: ['never'], + errors: ["Unexpected usage of 'this'."] } ] }) diff --git a/tests/lib/rules/use-v-on-exact.js b/tests/lib/rules/use-v-on-exact.js index 73ac2408b..929fd746a 100644 --- a/tests/lib/rules/use-v-on-exact.js +++ b/tests/lib/rules/use-v-on-exact.js @@ -15,92 +15,48 @@ const ruleTester = new RuleTester({ ruleTester.run('use-v-on-exact', rule, { valid: [ - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: `` - }, - { - code: ` + ` ], invalid: [ diff --git a/tests/lib/rules/v-bind-style.js b/tests/lib/rules/v-bind-style.js index 2fd1ce7c2..0cb67f62f 100644 --- a/tests/lib/rules/v-bind-style.js +++ b/tests/lib/rules/v-bind-style.js @@ -67,44 +67,44 @@ tester.run('v-bind-style', rule, { }, { filename: 'test.vue', - options: ['shorthand'], code: '', output: '', + options: ['shorthand'], errors: ["Unexpected 'v-bind' before ':'."] }, { filename: 'test.vue', - options: ['longform'], code: '', output: '', + options: ['longform'], errors: ["Expected 'v-bind' before ':'."] }, { filename: 'test.vue', - options: ['longform'], code: '', output: '', + options: ['longform'], errors: ["Expected 'v-bind:' instead of '.'."] }, { filename: 'test.vue', - options: ['longform'], code: '', output: '', + options: ['longform'], errors: ["Expected 'v-bind:' instead of '.'."] }, { filename: 'test.vue', - options: ['longform'], code: '', output: '', + options: ['longform'], errors: ["Expected 'v-bind:' instead of '.'."] }, { filename: 'test.vue', - options: ['longform'], code: '', output: '', + options: ['longform'], errors: ["Expected 'v-bind:' instead of '.'."] } ] diff --git a/tests/lib/rules/v-for-delimiter-style.js b/tests/lib/rules/v-for-delimiter-style.js index b1500af50..23665a32c 100644 --- a/tests/lib/rules/v-for-delimiter-style.js +++ b/tests/lib/rules/v-for-delimiter-style.js @@ -94,9 +94,9 @@ tester.run('v-for-delimiter-style', rule, { }, { filename: 'test.vue', - options: ['in'], code: '', output: '', + options: ['in'], errors: [ { message: "Expected 'in' instead of 'of' in 'v-for'.", @@ -106,9 +106,9 @@ tester.run('v-for-delimiter-style', rule, { }, { filename: 'test.vue', - options: ['of'], code: '', output: '', + options: ['of'], errors: [ { message: "Expected 'of' instead of 'in' in 'v-for'.", diff --git a/tests/lib/rules/v-on-event-hyphenation.js b/tests/lib/rules/v-on-event-hyphenation.js index 087e5d00a..beaa5e3fa 100644 --- a/tests/lib/rules/v-on-event-hyphenation.js +++ b/tests/lib/rules/v-on-event-hyphenation.js @@ -73,12 +73,12 @@ tester.run('v-on-event-hyphenation', rule, { `, - options: ['always', { autofix: true }], output: ` `, + options: ['always', { autofix: true }], errors: [ { message: "v-on event '@customEvent' must be hyphenated.", @@ -95,12 +95,12 @@ tester.run('v-on-event-hyphenation', rule, { `, - options: ['never', { autofix: true }], output: ` `, + options: ['never', { autofix: true }], errors: ["v-on event 'v-on:custom-event' can't be hyphenated."] }, { @@ -110,13 +110,13 @@ tester.run('v-on-event-hyphenation', rule, { `, - options: ['always', { autofix: true }], output: ` `, + options: ['always', { autofix: true }], errors: ["v-on event '@update:modelValue' must be hyphenated."] }, { @@ -126,13 +126,13 @@ tester.run('v-on-event-hyphenation', rule, { `, - options: ['never', { autofix: true }], output: ` `, + options: ['never', { autofix: true }], errors: ["v-on event '@update:model-value' can't be hyphenated."] }, { @@ -144,7 +144,6 @@ tester.run('v-on-event-hyphenation', rule, { `, - options: ['always', { autofix: true }], output: ` `, + options: ['always', { autofix: true }], errors: [ "v-on event '@upDate:modelValue' must be hyphenated.", "v-on event '@up-date:modelValue' must be hyphenated.", @@ -168,7 +168,6 @@ tester.run('v-on-event-hyphenation', rule, { `, - options: ['never', { autofix: true }], output: ` `, + options: ['never', { autofix: true }], errors: [ "v-on event '@up-date:modelValue' can't be hyphenated.", "v-on event '@upDate:model-value' can't be hyphenated.", diff --git a/tests/lib/rules/v-on-function-call.js b/tests/lib/rules/v-on-function-call.js index d8486a448..d06bbe231 100644 --- a/tests/lib/rules/v-on-function-call.js +++ b/tests/lib/rules/v-on-function-call.js @@ -161,37 +161,37 @@ tester.run('v-on-function-call', rule, { filename: 'test.vue', code: '', output: null, + options: ['always'], errors: [ "Method calls inside of 'v-on' directives must have parentheses." - ], - options: ['always'] + ] }, { filename: 'test.vue', code: '', output: ``, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', code: '', output: ``, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', code: '', output: null, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -204,13 +204,13 @@ tester.run('v-on-function-call', rule, { ">
`, output: null, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses.", "Method calls without arguments inside of 'v-on' directives must not have parentheses.", "Method calls without arguments inside of 'v-on' directives must not have parentheses.", "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -222,10 +222,10 @@ tester.run('v-on-function-call', rule, { `, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -237,10 +237,10 @@ tester.run('v-on-function-call', rule, { `, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -254,11 +254,11 @@ tester.run('v-on-function-call', rule, {
`, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses.", "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -270,10 +270,10 @@ tester.run('v-on-function-call', rule, { `, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -285,19 +285,19 @@ tester.run('v-on-function-call', rule, { `, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', code: '', output: '', + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -319,10 +319,10 @@ tester.run('v-on-function-call', rule, { } } `, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] }, { filename: 'test.vue', @@ -344,10 +344,10 @@ tester.run('v-on-function-call', rule, { } } `, + options: ['never'], errors: [ "Method calls without arguments inside of 'v-on' directives must not have parentheses." - ], - options: ['never'] + ] } ] }) diff --git a/tests/lib/rules/v-on-handler-style.js b/tests/lib/rules/v-on-handler-style.js index e3afd05d5..314bbf8c8 100644 --- a/tests/lib/rules/v-on-handler-style.js +++ b/tests/lib/rules/v-on-handler-style.js @@ -78,12 +78,12 @@ tester.run('v-on-handler-style', rule, {