diff --git a/eslint.config.js b/eslint.config.js index d6ab046ba..deff4615d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,15 +1,12 @@ 'use strict' const globals = require('globals') -const { FlatCompat } = require('@eslint/eslintrc') const eslintPluginEslintPlugin = require('eslint-plugin-eslint-plugin/configs/all') +const eslintPluginJsonc = require('eslint-plugin-jsonc') +const eslintPluginNodeDependencies = require('eslint-plugin-node-dependencies') const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended') const eslintPluginUnicorn = require('eslint-plugin-unicorn') -const eslintrc = new FlatCompat({ - baseDirectory: __dirname -}) - module.exports = [ { ignores: [ @@ -30,10 +27,8 @@ module.exports = [ }, eslintPluginEslintPlugin, eslintPluginUnicorn.configs['flat/recommended'], - ...eslintrc.extends( - 'plugin:node-dependencies/recommended', - 'plugin:jsonc/recommended-with-jsonc' - ), + ...eslintPluginNodeDependencies.configs['flat/recommended'], + ...eslintPluginJsonc.configs['flat/recommended-with-jsonc'], eslintPluginPrettierRecommended, { plugins: { @@ -144,6 +139,7 @@ module.exports = [ 'prefer-const': 2, 'prettier/prettier': 'error', + 'eslint-plugin/require-meta-docs-recommended': 'off', // use `categories` instead 'eslint-plugin/require-meta-fixable': [ 'error', { catchNoFixerButFixableProperty: true } diff --git a/lib/rules/attribute-hyphenation.js b/lib/rules/attribute-hyphenation.js index 3de0af1b5..0ef2a0420 100644 --- a/lib/rules/attribute-hyphenation.js +++ b/lib/rules/attribute-hyphenation.js @@ -51,7 +51,7 @@ module.exports = { allOf: [ { type: 'string' }, { not: { type: 'string', pattern: ':exit$' } }, - { not: { type: 'string', pattern: '^\\s*$' } } + { not: { type: 'string', pattern: String.raw`^\s*$` } } ] }, uniqueItems: true, diff --git a/lib/rules/html-indent.js b/lib/rules/html-indent.js index 96a8a4456..ed2bf1a62 100644 --- a/lib/rules/html-indent.js +++ b/lib/rules/html-indent.js @@ -62,7 +62,7 @@ module.exports = { allOf: [ { type: 'string' }, { not: { type: 'string', pattern: ':exit$' } }, - { not: { type: 'string', pattern: '^\\s*$' } } + { not: { type: 'string', pattern: String.raw`^\s*$` } } ] }, uniqueItems: true, diff --git a/lib/rules/no-invalid-model-keys.js b/lib/rules/no-invalid-model-keys.js index 11f4ab218..aa1390f2d 100644 --- a/lib/rules/no-invalid-model-keys.js +++ b/lib/rules/no-invalid-model-keys.js @@ -13,9 +13,9 @@ module.exports = { categories: undefined, url: 'https://eslint.vuejs.org/rules/no-invalid-model-keys.html' }, - schema: [], deprecated: true, - replacedBy: ['valid-model-definition'] + replacedBy: ['valid-model-definition'], + schema: [] }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/rules/no-restricted-custom-event.js b/lib/rules/no-restricted-custom-event.js index 98a87d807..5ddda037f 100644 --- a/lib/rules/no-restricted-custom-event.js +++ b/lib/rules/no-restricted-custom-event.js @@ -155,7 +155,7 @@ module.exports = { sourceCode.text[nameWithLoc.range[0]] }${JSON.stringify(option.suggest) .slice(1, -1) - .replace(/'/gu, "\\'")}${ + .replace(/'/gu, String.raw`\'`)}${ sourceCode.text[nameWithLoc.range[1] - 1] }` ) diff --git a/lib/rules/no-undef-properties.js b/lib/rules/no-undef-properties.js index 06eda247c..29fbb714b 100644 --- a/lib/rules/no-undef-properties.js +++ b/lib/rules/no-undef-properties.js @@ -106,9 +106,9 @@ module.exports = { /** @param {RuleContext} context */ create(context) { const options = context.options[0] || {} - const ignores = /** @type {string[]} */ (options.ignores || ['/^\\$/']).map( - toRegExp - ) + const ignores = /** @type {string[]} */ ( + options.ignores || [String.raw`/^\$/`] + ).map(toRegExp) const propertyReferenceExtractor = definePropertyReferenceExtractor(context) const programNode = context.getSourceCode().ast diff --git a/lib/rules/script-indent.js b/lib/rules/script-indent.js index c9d9d5e99..839b770ad 100644 --- a/lib/rules/script-indent.js +++ b/lib/rules/script-indent.js @@ -32,7 +32,7 @@ module.exports = { allOf: [ { type: 'string' }, { not: { type: 'string', pattern: ':exit$' } }, - { not: { type: 'string', pattern: '^\\s*$' } } + { not: { type: 'string', pattern: String.raw`^\s*$` } } ] }, uniqueItems: true, diff --git a/lib/rules/script-setup-uses-vars.js b/lib/rules/script-setup-uses-vars.js index a1d873a6b..836eb5e64 100644 --- a/lib/rules/script-setup-uses-vars.js +++ b/lib/rules/script-setup-uses-vars.js @@ -28,8 +28,8 @@ module.exports = { categories: undefined, url: 'https://eslint.vuejs.org/rules/script-setup-uses-vars.html' }, - schema: [], - deprecated: true + deprecated: true, + schema: [] }, /** * @param {RuleContext} context - The rule context. diff --git a/lib/rules/v-on-event-hyphenation.js b/lib/rules/v-on-event-hyphenation.js index 9ebe7554d..f99a45fdc 100644 --- a/lib/rules/v-on-event-hyphenation.js +++ b/lib/rules/v-on-event-hyphenation.js @@ -30,7 +30,7 @@ module.exports = { allOf: [ { type: 'string' }, { not: { type: 'string', pattern: ':exit$' } }, - { not: { type: 'string', pattern: '^\\s*$' } } + { not: { type: 'string', pattern: String.raw`^\s*$` } } ] }, uniqueItems: true, diff --git a/lib/rules/v-on-function-call.js b/lib/rules/v-on-function-call.js index efd5b6fa1..1d075a348 100644 --- a/lib/rules/v-on-function-call.js +++ b/lib/rules/v-on-function-call.js @@ -71,6 +71,8 @@ module.exports = { url: 'https://eslint.vuejs.org/rules/v-on-function-call.html' }, fixable: 'code', + deprecated: true, + replacedBy: ['v-on-handler-style'], schema: [ { enum: ['always', 'never'] }, { @@ -87,9 +89,7 @@ module.exports = { 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'] + } }, /** @param {RuleContext} context */ create(context) { diff --git a/lib/utils/regexp.js b/lib/utils/regexp.js index f19d55a6e..3ee40ae41 100644 --- a/lib/utils/regexp.js +++ b/lib/utils/regexp.js @@ -12,7 +12,7 @@ const RE_REGEXP_STR = /^\/(.+)\/(.*)$/u */ function escape(string) { return string && RE_HAS_REGEXP_CHAR.test(string) - ? string.replace(RE_REGEXP_CHAR, '\\$&') + ? string.replace(RE_REGEXP_CHAR, String.raw`\$&`) : string } diff --git a/package.json b/package.json index 687db9cac..8cb321f20 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,8 @@ "xml-name-validator": "^4.0.0" }, "devDependencies": { - "@ota-meshi/site-kit-eslint-editor-vue": "^0.1.2", - "@stylistic/eslint-plugin": "^1.6.1", + "@ota-meshi/site-kit-eslint-editor-vue": "^0.2.0", + "@stylistic/eslint-plugin": "^2.2.2", "@types/eslint": "^8.56.2", "@types/eslint-visitor-keys": "^3.3.0", "@types/natural-compare": "^1.4.3", @@ -77,21 +77,21 @@ "@typescript-eslint/types": "^7.13.1", "assert": "^2.1.0", "env-cmd": "^10.1.0", - "esbuild": "^0.20.0", + "esbuild": "^0.21.5", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-eslint-plugin": "~5.3.0", + "eslint-plugin-eslint-plugin": "~6.1.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-jsonc": "^2.13.0", - "eslint-plugin-node-dependencies": "^0.11.2", + "eslint-plugin-node-dependencies": "^0.12.0", "eslint-plugin-prettier": "^5.1.3", - "eslint-plugin-unicorn": "^51.0.1", + "eslint-plugin-unicorn": "^54.0.0", "eslint-plugin-vue": "file:.", "espree": "^9.6.1", "events": "^3.3.0", - "markdownlint-cli": "^0.39.0", + "markdownlint-cli": "^0.41.0", "mocha": "^10.3.0", - "nyc": "^15.1.0", + "nyc": "^17.0.0", "prettier": "^3.2.5", "typescript": "^5.3.3", "vitepress": "^1.0.0-rc.42" diff --git a/tests/lib/rules/component-definition-name-casing.js b/tests/lib/rules/component-definition-name-casing.js index 97d1e2d9a..2acdfcb8b 100644 --- a/tests/lib/rules/component-definition-name-casing.js +++ b/tests/lib/rules/component-definition-name-casing.js @@ -187,14 +187,14 @@ ruleTester.run('component-definition-name-casing', rule, { name: 'FooBar' } `, + languageOptions, errors: [ { message: 'Property name "foo-bar" is not PascalCase.', type: 'Literal', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -204,14 +204,14 @@ ruleTester.run('component-definition-name-casing', rule, { } `, output: null, + languageOptions, errors: [ { message: 'Property name "foo bar" is not PascalCase.', type: 'Literal', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -221,14 +221,14 @@ ruleTester.run('component-definition-name-casing', rule, { } `, output: null, + languageOptions, errors: [ { message: 'Property name "foo!bar" is not PascalCase.', type: 'Literal', line: 3 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -238,14 +238,14 @@ ruleTester.run('component-definition-name-casing', rule, { }) `, output: null, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: 'Property name "foo!bar" is not PascalCase.', type: 'Literal', line: 3 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.vue', @@ -259,14 +259,14 @@ ruleTester.run('component-definition-name-casing', rule, { name: 'FooBar' } `, + languageOptions, errors: [ { message: 'Property name "foo_bar" is not PascalCase.', type: 'Literal', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -281,14 +281,14 @@ ruleTester.run('component-definition-name-casing', rule, { } `, options: ['PascalCase'], + languageOptions, errors: [ { message: 'Property name "foo_bar" is not PascalCase.', type: 'Literal', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -303,156 +303,156 @@ ruleTester.run('component-definition-name-casing', rule, { } `, options: ['kebab-case'], + languageOptions, errors: [ { message: 'Property name "foo_bar" is not kebab-case.', type: 'Literal', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', code: `Vue.component('foo-bar', component)`, output: `Vue.component('FooBar', component)`, + languageOptions, errors: [ { message: 'Property name "foo-bar" is not PascalCase.', type: 'Literal', line: 1 } - ], - languageOptions + ] }, { filename: 'test.vue', code: `app.component('foo-bar', component)`, output: `app.component('FooBar', component)`, + languageOptions, errors: [ { message: 'Property name "foo-bar" is not PascalCase.', type: 'Literal', line: 1 } - ], - languageOptions + ] }, { filename: 'test.vue', code: `(Vue as VueConstructor).component('foo-bar', component)`, output: `(Vue as VueConstructor).component('FooBar', component)`, + languageOptions: { + parser: require('@typescript-eslint/parser'), + ...languageOptions + }, errors: [ { message: 'Property name "foo-bar" is not PascalCase.', type: 'Literal', line: 1 } - ], - languageOptions: { - parser: require('@typescript-eslint/parser'), - ...languageOptions - } + ] }, { filename: 'test.vue', code: `Vue.component('foo-bar', {})`, output: `Vue.component('FooBar', {})`, + languageOptions, errors: [ { message: 'Property name "foo-bar" is not PascalCase.', type: 'Literal', line: 1 } - ], - languageOptions + ] }, { filename: 'test.vue', code: `app.component('foo-bar', {})`, output: `app.component('FooBar', {})`, + languageOptions, errors: [ { message: 'Property name "foo-bar" is not PascalCase.', type: 'Literal', line: 1 } - ], - languageOptions + ] }, { filename: 'test.js', code: `Vue.component('foo_bar', {})`, output: `Vue.component('FooBar', {})`, options: ['PascalCase'], + languageOptions, errors: [ { message: 'Property name "foo_bar" is not PascalCase.', type: 'Literal', line: 1 } - ], - languageOptions + ] }, { filename: 'test.vue', code: `Vue.component('foo_bar', {})`, output: `Vue.component('foo-bar', {})`, options: ['kebab-case'], + languageOptions, errors: [ { message: 'Property name "foo_bar" is not kebab-case.', type: 'Literal', line: 1 } - ], - languageOptions + ] }, { filename: 'test.vue', code: `Vue.component(\`foo_bar\`, {})`, output: `Vue.component(\`foo-bar\`, {})`, options: ['kebab-case'], + languageOptions, errors: [ { message: 'Property name "foo_bar" is not kebab-case.', type: 'TemplateLiteral', line: 1 } - ], - languageOptions + ] }, { filename: 'test.vue', code: ``, output: ``, options: ['PascalCase'], + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: 'Property name "foo-bar" is not PascalCase.', line: 1 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] }, { filename: 'test.vue', code: ``, output: ``, options: ['kebab-case'], + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: 'Property name "FooBar" is not kebab-case.', line: 1 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] } ] }) diff --git a/tests/lib/rules/define-emits-declaration.js b/tests/lib/rules/define-emits-declaration.js index 6493765af..4e65783c2 100644 --- a/tests/lib/rules/define-emits-declaration.js +++ b/tests/lib/rules/define-emits-declaration.js @@ -176,17 +176,17 @@ tester.run('define-emits-declaration', rule, { `, options: ['type-literal'], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Use type based declaration instead of runtime declaration.', line: 3 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -199,17 +199,17 @@ tester.run('define-emits-declaration', rule, { `, options: ['runtime'], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Use runtime declaration instead of type based declaration.', line: 3 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -222,6 +222,11 @@ tester.run('define-emits-declaration', rule, { `, options: ['type-literal'], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: @@ -233,12 +238,7 @@ tester.run('define-emits-declaration', rule, { 'Use new type literal declaration instead of the old call signature declaration.', line: 5 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -251,18 +251,18 @@ tester.run('define-emits-declaration', rule, { `, options: ['type-literal'], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Use new type literal declaration instead of the old call signature declaration.', line: 5 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -272,18 +272,18 @@ tester.run('define-emits-declaration', rule, { `, options: ['type-literal'], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Use new type literal declaration instead of the old call signature declaration.', line: 3 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] } ] }) diff --git a/tests/lib/rules/define-macros-order.js b/tests/lib/rules/define-macros-order.js index bdae34e6a..3aa2e434d 100644 --- a/tests/lib/rules/define-macros-order.js +++ b/tests/lib/rules/define-macros-order.js @@ -413,17 +413,17 @@ tester.run('define-macros-order', rule, { `, options: optionsEmitsFirst, + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: message('defineEmits'), line: 12 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -451,17 +451,17 @@ tester.run('define-macros-order', rule, { interface SomeOtherInterface {}; `, + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: message('defineProps'), line: 10 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -506,17 +506,17 @@ tester.run('define-macros-order', rule, { `, options: optionsEmitsFirst, + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: message('defineEmits'), line: 16 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/define-props-declaration.js b/tests/lib/rules/define-props-declaration.js index 3af4513ea..d6785b93c 100644 --- a/tests/lib/rules/define-props-declaration.js +++ b/tests/lib/rules/define-props-declaration.js @@ -151,17 +151,17 @@ tester.run('define-props-declaration', rule, { `, options: ['runtime'], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Use runtime declaration instead of type-based declaration.', line: 3 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] } ] }) diff --git a/tests/lib/rules/html-comment-indent.js b/tests/lib/rules/html-comment-indent.js index 6abe16a6c..27c93af8e 100644 --- a/tests/lib/rules/html-comment-indent.js +++ b/tests/lib/rules/html-comment-indent.js @@ -246,8 +246,7 @@ tester.run('html-comment-indent', rule, { endColumn: 11 }, { - message: - 'Expected base point indentation of 10 spaces, but found " \\t".', + message: String.raw`Expected base point indentation of 10 spaces, but found " \t".`, line: 7, column: 1, endLine: 7, @@ -452,8 +451,7 @@ tester.run('html-comment-indent', rule, { endColumn: 14 }, { - message: - 'Expected base point indentation of 12 spaces, but found " \\t".', + message: String.raw`Expected base point indentation of 12 spaces, but found " \t".`, line: 12, column: 1, endLine: 12, @@ -671,13 +669,11 @@ comment --> `, errors: [ { - message: - 'Expected base point indentation of " \\t \\t \\t ", but found 7 spaces.', + message: String.raw`Expected base point indentation of " \t \t \t ", but found 7 spaces.`, line: 4 }, { - message: - 'Expected base point indentation of " \\t \\t \\t ", but found 7 spaces.', + message: String.raw`Expected base point indentation of " \t \t \t ", but found 7 spaces.`, line: 5 } ] diff --git a/tests/lib/rules/html-indent.js b/tests/lib/rules/html-indent.js index b8763dfb2..3a4c610cd 100644 --- a/tests/lib/rules/html-indent.js +++ b/tests/lib/rules/html-indent.js @@ -471,7 +471,7 @@ tester.run( `, errors: [ { - message: 'Expected " " character, but found "\\t" character.', + message: String.raw`Expected " " character, but found "\t" character.`, line: 3 } ] @@ -495,7 +495,7 @@ tester.run( options: ['tab'], errors: [ { - message: 'Expected "\\t" character, but found " " character.', + message: String.raw`Expected "\t" character, but found " " character.`, line: 3 } ] @@ -931,7 +931,7 @@ tester.run( options: ['tab', { ignores: ['VAttribute'] }], errors: [ { - message: 'Expected "\\t" character, but found " " character.', + message: String.raw`Expected "\t" character, but found " " character.`, line: 2 } ] diff --git a/tests/lib/rules/match-component-file-name.js b/tests/lib/rules/match-component-file-name.js index f66a3c2c5..a006d2f3c 100644 --- a/tests/lib/rules/match-component-file-name.js +++ b/tests/lib/rules/match-component-file-name.js @@ -581,6 +581,7 @@ ruleTester.run('match-component-file-name', rule, { render() { return
} } `, + languageOptions: jsxLanguageOptions, errors: [ { message: @@ -597,8 +598,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: jsxLanguageOptions + ] }, { filename: 'MyComponent.jsx', @@ -609,6 +609,7 @@ ruleTester.run('match-component-file-name', rule, { } `, options: [{ extensions: ['jsx'] }], + languageOptions: jsxLanguageOptions, errors: [ { message: @@ -625,8 +626,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: jsxLanguageOptions + ] }, { filename: 'MyComponent.jsx', @@ -637,6 +637,7 @@ ruleTester.run('match-component-file-name', rule, { } `, options: [{ extensions: ['jsx'] }], + languageOptions: jsxLanguageOptions, errors: [ { message: @@ -653,8 +654,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: jsxLanguageOptions + ] }, { filename: 'MyComponent.jsx', @@ -665,6 +665,7 @@ ruleTester.run('match-component-file-name', rule, { } `, options: [{ extensions: ['jsx'] }], + languageOptions: jsxLanguageOptions, errors: [ { message: @@ -681,8 +682,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: jsxLanguageOptions + ] }, // .vue @@ -697,6 +697,10 @@ ruleTester.run('match-component-file-name', rule, { `, options: [{ extensions: ['vue'] }], + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: @@ -715,11 +719,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] }, { filename: 'MyComponent.vue', @@ -732,6 +732,10 @@ ruleTester.run('match-component-file-name', rule, { `, options: [{ extensions: ['vue'] }], + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: @@ -750,11 +754,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] }, { filename: 'MyComponent.vue', @@ -767,6 +767,10 @@ ruleTester.run('match-component-file-name', rule, { `, options: [{ extensions: ['vue'] }], + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: @@ -785,11 +789,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] }, // .js @@ -802,6 +802,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -818,8 +819,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -830,6 +830,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -846,8 +847,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -858,6 +858,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -874,8 +875,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -885,6 +885,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -900,8 +901,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -911,6 +911,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -926,8 +927,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -937,6 +937,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -952,8 +953,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -963,6 +963,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -978,8 +979,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -989,6 +989,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -1004,8 +1005,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -1015,6 +1015,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -1030,8 +1031,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, { filename: 'MyComponent.js', @@ -1041,6 +1041,7 @@ ruleTester.run('match-component-file-name', rule, { }) `, options: [{ extensions: ['js'] }], + languageOptions, errors: [ { message: @@ -1056,8 +1057,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions + ] }, // casing @@ -1070,6 +1070,7 @@ ruleTester.run('match-component-file-name', rule, { } `, options: [{ shouldMatchCase: true }], + languageOptions: jsxLanguageOptions, errors: [ { message: @@ -1086,8 +1087,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: jsxLanguageOptions + ] }, { filename: 'my-component.jsx', @@ -1098,6 +1098,7 @@ ruleTester.run('match-component-file-name', rule, { } `, options: [{ shouldMatchCase: true }], + languageOptions: jsxLanguageOptions, errors: [ { message: @@ -1114,13 +1115,16 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: jsxLanguageOptions + ] }, { filename: 'MyComponent.vue', code: ``, options: [{ extensions: ['vue'] }], + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: @@ -1132,11 +1136,7 @@ ruleTester.run('match-component-file-name', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] } ] }) diff --git a/tests/lib/rules/no-async-in-computed-properties.js b/tests/lib/rules/no-async-in-computed-properties.js index d3b1a3087..264430ec7 100644 --- a/tests/lib/rules/no-async-in-computed-properties.js +++ b/tests/lib/rules/no-async-in-computed-properties.js @@ -339,6 +339,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: @@ -349,8 +350,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected await operator in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -363,6 +363,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: @@ -373,8 +374,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected Promise object in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -387,13 +387,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -406,8 +406,8 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, - errors: ['Unexpected asynchronous action in "foo" computed property.'], - languageOptions + languageOptions, + errors: ['Unexpected asynchronous action in "foo" computed property.'] }, { filename: 'test.vue', @@ -420,8 +420,8 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, - errors: ['Unexpected asynchronous action in "foo" computed property.'], - languageOptions + languageOptions, + errors: ['Unexpected asynchronous action in "foo" computed property.'] }, { filename: 'test.vue', @@ -434,13 +434,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -453,13 +453,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -472,13 +472,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -491,13 +491,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -510,13 +510,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -529,13 +529,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -548,13 +548,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -569,13 +569,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 6 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -590,13 +590,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 6 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.vue', @@ -611,13 +611,13 @@ ruleTester.run('no-async-in-computed-properties', rule, { } }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', line: 6 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.vue', @@ -632,6 +632,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } }) `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in "foo" computed property.', @@ -641,8 +642,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected asynchronous action in "foo" computed property.', line: 6 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -657,6 +657,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } }) `, + languageOptions, errors: [ { message: @@ -679,8 +680,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected asynchronous action in "foo" computed property.', line: 6 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -700,6 +700,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected timed function in "foo" computed property.', @@ -733,8 +734,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected timed function in "foo" computed property.', line: 12 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -754,6 +754,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ 'Unexpected timed function in "foo" computed property.', 'Unexpected timed function in "foo" computed property.', @@ -763,8 +764,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { 'Unexpected timed function in "foo" computed property.', 'Unexpected timed function in "foo" computed property.', 'Unexpected timed function in "foo" computed property.' - ], - languageOptions + ] }, { filename: 'test.vue', @@ -784,6 +784,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ 'Unexpected timed function in "foo" computed property.', 'Unexpected timed function in "foo" computed property.', @@ -793,8 +794,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { 'Unexpected timed function in "foo" computed property.', 'Unexpected timed function in "foo" computed property.', 'Unexpected timed function in "foo" computed property.' - ], - languageOptions + ] }, { filename: 'test.vue', @@ -812,6 +812,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: @@ -840,8 +841,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected await operator in computed function.', line: 10 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -855,6 +855,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: @@ -865,8 +866,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected Promise object in computed function.', line: 6 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -883,6 +883,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in computed function.', @@ -892,8 +893,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected asynchronous action in computed function.', line: 9 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -914,6 +914,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected asynchronous action in computed function.', @@ -923,8 +924,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected asynchronous action in computed function.', line: 12 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -945,6 +945,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected timed function in computed function.', @@ -978,8 +979,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected timed function in computed function.', line: 13 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -993,14 +993,14 @@ ruleTester.run('no-async-in-computed-properties', rule, { } } `, + languageOptions, errors: [ { message: 'Unexpected async function declaration in computed function.', line: 5 } - ], - languageOptions + ] }, { @@ -1017,6 +1017,10 @@ ruleTester.run('no-async-in-computed-properties', rule, { }) `, + languageOptions: { + parser, + ...languageOptions + }, errors: [ { message: @@ -1045,11 +1049,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected await operator in computed function.', line: 9 } - ], - languageOptions: { - parser, - ...languageOptions - } + ] }, { filename: 'test.vue', @@ -1061,6 +1061,10 @@ ruleTester.run('no-async-in-computed-properties', rule, { }) `, + languageOptions: { + parser, + ...languageOptions + }, errors: [ { message: @@ -1071,11 +1075,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected Promise object in computed function.', line: 5 } - ], - languageOptions: { - parser, - ...languageOptions - } + ] }, { filename: 'test.vue', @@ -1090,6 +1090,10 @@ ruleTester.run('no-async-in-computed-properties', rule, { }) `, + languageOptions: { + parser, + ...languageOptions + }, errors: [ { message: 'Unexpected asynchronous action in computed function.', @@ -1099,11 +1103,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected asynchronous action in computed function.', line: 8 } - ], - languageOptions: { - parser, - ...languageOptions - } + ] }, { filename: 'test.vue', @@ -1122,6 +1122,10 @@ ruleTester.run('no-async-in-computed-properties', rule, { }) `, + languageOptions: { + parser, + ...languageOptions + }, errors: [ { message: 'Unexpected asynchronous action in computed function.', @@ -1131,11 +1135,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected asynchronous action in computed function.', line: 11 } - ], - languageOptions: { - parser, - ...languageOptions - } + ] }, { filename: 'test.vue', @@ -1154,6 +1154,10 @@ ruleTester.run('no-async-in-computed-properties', rule, { }) `, + languageOptions: { + parser, + ...languageOptions + }, errors: [ { message: 'Unexpected timed function in computed function.', @@ -1187,11 +1191,7 @@ ruleTester.run('no-async-in-computed-properties', rule, { message: 'Unexpected timed function in computed function.', line: 12 } - ], - languageOptions: { - parser, - ...languageOptions - } + ] }, { filename: 'test.vue', @@ -1203,17 +1203,17 @@ ruleTester.run('no-async-in-computed-properties', rule, { }) `, + languageOptions: { + parser, + ...languageOptions + }, errors: [ { message: 'Unexpected async function declaration in computed function.', line: 4 } - ], - languageOptions: { - parser, - ...languageOptions - } + ] } ] }) diff --git a/tests/lib/rules/no-boolean-default.js b/tests/lib/rules/no-boolean-default.js index c1f1a1784..6f275c671 100644 --- a/tests/lib/rules/no-boolean-default.js +++ b/tests/lib/rules/no-boolean-default.js @@ -424,14 +424,14 @@ ruleTester.run('no-boolean-default', rule, { }) `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: 'Boolean prop should not set a default (Vue defaults it to false).', line: 6 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, { filename: 'test.vue', @@ -446,13 +446,13 @@ ruleTester.run('no-boolean-default', rule, { `, options: ['default-false'], + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: 'Boolean prop should only be defaulted to false.', line: 6 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, ...(semver.lt( require('@typescript-eslint/parser/package.json').version, diff --git a/tests/lib/rules/no-deprecated-data-object-declaration.js b/tests/lib/rules/no-deprecated-data-object-declaration.js index 1c2007aab..648e1de24 100644 --- a/tests/lib/rules/no-deprecated-data-object-declaration.js +++ b/tests/lib/rules/no-deprecated-data-object-declaration.js @@ -150,14 +150,14 @@ return { } }) `, + languageOptions, errors: [ { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", line: 4 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -177,14 +177,14 @@ return { } }) `, + languageOptions, errors: [ { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -204,14 +204,14 @@ return { } } `, + languageOptions, errors: [ { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -231,14 +231,14 @@ return (/*b*/{ } } `, + languageOptions, errors: [ { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", line: 3 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -258,14 +258,14 @@ return { } }) `, + languageOptions, errors: [ { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", line: 3 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -285,14 +285,14 @@ return { } }).mount('#app') `, + languageOptions, errors: [ { message: "Object declaration on 'data' property is deprecated. Using function declaration instead.", line: 3 } - ], - languageOptions + ] } ] }) diff --git a/tests/lib/rules/no-deprecated-events-api.js b/tests/lib/rules/no-deprecated-events-api.js index 4b4fd288f..c78577d4b 100644 --- a/tests/lib/rules/no-deprecated-events-api.js +++ b/tests/lib/rules/no-deprecated-events-api.js @@ -134,14 +134,14 @@ ruleTester.run('no-deprecated-events-api', rule, { } }) `, + languageOptions, errors: [ { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', line: 4 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -152,14 +152,14 @@ ruleTester.run('no-deprecated-events-api', rule, { } }) `, + languageOptions, errors: [ { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -172,14 +172,14 @@ ruleTester.run('no-deprecated-events-api', rule, { } } `, + languageOptions, errors: [ { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', line: 4 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -193,14 +193,14 @@ ruleTester.run('no-deprecated-events-api', rule, { } }) `, + languageOptions, errors: [ { message: 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -213,12 +213,12 @@ ruleTester.run('no-deprecated-events-api', rule, { } }) `, + languageOptions, errors: [ 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.' - ], - languageOptions + ] }, { filename: 'test.js', @@ -231,12 +231,12 @@ ruleTester.run('no-deprecated-events-api', rule, { } }) `, + languageOptions, errors: [ 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.', 'The Events api `$on`, `$off` `$once` is deprecated. Using external library instead, for example mitt.' - ], - languageOptions + ] } ] }) diff --git a/tests/lib/rules/no-dupe-keys.js b/tests/lib/rules/no-dupe-keys.js index 2eae55863..124442ec2 100644 --- a/tests/lib/rules/no-dupe-keys.js +++ b/tests/lib/rules/no-dupe-keys.js @@ -1011,14 +1011,14 @@ ruleTester.run('no-dupe-keys', rule, { const foo = 0 `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: "Duplicate key 'foo'. May cause name collision in script or template tag.", line: 6 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, { filename: 'test.vue', @@ -1039,6 +1039,7 @@ ruleTester.run('no-dupe-keys', rule, { const bar = () => 'bar'; `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: @@ -1055,8 +1056,7 @@ ruleTester.run('no-dupe-keys', rule, { "Duplicate key 'bar'. May cause name collision in script or template tag.", line: 15 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, { filename: 'test.vue', @@ -1071,6 +1071,10 @@ ruleTester.run('no-dupe-keys', rule, { const bar = 'bar'; `, + languageOptions: { + parser: require('vue-eslint-parser'), + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: @@ -1082,11 +1086,7 @@ ruleTester.run('no-dupe-keys', rule, { "Duplicate key 'bar'. May cause name collision in script or template tag.", line: 9 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', @@ -1097,14 +1097,14 @@ ruleTester.run('no-dupe-keys', rule, { const bar = 42 `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: "Duplicate key 'bar'. May cause name collision in script or template tag.", line: 5 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] } ] }) diff --git a/tests/lib/rules/no-export-in-script-setup.js b/tests/lib/rules/no-export-in-script-setup.js index e6f2f1e19..8703dc74a 100644 --- a/tests/lib/rules/no-export-in-script-setup.js +++ b/tests/lib/rules/no-export-in-script-setup.js @@ -145,6 +145,12 @@ ruleTester.run('no-export-in-script-setup', rule, { export {} `, + languageOptions: { + parser: require('vue-eslint-parser'), + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: '` `, + languageOptions: { ecmaVersion: 2022 }, errors: [ { message: '`defineExpose` is forbidden after an `await` expression.', line: 4, column: 7 } - ], - languageOptions: { ecmaVersion: 2022 } + ] } ] }) diff --git a/tests/lib/rules/no-mutating-props.js b/tests/lib/rules/no-mutating-props.js index 1ecca1787..f47568a46 100644 --- a/tests/lib/rules/no-mutating-props.js +++ b/tests/lib/rules/no-mutating-props.js @@ -1031,17 +1031,17 @@ ruleTester.run('no-mutating-props', rule, { props.value++ `, + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Unexpected mutation of "value" prop.', line: 6 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/no-ref-as-operand.js b/tests/lib/rules/no-ref-as-operand.js index 62e29275c..d57356356 100644 --- a/tests/lib/rules/no-ref-as-operand.js +++ b/tests/lib/rules/no-ref-as-operand.js @@ -839,6 +839,11 @@ tester.run('no-ref-as-operand', rule, { console.log(count.value + 1) // error console.log(1 + count.value) // error `, + languageOptions: { + globals: { + ref: 'readonly' + } + }, errors: [ { message: @@ -864,12 +869,7 @@ tester.run('no-ref-as-operand', rule, { endLine: 6, endColumn: 28 } - ], - languageOptions: { - globals: { - ref: 'readonly' - } - } + ] } ] }) diff --git a/tests/lib/rules/no-ref-object-reactivity-loss.js b/tests/lib/rules/no-ref-object-reactivity-loss.js index c06e456bb..c026ba599 100644 --- a/tests/lib/rules/no-ref-object-reactivity-loss.js +++ b/tests/lib/rules/no-ref-object-reactivity-loss.js @@ -319,6 +319,7 @@ tester.run('no-ref-object-reactivity-loss', rule, { mod.value // OK ) `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: @@ -330,8 +331,7 @@ tester.run('no-ref-object-reactivity-loss', rule, { 'Getting a value from the ref object in the same scope will cause the value to lose reactivity.', line: 7 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, // Reactivity Transform { diff --git a/tests/lib/rules/no-required-prop-with-default.js b/tests/lib/rules/no-required-prop-with-default.js index 89319c0a8..7bdd9c611 100644 --- a/tests/lib/rules/no-required-prop-with-default.js +++ b/tests/lib/rules/no-required-prop-with-default.js @@ -223,17 +223,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "name" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -266,17 +266,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "name" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -309,17 +309,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "na::me" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -354,17 +354,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "name" should be optional.', line: 5 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -395,17 +395,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "name" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -438,17 +438,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "name" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -481,17 +481,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "na"me2" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -524,17 +524,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "foo" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -567,17 +567,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "name" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -610,17 +610,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "name" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -653,17 +653,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "a" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -696,17 +696,17 @@ tester.run('no-required-prop-with-default', rule, { `, options: [{ autofix: true }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Prop "a" should be optional.', line: 4 } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/no-reserved-keys.js b/tests/lib/rules/no-reserved-keys.js index ded4a9692..277c12c92 100644 --- a/tests/lib/rules/no-reserved-keys.js +++ b/tests/lib/rules/no-reserved-keys.js @@ -121,13 +121,13 @@ ruleTester.run('no-reserved-keys', rule, { } }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Key '$el' is reserved.", line: 4 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -140,13 +140,13 @@ ruleTester.run('no-reserved-keys', rule, { } }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Key '$el' is reserved.", line: 5 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -159,13 +159,13 @@ ruleTester.run('no-reserved-keys', rule, { } }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Key '$el' is reserved.", line: 5 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -176,13 +176,13 @@ ruleTester.run('no-reserved-keys', rule, { } }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Keys starting with '_' are reserved in '_foo' group.", line: 4 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -195,13 +195,13 @@ ruleTester.run('no-reserved-keys', rule, { } }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Keys starting with '_' are reserved in '_foo' group.", line: 5 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -212,13 +212,13 @@ ruleTester.run('no-reserved-keys', rule, { }) }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Keys starting with '_' are reserved in '_foo' group.", line: 4 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -229,13 +229,13 @@ ruleTester.run('no-reserved-keys', rule, { }) }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Keys starting with '_' are reserved in '_foo' group.", line: 4 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -247,13 +247,13 @@ ruleTester.run('no-reserved-keys', rule, { }) `, options: [{ reserved: ['bar'], groups: ['foo'] }], + languageOptions: { ecmaVersion: 6 }, errors: [ { message: "Key 'bar' is reserved.", line: 4 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.vue', @@ -264,13 +264,13 @@ ruleTester.run('no-reserved-keys', rule, { }) `, + languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 6 }, errors: [ { message: "Key '$el' is reserved.", line: 4 } - ], - languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 6 } + ] }, { filename: 'test.vue', @@ -279,19 +279,19 @@ ruleTester.run('no-reserved-keys', rule, { defineProps<{$el: string}>() `, - errors: [ - { - message: "Key '$el' is reserved.", - line: 3 - } - ], languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 6, parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + { + message: "Key '$el' is reserved.", + line: 3 + } + ] }, ...(semver.lt( require('@typescript-eslint/parser/package.json').version, diff --git a/tests/lib/rules/no-reserved-props.js b/tests/lib/rules/no-reserved-props.js index aa8252f0c..884708233 100644 --- a/tests/lib/rules/no-reserved-props.js +++ b/tests/lib/rules/no-reserved-props.js @@ -261,6 +261,12 @@ tester.run('no-reserved-props', rule, { defineProps() `, + languageOptions: { + parser: require('vue-eslint-parser'), + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: "'ref' is a reserved attribute and cannot be used as props.", @@ -272,13 +278,7 @@ tester.run('no-reserved-props', rule, { line: 5, column: 9 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/no-restricted-props.js b/tests/lib/rules/no-restricted-props.js index a50b22911..2dc1bcf64 100644 --- a/tests/lib/rules/no-restricted-props.js +++ b/tests/lib/rules/no-restricted-props.js @@ -390,6 +390,11 @@ tester.run('no-restricted-props', rule, { `, options: [{ name: 'foo', suggest: 'Foo' }], + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { message: 'Using `foo` props is not allowed.', @@ -407,12 +412,7 @@ tester.run('no-restricted-props', rule, { } ] } - ], - languageOptions: { - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, ...(semver.lt( require('@typescript-eslint/parser/package.json').version, diff --git a/tests/lib/rules/no-shared-component-data.js b/tests/lib/rules/no-shared-component-data.js index 50f433036..98e06728e 100644 --- a/tests/lib/rules/no-shared-component-data.js +++ b/tests/lib/rules/no-shared-component-data.js @@ -129,13 +129,13 @@ return { } }) `, + languageOptions, errors: [ { message: '`data` property in component must be a function.', line: 3 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -155,13 +155,13 @@ return { } }) `, + languageOptions, errors: [ { message: '`data` property in component must be a function.', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -181,13 +181,13 @@ return { } } `, + languageOptions, errors: [ { message: '`data` property in component must be a function.', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -207,13 +207,13 @@ return (/*b*/{ } } `, + languageOptions, errors: [ { message: '`data` property in component must be a function.', line: 3 } - ], - languageOptions + ] } ] }) 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 7ba6c0827..6cb6d6284 100644 --- a/tests/lib/rules/no-side-effects-in-computed-properties.js +++ b/tests/lib/rules/no-side-effects-in-computed-properties.js @@ -391,13 +391,13 @@ ruleTester.run('no-side-effects-in-computed-properties', rule, { } }); `, + languageOptions: { parser: require('@typescript-eslint/parser') }, errors: [ { line: 5, message: 'Unexpected side effect in "test1" computed property.' } - ], - languageOptions: { parser: require('@typescript-eslint/parser') } + ] }, { diff --git a/tests/lib/rules/no-undef-components.js b/tests/lib/rules/no-undef-components.js index 8b332ba42..e9992e39d 100644 --- a/tests/lib/rules/no-undef-components.js +++ b/tests/lib/rules/no-undef-components.js @@ -104,7 +104,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['custom(\\-\\w+)+'] + ignorePatterns: [String.raw`custom(\-\w+)+`] } ] }, @@ -170,7 +170,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['custom(\\-\\w+)+'] + ignorePatterns: [String.raw`custom(\-\w+)+`] } ] }, @@ -185,7 +185,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['custom(\\-\\w+)+'] + ignorePatterns: [String.raw`custom(\-\w+)+`] } ] }, @@ -200,7 +200,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['custom(\\-\\w+)+'] + ignorePatterns: [String.raw`custom(\-\w+)+`] } ] }, @@ -215,7 +215,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['Custom(\\w+)+'] + ignorePatterns: [String.raw`Custom(\w+)+`] } ] }, @@ -230,7 +230,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['Custom(\\w+)+'] + ignorePatterns: [String.raw`Custom(\w+)+`] } ] }, @@ -245,7 +245,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['Custom(\\w+)+'] + ignorePatterns: [String.raw`Custom(\w+)+`] } ] }, @@ -261,7 +261,11 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['Custom(\\w+)+', 'Warm(\\w+)+', 'InfoBtn(\\w+)+'] + ignorePatterns: [ + String.raw`Custom(\w+)+`, + String.raw`Warm(\w+)+`, + String.raw`InfoBtn(\w+)+` + ] } ] }, @@ -807,13 +811,6 @@ tester.run('no-undef-components', rule, { `, - errors: [ - { - message: - "The '' component has been used, but 'Foo' only refers to a type.", - line: 7 - } - ], languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 6, @@ -821,7 +818,14 @@ tester.run('no-undef-components', rule, { parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + { + message: + "The '' component has been used, but 'Foo' only refers to a type.", + line: 7 + } + ] }, // options API @@ -849,7 +853,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['custom(\\-\\w+)+'] + ignorePatterns: [String.raw`custom(\-\w+)+`] } ], errors: [ @@ -888,7 +892,7 @@ tester.run('no-undef-components', rule, { `, options: [ { - ignorePatterns: ['custom(\\-\\w+)+'] + ignorePatterns: [String.raw`custom(\-\w+)+`] } ], errors: [ diff --git a/tests/lib/rules/no-unused-emit-declarations.js b/tests/lib/rules/no-unused-emit-declarations.js index cccbcbb98..b4469150d 100644 --- a/tests/lib/rules/no-unused-emit-declarations.js +++ b/tests/lib/rules/no-unused-emit-declarations.js @@ -680,6 +680,9 @@ tester.run('no-unused-emit-declarations', rule, { }>() const change = () => emit('foo'); `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { messageId: 'unused', @@ -687,10 +690,7 @@ tester.run('no-unused-emit-declarations', rule, { column: 11, endColumn: 36 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', @@ -716,6 +716,9 @@ tester.run('no-unused-emit-declarations', rule, { defineEmits<{(e: 'foo'): void}>() `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { messageId: 'unused', @@ -723,10 +726,7 @@ tester.run('no-unused-emit-declarations', rule, { column: 22, endColumn: 38 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/order-in-components.js b/tests/lib/rules/order-in-components.js index 6ddba308d..2cbe721c5 100644 --- a/tests/lib/rules/order-in-components.js +++ b/tests/lib/rules/order-in-components.js @@ -225,14 +225,14 @@ ruleTester.run('order-in-components', rule, { }, } `, + languageOptions, errors: [ { message: 'The "props" property should be above the "data" property on line 4.', line: 9 } - ], - languageOptions + ] }, { filename: 'test.jsx', @@ -272,6 +272,13 @@ ruleTester.run('order-in-components', rule, { }, } `, + languageOptions: { + ecmaVersion: 6, + sourceType: 'module', + parserOptions: { + ecmaFeatures: { jsx: true } + } + }, errors: [ { message: @@ -288,14 +295,7 @@ ruleTester.run('order-in-components', rule, { 'The "props" property should be above the "data" property on line 9.', line: 14 } - ], - languageOptions: { - ecmaVersion: 6, - sourceType: 'module', - parserOptions: { - ecmaFeatures: { jsx: true } - } - } + ] }, { filename: 'test.js', @@ -323,14 +323,14 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: 'The "components" property should be above the "data" property on line 4.', line: 9 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -358,14 +358,14 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: 'The "components" property should be above the "data" property on line 4.', line: 9 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -395,14 +395,14 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: 'The "components" property should be above the "data" property on line 5.', line: 10 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -432,6 +432,7 @@ ruleTester.run('order-in-components', rule, { template: '
' }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -443,8 +444,7 @@ ruleTester.run('order-in-components', rule, { 'The "components" property should be above the "data" property on line 5.', line: 10 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'example.vue', @@ -484,14 +484,14 @@ ruleTester.run('order-in-components', rule, { }, }; `, + languageOptions, errors: [ { message: 'The "name" property should be above the "data" property on line 3.', line: 16 } - ], - languageOptions + ] }, { filename: 'example.vue', @@ -512,14 +512,14 @@ ruleTester.run('order-in-components', rule, { }; `, options: [{ order: ['data', 'test', 'name'] }], + languageOptions, errors: [ { message: 'The "test" property should be above the "name" property on line 5.', line: 6 } - ], - languageOptions + ] }, { filename: 'example.vue', @@ -541,14 +541,14 @@ ruleTester.run('order-in-components', rule, { } }; `, + languageOptions, errors: [ { message: 'The "name" property should be above the "data" property on line 4.', line: 7 } - ], - languageOptions + ] }, { filename: 'example.vue', @@ -570,27 +570,27 @@ ruleTester.run('order-in-components', rule, { }/*test*/ }; `, + languageOptions, errors: [ { message: 'The "name" property should be above the "data" property on line 4.', line: 7 } - ], - languageOptions + ] }, { filename: 'example.vue', code: `export default {data(){},name:'burger'};`, output: `export default {name:'burger',data(){}};`, + languageOptions, errors: [ { message: 'The "name" property should be above the "data" property on line 1.', line: 1 } - ], - languageOptions + ] }, { // side-effects CallExpression @@ -604,6 +604,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -623,8 +624,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects NewExpression @@ -638,6 +638,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -657,8 +658,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects UpdateExpression @@ -672,6 +672,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -691,8 +692,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects AssignmentExpression @@ -706,6 +706,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -725,8 +726,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects TaggedTemplateExpression @@ -740,6 +740,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -759,8 +760,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects key @@ -774,6 +774,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -793,8 +794,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects object deep props @@ -808,6 +808,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -827,8 +828,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects array elements @@ -842,6 +842,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -861,8 +862,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects call at middle @@ -876,6 +876,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -895,8 +896,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects delete @@ -910,6 +910,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -929,8 +930,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects within BinaryExpression @@ -944,6 +944,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -963,8 +964,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects within ConditionalExpression @@ -978,6 +978,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -997,8 +998,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects within TemplateLiteral @@ -1012,6 +1012,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -1031,8 +1032,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // side-effects https://github.com/vuejs/eslint-plugin-vue/issues/2418 @@ -1047,6 +1047,7 @@ ruleTester.run('order-in-components', rule, { }; `, output: null, + languageOptions, errors: [ { message: @@ -1067,8 +1068,7 @@ ruleTester.run('order-in-components', rule, { } ] } - ], - languageOptions + ] }, { // without side-effects @@ -1089,14 +1089,14 @@ ruleTester.run('order-in-components', rule, { test: fn(), }; `, + languageOptions, errors: [ { message: 'The "name" property should be above the "data" property on line 3.', line: 5 } - ], - languageOptions + ] }, { // don't side-effects @@ -1135,14 +1135,14 @@ ruleTester.run('order-in-components', rule, { testOptionalChaining: a?.b?.c, }; `, + languageOptions, errors: [ { message: 'The "name" property should be above the "data" property on line 3.', line: 15 } - ], - languageOptions + ] }, { filename: 'example.vue', @@ -1166,20 +1166,20 @@ ruleTester.run('order-in-components', rule, { }; `, - errors: [ - { - message: - 'The "props" property should be above the "setup" property on line 4.', - line: 5 - } - ], languageOptions: { parser: require('vue-eslint-parser'), ...languageOptions, parserOptions: { parser: { ts: require.resolve('@typescript-eslint/parser') } } - } + }, + errors: [ + { + message: + 'The "props" property should be above the "setup" property on line 4.', + line: 5 + } + ] }, { filename: 'example.vue', @@ -1199,14 +1199,14 @@ ruleTester.run('order-in-components', rule, { }) `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: 'The "name" property should be above the "inheritAttrs" property on line 4.', line: 5 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] } ] }) diff --git a/tests/lib/rules/prop-name-casing.js b/tests/lib/rules/prop-name-casing.js index 0ec845938..65748dc49 100644 --- a/tests/lib/rules/prop-name-casing.js +++ b/tests/lib/rules/prop-name-casing.js @@ -372,14 +372,14 @@ ruleTester.run('prop-name-casing', rule, { } } `, + languageOptions, errors: [ { message: 'Prop "greeting_text" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -391,14 +391,14 @@ ruleTester.run('prop-name-casing', rule, { } `, options: ['camelCase'], + languageOptions, errors: [ { message: 'Prop "greeting_text" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -408,14 +408,14 @@ ruleTester.run('prop-name-casing', rule, { } `, options: ['camelCase'], + languageOptions, errors: [ { message: 'Prop "greeting_text" is not in camelCase.', type: 'Literal', line: 3 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -427,14 +427,14 @@ ruleTester.run('prop-name-casing', rule, { } `, options: ['snake_case'], + languageOptions, errors: [ { message: 'Prop "greetingText" is not in snake_case.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -446,14 +446,14 @@ ruleTester.run('prop-name-casing', rule, { } `, options: ['camelCase'], + languageOptions, errors: [ { message: 'Prop "greeting-text" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -465,14 +465,14 @@ ruleTester.run('prop-name-casing', rule, { } `, options: ['snake_case'], + languageOptions, errors: [ { message: 'Prop "greeting-text" is not in snake_case.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -483,14 +483,14 @@ ruleTester.run('prop-name-casing', rule, { } } `, + languageOptions, errors: [ { message: 'Prop "greeting_text" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { // computed property name @@ -502,14 +502,14 @@ ruleTester.run('prop-name-casing', rule, { } } `, + languageOptions, errors: [ { message: 'Prop "greeting-text" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { // shorthand @@ -521,14 +521,14 @@ ruleTester.run('prop-name-casing', rule, { } } `, + languageOptions, errors: [ { message: 'Prop "greeting_text" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -539,14 +539,14 @@ ruleTester.run('prop-name-casing', rule, { } } `, + languageOptions, errors: [ { message: 'Prop "abc-123-def" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { // Parentheses computed property name @@ -558,14 +558,14 @@ ruleTester.run('prop-name-casing', rule, { } } `, + languageOptions, errors: [ { message: 'Prop "greeting-text" is not in camelCase.', type: 'Property', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -576,8 +576,8 @@ ruleTester.run('prop-name-casing', rule, { } } `, - errors: ['Prop "_item" is not in camelCase.'], - languageOptions + languageOptions, + errors: ['Prop "_item" is not in camelCase.'] }, { filename: 'test.vue', @@ -589,8 +589,8 @@ ruleTester.run('prop-name-casing', rule, { } `, options: ['snake_case'], - errors: ['Prop "_itemName" is not in snake_case.'], - languageOptions + languageOptions, + errors: ['Prop "_itemName" is not in snake_case.'] }, { // TemplateLiteral computed property @@ -602,8 +602,8 @@ ruleTester.run('prop-name-casing', rule, { } } `, - errors: ['Prop "greeting-text" is not in camelCase.'], - languageOptions + languageOptions, + errors: ['Prop "greeting-text" is not in camelCase.'] }, { // RegExp Literal computed property name @@ -615,8 +615,8 @@ ruleTester.run('prop-name-casing', rule, { } } `, - errors: ['Prop "/greeting-text/" is not in camelCase.'], - languageOptions + languageOptions, + errors: ['Prop "/greeting-text/" is not in camelCase.'] }, { filename: 'test.vue', @@ -627,16 +627,16 @@ ruleTester.run('prop-name-casing', rule, { }) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: 'Prop "greeting_text" is not in camelCase.', line: 4 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] }, { filename: 'test.vue', @@ -645,16 +645,16 @@ ruleTester.run('prop-name-casing', rule, { defineProps(['greeting_text']) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: 'Prop "greeting_text" is not in camelCase.', line: 3 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] }, ...(semver.lt( require('@typescript-eslint/parser/package.json').version, diff --git a/tests/lib/rules/require-default-prop.js b/tests/lib/rules/require-default-prop.js index 834f319aa..3ac13bcb8 100644 --- a/tests/lib/rules/require-default-prop.js +++ b/tests/lib/rules/require-default-prop.js @@ -414,15 +414,15 @@ ruleTester.run('require-default-prop', rule, { } }); `, + languageOptions: { + parser: require('@typescript-eslint/parser') + }, errors: [ { message: `Prop 'a' requires default value to be set.`, line: 4 } - ], - languageOptions: { - parser: require('@typescript-eslint/parser') - } + ] }, { filename: 'test.vue', @@ -435,13 +435,13 @@ ruleTester.run('require-default-prop', rule, { } }); `, + languageOptions: { parser: require('@typescript-eslint/parser') }, errors: [ { message: `Prop 'a' requires default value to be set.`, line: 4 } - ], - languageOptions: { parser: require('@typescript-eslint/parser') } + ] }, // computed properties @@ -555,16 +555,16 @@ ruleTester.run('require-default-prop', rule, { }) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions + }, errors: [ { message: "Prop 'foo' requires default value to be set.", line: 4 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions - } + ] }, { filename: 'test.vue', @@ -581,17 +581,17 @@ ruleTester.run('require-default-prop', rule, { }) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ...languageOptions, + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: "Prop 'bar' requires default value to be set.", line: 8 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ...languageOptions, - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, ...(semver.lt( require('@typescript-eslint/parser/package.json').version, diff --git a/tests/lib/rules/require-emit-validator.js b/tests/lib/rules/require-emit-validator.js index 8aadde153..32d998682 100644 --- a/tests/lib/rules/require-emit-validator.js +++ b/tests/lib/rules/require-emit-validator.js @@ -197,6 +197,7 @@ ruleTester.run('require-emit-validator', rule, { emits: ['foo', bar, \`baz\`, foo()] } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'missing', @@ -218,8 +219,7 @@ ruleTester.run('require-emit-validator', rule, { data: { name: 'Unknown emit' }, line: 3 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.js', @@ -228,6 +228,7 @@ ruleTester.run('require-emit-validator', rule, { emits: ['foo', bar, \`baz\`, foo()] }) `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'missing', @@ -249,8 +250,7 @@ ruleTester.run('require-emit-validator', rule, { data: { name: 'Unknown emit' }, line: 3 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -260,6 +260,7 @@ ruleTester.run('require-emit-validator', rule, { foo: null } }`, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'skipped', @@ -277,8 +278,7 @@ ruleTester.run('require-emit-validator', rule, { } ] } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -289,6 +289,7 @@ ruleTester.run('require-emit-validator', rule, { bar: (payload) => {} } }`, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'skipped', @@ -307,8 +308,7 @@ ruleTester.run('require-emit-validator', rule, { } ] } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -321,14 +321,14 @@ ruleTester.run('require-emit-validator', rule, { } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'missing', data: { name: 'foo' }, line: 4 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -339,18 +339,18 @@ ruleTester.run('require-emit-validator', rule, { } }); `, + languageOptions: { + parser: require('@typescript-eslint/parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { messageId: 'missing', data: { name: 'foo' }, line: 4 } - ], - languageOptions: { - parser: require('@typescript-eslint/parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] }, { filename: 'test.vue', @@ -359,18 +359,18 @@ ruleTester.run('require-emit-validator', rule, { const emit = defineEmits(['foo']) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { messageId: 'missing', data: { name: 'foo' }, line: 3 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] }, { filename: 'test.vue', @@ -379,6 +379,11 @@ ruleTester.run('require-emit-validator', rule, { const emit = defineEmits({foo:null}) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { messageId: 'skipped', @@ -395,12 +400,7 @@ ruleTester.run('require-emit-validator', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] } ] }) diff --git a/tests/lib/rules/require-explicit-emits.js b/tests/lib/rules/require-explicit-emits.js index ed9e2d050..da9b87246 100644 --- a/tests/lib/rules/require-explicit-emits.js +++ b/tests/lib/rules/require-explicit-emits.js @@ -2129,16 +2129,16 @@ emits: {'foo': null}, }>() `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: 'The "bar" event has been triggered but not declared on `defineEmits`.', line: 3 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', @@ -2150,16 +2150,16 @@ emits: {'foo': null}, defineEmits<(e: 'foo') => void>() `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: 'The "bar" event has been triggered but not declared on `defineEmits`.', line: 3 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', @@ -2187,16 +2187,16 @@ emits: {'foo': null}, emit('bar') `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: 'The "bar" event has been triggered but not declared on `defineEmits`.', line: 5 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', @@ -2237,16 +2237,16 @@ emits: {'foo': null}, emit('bar') `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: 'The "bar" event has been triggered but not declared on `defineEmits`.', line: 5 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { // new syntax in Vue 3.3 @@ -2259,16 +2259,16 @@ emits: {'foo': null}, emit('bar') `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: 'The "bar" event has been triggered but not declared on `defineEmits`.', line: 6 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { code: ` @@ -2299,16 +2299,16 @@ emits: {'foo': null}, const emit = defineEmits<(e: 'foo') => void>() `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: 'The "bar" event has been triggered but not declared on `defineEmits`.', line: 3 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] } ] }) diff --git a/tests/lib/rules/require-name-property.js b/tests/lib/rules/require-name-property.js index fe0357a30..c61c46759 100644 --- a/tests/lib/rules/require-name-property.js +++ b/tests/lib/rules/require-name-property.js @@ -76,6 +76,7 @@ ruleTester.run('require-name-property', rule, { export default { } `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -91,8 +92,7 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] }, { filename: 'InvalidComponent.vue', @@ -100,6 +100,7 @@ ruleTester.run('require-name-property', rule, { export default defineComponent({ }) `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -115,14 +116,14 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] }, { filename: 'InvalidComponent.vue', code: ` export default defineComponent({ }) `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -138,14 +139,14 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] }, { filename: 'InvalidComponent.vue', code: ` export default { } `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -161,8 +162,7 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] }, { filename: 'InvalidComponent.vue', @@ -171,6 +171,7 @@ ruleTester.run('require-name-property', rule, { nameNot: 'IssaNameNot' } `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -187,8 +188,7 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] }, { filename: 'InvalidComponent.vue', @@ -197,6 +197,7 @@ ruleTester.run('require-name-property', rule, { nameNot: 'IssaNameNot' }) `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -213,8 +214,7 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] }, { @@ -226,6 +226,7 @@ ruleTester.run('require-name-property', rule, { } } `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -244,8 +245,7 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] }, { filename: 'InvalidComponent.vue', @@ -254,6 +254,7 @@ ruleTester.run('require-name-property', rule, { [name]: 'IssaName' } `, + languageOptions, errors: [ { message: 'Required name property is not set.', @@ -270,8 +271,7 @@ ruleTester.run('require-name-property', rule, { } ] } - ], - languageOptions + ] } ] }) diff --git a/tests/lib/rules/require-prop-comment.js b/tests/lib/rules/require-prop-comment.js index f2ee24ee9..837f3c525 100644 --- a/tests/lib/rules/require-prop-comment.js +++ b/tests/lib/rules/require-prop-comment.js @@ -263,18 +263,18 @@ tester.run('require-prop-comment', rule, { const props = defineProps() `, + languageOptions: { + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { line: 4, column: 9, message: 'The "a" property should have a JSDoc comment.' } - ], - languageOptions: { - 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 acd098634..0ed9a57af 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, { } } `, + languageOptions: { parser: require('@typescript-eslint/parser') }, errors: [ { message: 'The "a" property should be a constructor.', line: 5 } - ], - languageOptions: { parser: require('@typescript-eslint/parser') } + ] }, { filename: 'ExtraCommas.vue', @@ -248,13 +248,13 @@ ruleTester.run('require-prop-type-constructor', rule, { } } `, + languageOptions: { parser: require('@typescript-eslint/parser') }, errors: [ { message: 'The "name" property should be a constructor.', line: 4 } - ], - languageOptions: { parser: require('@typescript-eslint/parser') } + ] }, { filename: 'LiteralsComponent.vue', @@ -381,13 +381,13 @@ ruleTester.run('require-prop-type-constructor', rule, { }) `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: 'The "a" property should be a constructor.', line: 5 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] } ] }) diff --git a/tests/lib/rules/require-prop-types.js b/tests/lib/rules/require-prop-types.js index bf38d9fd7..11ba2d5e8 100644 --- a/tests/lib/rules/require-prop-types.js +++ b/tests/lib/rules/require-prop-types.js @@ -245,6 +245,7 @@ ruleTester.run('require-prop-types', rule, { props: ['foo', bar, \`baz\`, foo()] } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', @@ -262,8 +263,7 @@ ruleTester.run('require-prop-types', rule, { message: 'Prop "Unknown prop" should define at least its type.', line: 3 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.js', @@ -272,6 +272,7 @@ ruleTester.run('require-prop-types', rule, { props: ['foo', bar, \`baz\`, foo()] }) `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', @@ -289,8 +290,7 @@ ruleTester.run('require-prop-types', rule, { message: 'Prop "Unknown prop" should define at least its type.', line: 3 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -302,13 +302,13 @@ ruleTester.run('require-prop-types', rule, { } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -321,13 +321,13 @@ ruleTester.run('require-prop-types', rule, { } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -338,13 +338,13 @@ ruleTester.run('require-prop-types', rule, { } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -355,17 +355,17 @@ ruleTester.run('require-prop-types', rule, { } }); `, + languageOptions: { + parser: require('@typescript-eslint/parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { - parser: require('@typescript-eslint/parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] }, { filename: 'test.vue', @@ -376,17 +376,17 @@ ruleTester.run('require-prop-types', rule, { } }); `, + languageOptions: { + parser: require('@typescript-eslint/parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { - parser: require('@typescript-eslint/parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] }, { filename: 'test.vue', @@ -397,17 +397,17 @@ ruleTester.run('require-prop-types', rule, { }) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] }, { filename: 'test.vue', @@ -416,17 +416,17 @@ ruleTester.run('require-prop-types', rule, { defineProps(['foo']) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { message: 'Prop "foo" should define at least its type.', line: 3 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] }, { // defineModel @@ -436,6 +436,7 @@ ruleTester.run('require-prop-types', rule, { const foo = defineModel('foo') `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: 'Prop "modelValue" should define at least its type.', @@ -445,8 +446,7 @@ ruleTester.run('require-prop-types', rule, { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, { // defineModel @@ -456,6 +456,7 @@ ruleTester.run('require-prop-types', rule, { const foo = defineModel('foo',{}) `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { message: 'Prop "modelValue" should define at least its type.', @@ -465,8 +466,7 @@ ruleTester.run('require-prop-types', rule, { message: 'Prop "foo" should define at least its type.', line: 4 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] } ] }) diff --git a/tests/lib/rules/require-render-return.js b/tests/lib/rules/require-render-return.js index 44da6b083..d2aad3c01 100644 --- a/tests/lib/rules/require-render-return.js +++ b/tests/lib/rules/require-render-return.js @@ -136,14 +136,14 @@ ruleTester.run('require-render-return', rule, { render() { } }`, + languageOptions, errors: [ { message: 'Expected to return a value in render function.', type: 'Identifier', line: 2 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -154,14 +154,14 @@ ruleTester.run('require-render-return', rule, { } } }`, + languageOptions, errors: [ { message: 'Expected to return a value in render function.', type: 'Identifier', line: 2 } - ], - languageOptions + ] }, { code: `Vue.component('test', { @@ -171,14 +171,14 @@ ruleTester.run('require-render-return', rule, { } } })`, + languageOptions, errors: [ { message: 'Expected to return a value in render function.', type: 'Identifier', line: 2 } - ], - languageOptions + ] }, { code: `app.component('test', { @@ -188,14 +188,14 @@ ruleTester.run('require-render-return', rule, { } } })`, + languageOptions, errors: [ { message: 'Expected to return a value in render function.', type: 'Identifier', line: 2 } - ], - languageOptions + ] }, { code: `Vue.component('test2', { @@ -205,14 +205,14 @@ ruleTester.run('require-render-return', rule, { } } })`, + languageOptions, errors: [ { message: 'Expected to return a value in render function.', type: 'Identifier', line: 2 } - ], - languageOptions + ] }, { code: `Vue.component('test2', { @@ -224,14 +224,14 @@ ruleTester.run('require-render-return', rule, { } } })`, + languageOptions, errors: [ { message: 'Expected to return a value in render function.', type: 'Identifier', line: 2 } - ], - languageOptions + ] } ] }) diff --git a/tests/lib/rules/require-typed-object-prop.js b/tests/lib/rules/require-typed-object-prop.js index 3d8d3e58b..9f5f000a9 100644 --- a/tests/lib/rules/require-typed-object-prop.js +++ b/tests/lib/rules/require-typed-object-prop.js @@ -377,6 +377,14 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: Object }); `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module', + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -405,15 +413,7 @@ ruleTester.run('require-typed-object-prop', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module', - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -422,6 +422,14 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: Array }); `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module', + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -450,15 +458,7 @@ ruleTester.run('require-typed-object-prop', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module', - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] }, { filename: 'test.vue', @@ -467,6 +467,7 @@ ruleTester.run('require-typed-object-prop', rule, { props: { foo: Object } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -495,8 +496,7 @@ ruleTester.run('require-typed-object-prop', rule, { } ] } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -505,6 +505,7 @@ ruleTester.run('require-typed-object-prop', rule, { props: { foo: Object } }); `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -533,8 +534,7 @@ ruleTester.run('require-typed-object-prop', rule, { } ] } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -543,6 +543,7 @@ ruleTester.run('require-typed-object-prop', rule, { props: { foo: { type: Object } } }); `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -571,8 +572,7 @@ ruleTester.run('require-typed-object-prop', rule, { } ] } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -581,6 +581,7 @@ ruleTester.run('require-typed-object-prop', rule, { props: { foo: { type: Object } } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -609,8 +610,7 @@ ruleTester.run('require-typed-object-prop', rule, { } ] } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -619,6 +619,14 @@ ruleTester.run('require-typed-object-prop', rule, { defineProps({ foo: { type: Object } }); `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module', + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } + }, errors: [ { messageId: 'expectedTypeAnnotation', @@ -647,15 +655,7 @@ ruleTester.run('require-typed-object-prop', rule, { } ] } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module', - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - } - } + ] } ] }) diff --git a/tests/lib/rules/require-typed-ref.js b/tests/lib/rules/require-typed-ref.js index 5b18bcb3c..6f3b359d6 100644 --- a/tests/lib/rules/require-typed-ref.js +++ b/tests/lib/rules/require-typed-ref.js @@ -220,6 +220,7 @@ tester.run('require-typed-ref', rule, { const count = ref() `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { messageId: 'noType', @@ -228,8 +229,7 @@ tester.run('require-typed-ref', rule, { endLine: 4, endColumn: 30 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, { filename: 'test.vue', @@ -244,6 +244,7 @@ tester.run('require-typed-ref', rule, { } `, + languageOptions: { parser: require('vue-eslint-parser') }, errors: [ { messageId: 'noType', @@ -252,8 +253,7 @@ tester.run('require-typed-ref', rule, { endLine: 6, endColumn: 34 } - ], - languageOptions: { parser: require('vue-eslint-parser') } + ] }, { filename: 'test.ts', diff --git a/tests/lib/rules/require-valid-default-prop.js b/tests/lib/rules/require-valid-default-prop.js index a8e5cfbef..c9e506a4a 100644 --- a/tests/lib/rules/require-valid-default-prop.js +++ b/tests/lib/rules/require-valid-default-prop.js @@ -219,12 +219,12 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - errors: errorMessage('function'), languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 6, sourceType: 'module' - } + }, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -237,12 +237,12 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - errors: errorMessage('function'), languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 6, sourceType: 'module' - } + }, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -255,12 +255,12 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - errors: errorMessage('function'), languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 6, sourceType: 'module' - } + }, + errors: errorMessage('function') }, { // https://github.com/vuejs/eslint-plugin-vue/issues/1853 @@ -318,8 +318,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('number or string'), - languageOptions + languageOptions, + errors: errorMessage('number or string') }, { filename: 'test.vue', @@ -331,8 +331,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('number or function'), - languageOptions + languageOptions, + errors: errorMessage('number or function') }, { filename: 'test.vue', @@ -344,8 +344,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('number'), - languageOptions + languageOptions, + errors: errorMessage('number') }, { filename: 'test.vue', @@ -357,8 +357,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('number'), - languageOptions + languageOptions, + errors: errorMessage('number') }, { filename: 'test.vue', @@ -370,8 +370,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('number'), - languageOptions + languageOptions, + errors: errorMessage('number') }, { filename: 'test.vue', @@ -383,8 +383,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('number'), - languageOptions + languageOptions, + errors: errorMessage('number') }, { filename: 'test.vue', @@ -396,8 +396,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('string'), - languageOptions + languageOptions, + errors: errorMessage('string') }, { filename: 'test.vue', @@ -409,8 +409,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('string'), - languageOptions + languageOptions, + errors: errorMessage('string') }, { filename: 'test.vue', @@ -422,8 +422,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('string'), - languageOptions + languageOptions, + errors: errorMessage('string') }, { filename: 'test.vue', @@ -435,8 +435,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('boolean'), - languageOptions + languageOptions, + errors: errorMessage('boolean') }, { filename: 'test.vue', @@ -448,8 +448,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('boolean'), - languageOptions + languageOptions, + errors: errorMessage('boolean') }, { filename: 'test.vue', @@ -461,8 +461,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('boolean'), - languageOptions + languageOptions, + errors: errorMessage('boolean') }, { filename: 'test.vue', @@ -474,8 +474,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('boolean'), - languageOptions + languageOptions, + errors: errorMessage('boolean') }, { filename: 'test.vue', @@ -487,8 +487,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -500,8 +500,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -513,8 +513,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -526,8 +526,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -539,8 +539,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -552,8 +552,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -565,8 +565,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -578,8 +578,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -591,8 +591,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -604,8 +604,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -617,8 +617,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function or number'), - languageOptions + languageOptions, + errors: errorMessage('function or number') }, { filename: 'test.vue', @@ -631,12 +631,12 @@ ruleTester.run('require-valid-default-prop', rule, { } });`, - errors: errorMessage('function or number'), languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 6, sourceType: 'module' - } + }, + errors: errorMessage('function or number') }, { @@ -657,6 +657,7 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, + languageOptions, errors: [ { message: `Type of the default value for 'foo' prop must be a function.`, @@ -670,8 +671,7 @@ ruleTester.run('require-valid-default-prop', rule, { message: `Type of the default value for '[baz]' prop must be a function.`, line: 13 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -683,8 +683,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('string'), - languageOptions + languageOptions, + errors: errorMessage('string') }, { filename: 'test.vue', @@ -698,8 +698,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessageForFunction('number'), - languageOptions + languageOptions, + errors: errorMessageForFunction('number') }, { filename: 'test.vue', @@ -713,8 +713,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessageForFunction('object'), - languageOptions + languageOptions, + errors: errorMessageForFunction('object') }, { filename: 'test.vue', @@ -728,8 +728,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessageForFunction('string'), - languageOptions + languageOptions, + errors: errorMessageForFunction('string') }, { filename: 'test.vue', @@ -743,8 +743,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessageForFunction('number'), - languageOptions + languageOptions, + errors: errorMessageForFunction('number') }, { filename: 'test.vue', @@ -758,8 +758,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessageForFunction('object'), - languageOptions + languageOptions, + errors: errorMessageForFunction('object') }, { filename: 'test.vue', @@ -773,8 +773,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessageForFunction('string'), - languageOptions + languageOptions, + errors: errorMessageForFunction('string') }, { filename: 'test.vue', @@ -786,8 +786,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('number'), - languageOptions + languageOptions, + errors: errorMessage('number') }, { filename: 'test.vue', @@ -799,8 +799,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('object'), - languageOptions + languageOptions, + errors: errorMessage('object') }, { filename: 'test.vue', @@ -812,8 +812,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('string'), - languageOptions + languageOptions, + errors: errorMessage('string') }, { filename: 'test.vue', @@ -825,8 +825,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('function'), - languageOptions + languageOptions, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -851,6 +851,7 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, + languageOptions, errors: [ { message: @@ -867,8 +868,7 @@ ruleTester.run('require-valid-default-prop', rule, { "Type of the default value for 'foo' prop must be a string or boolean.", line: 11 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -880,8 +880,8 @@ ruleTester.run('require-valid-default-prop', rule, { } } }`, - errors: errorMessage('string'), - languageOptions + languageOptions, + errors: errorMessage('string') }, { filename: 'test.vue', @@ -894,12 +894,12 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - errors: errorMessage('function'), languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 6, sourceType: 'module' - } + }, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -912,12 +912,12 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - errors: errorMessage('function'), languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 6, sourceType: 'module' - } + }, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -930,12 +930,12 @@ ruleTester.run('require-valid-default-prop', rule, { } }); `, - errors: errorMessage('function'), languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 6, sourceType: 'module' - } + }, + errors: errorMessage('function') }, { filename: 'test.vue', @@ -949,17 +949,17 @@ ruleTester.run('require-valid-default-prop', rule, { }) `, + languageOptions: { + parser: require('vue-eslint-parser'), + ecmaVersion: 6, + sourceType: 'module' + }, errors: [ { message: "Type of the default value for 'foo' prop must be a string.", line: 6 } - ], - languageOptions: { - parser: require('vue-eslint-parser'), - ecmaVersion: 6, - sourceType: 'module' - } + ] }, { filename: 'test.vue', @@ -970,12 +970,6 @@ ruleTester.run('require-valid-default-prop', rule, { }) `, - errors: [ - { - message: "Type of the default value for 'foo' prop must be a string.", - line: 4 - } - ], languageOptions: { ecmaVersion: 6, sourceType: 'module', @@ -983,7 +977,13 @@ ruleTester.run('require-valid-default-prop', rule, { parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + { + message: "Type of the default value for 'foo' prop must be a string.", + line: 4 + } + ] }, { code: ` diff --git a/tests/lib/rules/return-in-computed-property.js b/tests/lib/rules/return-in-computed-property.js index ca15503ae..2f17fd1c3 100644 --- a/tests/lib/rules/return-in-computed-property.js +++ b/tests/lib/rules/return-in-computed-property.js @@ -160,13 +160,13 @@ ruleTester.run('return-in-computed-property', rule, { } } `, + languageOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -178,13 +178,13 @@ ruleTester.run('return-in-computed-property', rule, { } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 4 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -199,13 +199,13 @@ ruleTester.run('return-in-computed-property', rule, { } } `, + languageOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 4 } - ], - languageOptions: { ecmaVersion: 6, sourceType: 'module' } + ] }, { filename: 'test.vue', @@ -221,13 +221,13 @@ ruleTester.run('return-in-computed-property', rule, { } } `, + languageOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 7 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -243,13 +243,13 @@ ruleTester.run('return-in-computed-property', rule, { } } `, + languageOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -265,13 +265,13 @@ ruleTester.run('return-in-computed-property', rule, { } `, options: [{ treatUndefinedAsUnspecified: false }], + languageOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 4 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -285,13 +285,13 @@ ruleTester.run('return-in-computed-property', rule, { } `, options: [{ treatUndefinedAsUnspecified: true }], + languageOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 4 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -306,14 +306,14 @@ ruleTester.run('return-in-computed-property', rule, { } } `, + languageOptions, errors: [ { message: 'Expected to return a value in "my_FALSE_test" computed property.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -341,6 +341,7 @@ ruleTester.run('return-in-computed-property', rule, { } } `, + languageOptions, errors: [ { message: 'Expected to return a value in computed function.', @@ -362,8 +363,7 @@ ruleTester.run('return-in-computed-property', rule, { message: 'Expected to return a value in computed function.', line: 16 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -379,13 +379,13 @@ ruleTester.run('return-in-computed-property', rule, { } `, options: [{ treatUndefinedAsUnspecified: false }], + languageOptions, errors: [ { message: 'Expected to return a value in computed function.', line: 5 } - ], - languageOptions + ] }, { filename: 'test.vue', @@ -396,13 +396,13 @@ ruleTester.run('return-in-computed-property', rule, { } } }`, + languageOptions, errors: [ { message: 'Expected to return a value in "foo" computed property.', line: 4 } - ], - languageOptions + ] } ] }) diff --git a/tests/lib/rules/script-indent.js b/tests/lib/rules/script-indent.js index c664b154d..666ca9d71 100644 --- a/tests/lib/rules/script-indent.js +++ b/tests/lib/rules/script-indent.js @@ -263,7 +263,7 @@ tester.run( `, errors: [ { - message: 'Expected " " character, but found "\\t" character.', + message: String.raw`Expected " " character, but found "\t" character.`, line: 3 } ] @@ -289,11 +289,11 @@ tester.run( options: ['tab'], errors: [ { - message: 'Expected "\\t" character, but found " " character.', + message: String.raw`Expected "\t" character, but found " " character.`, line: 3 }, { - message: 'Expected "\\t" character, but found " " character.', + message: String.raw`Expected "\t" character, but found " " character.`, line: 4 } ] diff --git a/tests/lib/rules/sort-keys.js b/tests/lib/rules/sort-keys.js index 4a40f1e67..030c5ed3f 100644 --- a/tests/lib/rules/sort-keys.js +++ b/tests/lib/rules/sort-keys.js @@ -523,10 +523,10 @@ ruleTester.run('sort-keys', rule, { }, { code: 'var obj = {a:1, [``]:2} // default', + languageOptions: { ecmaVersion: 6 }, errors: [ "Expected object keys to be in ascending order. '' should be before 'a'." - ], - languageOptions: { ecmaVersion: 6 } + ] }, { code: 'var obj = {a:1, _:2, b:3} // default', @@ -575,101 +575,101 @@ ruleTester.run('sort-keys', rule, { { code: 'var obj = {...z, c:1, b:1}', options: [], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in ascending order. 'b' should be before 'c'." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, { code: 'var obj = {...z, ...c, d:4, b:1, ...y, ...f, e:2, a:1}', options: [], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in ascending order. 'b' should be before 'd'.", "Expected object keys to be in ascending order. 'a' should be before 'e'." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, { code: 'var obj = {c:1, b:1, ...a}', options: [], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in ascending order. 'b' should be before 'c'." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, { code: 'var obj = {...z, ...a, c:1, b:1}', options: [], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in ascending order. 'b' should be before 'c'." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, { code: 'var obj = {...z, b:1, a:1, ...d, ...c}', options: [], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in ascending order. 'a' should be before 'b'." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, { code: 'var obj = {...z, a:2, b:0, ...x, ...c}', options: ['desc'], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in descending order. 'b' should be before 'a'." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, { code: 'var obj = {...z, a:2, b:0, ...x}', options: ['desc'], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in descending order. 'b' should be before 'a'." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, { code: "var obj = {...z, '':1, a:2}", options: ['desc'], + languageOptions: { ecmaVersion: 2018 }, errors: [ "Expected object keys to be in descending order. 'a' should be before ''." - ], - languageOptions: { ecmaVersion: 2018 } + ] }, // ignore non-simple computed properties, but their position shouldn't affect other comparisons. { code: "var obj = {a:1, [b+c]:2, '':3}", + languageOptions: { ecmaVersion: 6 }, errors: [ "Expected object keys to be in ascending order. '' should be before 'a'." - ], - languageOptions: { ecmaVersion: 6 } + ] }, { code: "var obj = {'':1, [b+c]:2, a:3}", options: ['desc'], + languageOptions: { ecmaVersion: 6 }, errors: [ "Expected object keys to be in descending order. 'a' should be before ''." - ], - languageOptions: { ecmaVersion: 6 } + ] }, { code: "var obj = {b:1, [f()]:2, '':3, a:4}", options: ['desc'], + languageOptions: { ecmaVersion: 6 }, errors: [ "Expected object keys to be in descending order. 'a' should be before ''." - ], - languageOptions: { ecmaVersion: 6 } + ] }, // not ignore simple computed properties. { code: 'var obj = {a:1, b:3, [a]: -1, c:2}', + languageOptions: { ecmaVersion: 6 }, errors: [ "Expected object keys to be in ascending order. 'a' should be before 'b'." - ], - languageOptions: { ecmaVersion: 6 } + ] }, // nested @@ -918,10 +918,10 @@ ruleTester.run('sort-keys', rule, { { code: "var obj = {[``]:1, a:'2'} // desc", options: ['desc'], + languageOptions: { ecmaVersion: 6 }, errors: [ "Expected object keys to be in descending order. 'a' should be before ''." - ], - languageOptions: { ecmaVersion: 6 } + ] }, { code: 'var obj = {a:1, _:2, b:3} // desc', @@ -1193,6 +1193,8 @@ ruleTester.run('sort-keys', rule, { }, } `, + languageOptions, + errors: [ { message: @@ -1204,9 +1206,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'msg' should be before 'zd'.", line: 12 } - ], - - languageOptions + ] }, { filename: 'example.vue', @@ -1228,14 +1228,14 @@ ruleTester.run('sort-keys', rule, { name: 'burger', }; `, + languageOptions, errors: [ { message: "Expected object keys to be in ascending order. 'closeMenu' should be before 'toggleMenu'.", line: 12 } - ], - languageOptions + ] }, { filename: 'example.vue', @@ -1261,6 +1261,7 @@ ruleTester.run('sort-keys', rule, { name: 'burger', }; `, + languageOptions, errors: [ { message: @@ -1272,8 +1273,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'a' should be before 'z'.", line: 14 } - ], - languageOptions + ] }, { filename: 'example.vue', @@ -1290,6 +1290,7 @@ ruleTester.run('sort-keys', rule, { name: 'burger', }; `, + languageOptions, errors: [ { message: @@ -1301,8 +1302,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'isActive' should be before 'z'.", line: 8 } - ], - languageOptions + ] }, { filename: 'example.vue', @@ -1319,6 +1319,7 @@ ruleTester.run('sort-keys', rule, { const dict = { zd: 1, a: 2 }; `, + languageOptions, errors: [ { message: @@ -1330,8 +1331,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'a' should be before 'zd'.", line: 12 } - ], - languageOptions + ] }, { filename: 'test.js', @@ -1350,6 +1350,7 @@ ruleTester.run('sort-keys', rule, { template: '
' }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -1361,8 +1362,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'msg' should be before 'z'.", line: 9 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -1381,6 +1381,7 @@ ruleTester.run('sort-keys', rule, { template: '
' }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -1392,8 +1393,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'msg' should be before 'z'.", line: 9 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'test.js', @@ -1412,6 +1412,7 @@ ruleTester.run('sort-keys', rule, { template: '
' }) `, + languageOptions: { ecmaVersion: 6 }, errors: [ { message: @@ -1423,8 +1424,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'msg' should be before 'z'.", line: 9 } - ], - languageOptions: { ecmaVersion: 6 } + ] }, { filename: 'propsOrder.vue', @@ -1440,14 +1440,14 @@ ruleTester.run('sort-keys', rule, { } `, options: ['asc', { ignoreGrandchildrenOf: [] }], + languageOptions, errors: [ { message: "Expected object keys to be in ascending order. 'default' should be before 'type'.", line: 7 } - ], - languageOptions + ] }, { filename: 'propsOrder.vue', @@ -1463,6 +1463,7 @@ ruleTester.run('sort-keys', rule, { a: 2 } `, + languageOptions, errors: [ { message: @@ -1474,8 +1475,7 @@ ruleTester.run('sort-keys', rule, { "Expected object keys to be in ascending order. 'a' should be before 'foo'.", line: 10 } - ], - languageOptions + ] }, { filename: 'propsOrder.vue', @@ -1491,14 +1491,14 @@ ruleTester.run('sort-keys', rule, { } } `, + languageOptions, errors: [ { message: "Expected object keys to be in ascending order. 'a' should be before 'b'.", line: 7 } - ], - languageOptions + ] } ] }) diff --git a/tests/lib/rules/valid-define-emits.js b/tests/lib/rules/valid-define-emits.js index 0ec383b36..57a130299 100644 --- a/tests/lib/rules/valid-define-emits.js +++ b/tests/lib/rules/valid-define-emits.js @@ -155,15 +155,15 @@ tester.run('valid-define-emits', rule, { defineEmits<(e: 'notify')=>void>({ submit: null }) `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: '`defineEmits` has both a type-only emit and an argument.', line: 4 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/valid-define-options.js b/tests/lib/rules/valid-define-options.js index 904d0c197..867bcb569 100644 --- a/tests/lib/rules/valid-define-options.js +++ b/tests/lib/rules/valid-define-options.js @@ -132,6 +132,9 @@ tester.run('valid-define-options', rule, { defineOptions<{ name: 'Foo' }>() `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: 'Options are not defined.', @@ -141,10 +144,7 @@ tester.run('valid-define-options', rule, { message: '`defineOptions()` cannot accept type arguments.', line: 3 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/valid-define-props.js b/tests/lib/rules/valid-define-props.js index 193a5c432..d20209846 100644 --- a/tests/lib/rules/valid-define-props.js +++ b/tests/lib/rules/valid-define-props.js @@ -158,15 +158,15 @@ tester.run('valid-define-props', rule, { defineProps<{ msg?:string }>({ msg: String }) `, + languageOptions: { + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } + }, errors: [ { message: '`defineProps` has both a type-only props and an argument.', line: 4 } - ], - languageOptions: { - parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + ] }, { filename: 'test.vue', diff --git a/tests/lib/rules/valid-v-model.js b/tests/lib/rules/valid-v-model.js index 02264e527..7ef63d01e 100644 --- a/tests/lib/rules/valid-v-model.js +++ b/tests/lib/rules/valid-v-model.js @@ -290,62 +290,62 @@ tester.run('valid-v-model', rule, { { filename: 'test.vue', code: '', - errors: [ - "'v-model' directives require the attribute value which is valid as LHS." - ], languageOptions: { parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + "'v-model' directives require the attribute value which is valid as LHS." + ] }, { filename: 'test.vue', code: '', - errors: [ - "'v-model' directives require the attribute value which is valid as LHS." - ], languageOptions: { parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + "'v-model' directives require the attribute value which is valid as LHS." + ] }, { filename: 'test.vue', code: '', - errors: [ - "'v-model' directives require the attribute value which is valid as LHS." - ], languageOptions: { parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + "'v-model' directives require the attribute value which is valid as LHS." + ] }, { filename: 'test.vue', code: '', - errors: [ - "'v-model' directives require the attribute value which is valid as LHS." - ], languageOptions: { parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + "'v-model' directives require the attribute value which is valid as LHS." + ] }, { filename: 'test.vue', code: '', - errors: [ - "'v-model' directives require the attribute value which is valid as LHS." - ], languageOptions: { parserOptions: { parser: require.resolve('@typescript-eslint/parser') } - } + }, + errors: [ + "'v-model' directives require the attribute value which is valid as LHS." + ] } ] }) diff --git a/tests/lib/utils/vue-component.js b/tests/lib/utils/vue-component.js index 46328f0f4..9beffdb82 100644 --- a/tests/lib/utils/vue-component.js +++ b/tests/lib/utils/vue-component.js @@ -345,14 +345,14 @@ ruleTester.run('vue-component', rule, { { filename: 'test.vue', code: `export default { }`, - errors: [makeError(1)], - languageOptions + languageOptions, + errors: [makeError(1)] }, { filename: 'test.jsx', code: `export default { }`, - errors: [makeError(1)], - languageOptions + languageOptions, + errors: [makeError(1)] }, ...invalidTests('js'), ...invalidTests('jsx'), diff --git a/tools/new-rule.js b/tools/new-rule.js index e569f1da7..d9a155795 100644 --- a/tools/new-rule.js +++ b/tools/new-rule.js @@ -117,7 +117,7 @@ description: xxx > xxx -- :exclamation: ***This rule has not been released yet.*** +- :exclamation: _**This rule has not been released yet.**_ ## :book: Rule Details diff --git a/tools/update-docs.js b/tools/update-docs.js index 74883ddb6..21ebce2f7 100644 --- a/tools/update-docs.js +++ b/tools/update-docs.js @@ -88,8 +88,8 @@ class DocFile { ? meta.docs.description : this.content.match(/^description: (.*)$/m)[1] const escapedDescription = description - .replace(/\*/g, '\\*') - .replace(/_/g, '\\_') + .replace(/\*/g, String.raw`\*`) + .replace(/_/g, String.raw`\_`) const title = `# ${ruleId}\n\n> ${escapedDescription}` const notes = [] @@ -142,7 +142,7 @@ class DocFile { if (!this.since) { notes.unshift( - `- :exclamation: ***This rule has not been released yet.*** ` + `- :exclamation: _**This rule has not been released yet.**_ ` ) }