From 299d63484554b05968b3c97b97f52adbd691982f Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Tue, 16 May 2023 22:17:50 +0200 Subject: [PATCH 1/6] Add `additionalProperties` to `vue/no-deprecated-router-link-tag-prop` schema (#2177) --- lib/rules/no-deprecated-router-link-tag-prop.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-deprecated-router-link-tag-prop.js b/lib/rules/no-deprecated-router-link-tag-prop.js index 2feb0ee75..e2853f2af 100644 --- a/lib/rules/no-deprecated-router-link-tag-prop.js +++ b/lib/rules/no-deprecated-router-link-tag-prop.js @@ -45,7 +45,8 @@ module.exports = { uniqueItems: true, minItems: 1 } - } + }, + additionalProperties: false } ], messages: { From c1f3d55f284cf1b26ff7f9a90f2394e53239fce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AA=E8=A7=89=E9=9B=A8=E5=A3=B0?= <544022268@qq.com> Date: Fri, 19 May 2023 16:18:59 +0800 Subject: [PATCH 2/6] Document related rules for component name rules (#2181) --- docs/rules/multi-word-component-names.md | 4 ++++ docs/rules/no-reserved-component-names.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/rules/multi-word-component-names.md b/docs/rules/multi-word-component-names.md index 25f862720..c54d199e9 100644 --- a/docs/rules/multi-word-component-names.md +++ b/docs/rules/multi-word-component-names.md @@ -169,6 +169,10 @@ export default { +## :couple: Related Rules + +- [vue/no-reserved-component-names](./no-reserved-component-names.md) + ## :books: Further Reading - [Style guide - Multi-word component names](https://vuejs.org/style-guide/rules-essential.html#use-multi-word-component-names) diff --git a/docs/rules/no-reserved-component-names.md b/docs/rules/no-reserved-component-names.md index 8a0813b94..80e430813 100644 --- a/docs/rules/no-reserved-component-names.md +++ b/docs/rules/no-reserved-component-names.md @@ -72,6 +72,10 @@ export default { +## :couple: Related Rules + +- [vue/multi-word-component-names](./multi-word-component-names.md) + ## :books: Further Reading - [List of html elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) From 8494cd5c62227ca3286f23d8a9b116e91370f4c7 Mon Sep 17 00:00:00 2001 From: Magomed Chemurziev Date: Mon, 22 May 2023 07:46:24 +0300 Subject: [PATCH 3/6] Extend `vue/no-dupe-keys` to support ` + `, + parser: require.resolve('vue-eslint-parser') + }, + { + filename: 'test.vue', + code: ` + + `, + parser: require.resolve('vue-eslint-parser'), + parserOptions: { parser: require.resolve('@typescript-eslint/parser') } } ], @@ -861,6 +887,85 @@ ruleTester.run('no-dupe-keys', rule, { line: 7 } ] + }, + { + filename: 'test.vue', + code: ` + + `, + parser: require.resolve('vue-eslint-parser'), + errors: [ + { + message: "Duplicated key 'foo'.", + line: 6 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + parser: require.resolve('vue-eslint-parser'), + errors: [ + { + message: "Duplicated key 'baz'.", + line: 4 + }, + { + message: "Duplicated key 'foo'.", + line: 12 + }, + { + message: "Duplicated key 'bar'.", + line: 15 + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + parser: require.resolve('vue-eslint-parser'), + parserOptions: { parser: require.resolve('@typescript-eslint/parser') }, + errors: [ + { + message: "Duplicated key 'foo'.", + line: 8 + }, + { + message: "Duplicated key 'bar'.", + line: 9 + } + ] } ] }) From 30931f0f493308bd69e1527d407d1dec5b1afa19 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Mon, 22 May 2023 13:46:41 +0900 Subject: [PATCH 4/6] Add support for `defineOptions` to `vue/no-duplicate-attr-inheritance` rule (#2178) --- lib/rules/no-duplicate-attr-inheritance.js | 21 ++++++-- .../rules/no-duplicate-attr-inheritance.js | 52 +++++++++++++++++++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/lib/rules/no-duplicate-attr-inheritance.js b/lib/rules/no-duplicate-attr-inheritance.js index eea2bf765..a8661b091 100644 --- a/lib/rules/no-duplicate-attr-inheritance.js +++ b/lib/rules/no-duplicate-attr-inheritance.js @@ -26,12 +26,23 @@ module.exports = { /** @type {string | number | boolean | RegExp | BigInt | null} */ let inheritsAttrs = true - return Object.assign( - utils.executeOnVue(context, (node) => { - const inheritAttrsProp = utils.findProperty(node, 'inheritAttrs') + /** @param {ObjectExpression} node */ + function processOptions(node) { + const inheritAttrsProp = utils.findProperty(node, 'inheritAttrs') - if (inheritAttrsProp && inheritAttrsProp.value.type === 'Literal') { - inheritsAttrs = inheritAttrsProp.value.value + if (inheritAttrsProp && inheritAttrsProp.value.type === 'Literal') { + inheritsAttrs = inheritAttrsProp.value.value + } + } + + return utils.compositingVisitors( + utils.executeOnVue(context, processOptions), + utils.defineScriptSetupVisitor(context, { + onDefineOptionsEnter(node) { + if (node.arguments.length === 0) return + const define = node.arguments[0] + if (define.type !== 'ObjectExpression') return + processOptions(define) } }), utils.defineTemplateBodyVisitor(context, { diff --git a/tests/lib/rules/no-duplicate-attr-inheritance.js b/tests/lib/rules/no-duplicate-attr-inheritance.js index b4a00c228..7fc112123 100644 --- a/tests/lib/rules/no-duplicate-attr-inheritance.js +++ b/tests/lib/rules/no-duplicate-attr-inheritance.js @@ -79,6 +79,26 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { export default { } ` + }, + { + filename: 'test.vue', + code: ` + + + + ` + }, + { + filename: 'test.vue', + code: ` + + + ` } ], @@ -99,6 +119,38 @@ ruleTester.run('no-duplicate-attr-inheritance', rule, { `, errors: ['Set "inheritAttrs" to false.'] + }, + { + filename: 'test.vue', + code: ` + + + + `, + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 7 + } + ] + }, + { + filename: 'test.vue', + code: ` + + + `, + errors: [ + { + message: 'Set "inheritAttrs" to false.', + line: 5 + } + ] } ] }) From d93f2c6b08827365bc40896be8050b47696e0460 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Mon, 22 May 2023 19:37:54 +0900 Subject: [PATCH 5/6] Fix false positive for unknown prop in `vue/no-undef-properties` rule (#2186) --- lib/rules/no-undef-properties.js | 11 ++++++ tests/lib/rules/no-undef-properties.js | 47 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/lib/rules/no-undef-properties.js b/lib/rules/no-undef-properties.js index 36650f555..d7026eb62 100644 --- a/lib/rules/no-undef-properties.js +++ b/lib/rules/no-undef-properties.js @@ -127,6 +127,8 @@ module.exports = { /** @type { Set } */ this.reported = new Set() + + this.hasUnknownProperty = false } /** * Report @@ -135,6 +137,7 @@ module.exports = { * @param {boolean} [options.props] */ verifyReferences(references, options) { + if (this.hasUnknownProperty) return const report = this.report.bind(this) verifyUndefProperties(this.defineProperties, references, null) @@ -206,6 +209,10 @@ module.exports = { } }) } + + markAsHasUnknownProperty() { + this.hasUnknownProperty = true + } } /** @type {Map} */ @@ -280,6 +287,10 @@ module.exports = { const ctx = getVueComponentContext(programNode) for (const prop of props) { + if (prop.type === 'unknown') { + ctx.markAsHasUnknownProperty() + return + } if (!prop.propName) { continue } diff --git a/tests/lib/rules/no-undef-properties.js b/tests/lib/rules/no-undef-properties.js index 8b8ebbb1d..9a97fe1a9 100644 --- a/tests/lib/rules/no-undef-properties.js +++ b/tests/lib/rules/no-undef-properties.js @@ -6,6 +6,9 @@ const RuleTester = require('eslint').RuleTester const rule = require('../../../lib/rules/no-undef-properties') +const { + getTypeScriptFixtureTestOptions +} = require('../../test-utils/typescript') const tester = new RuleTester({ parser: require.resolve('vue-eslint-parser'), @@ -535,6 +538,26 @@ tester.run('no-undef-properties', rule, { }, }; ` + }, + + { + // unknown type + filename: 'test.vue', + code: ` + + + `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + } } ], @@ -1129,6 +1152,30 @@ tester.run('no-undef-properties', rule, { column: 46 } ] + }, + + { + // known type + filename: 'test.vue', + code: ` + + + `, + ...getTypeScriptFixtureTestOptions(), + errors: [ + { + message: "'unknown' is not defined.", + line: 11 + } + ] } ] }) From 15f703262485d6bd7db6e3c0bff3228b39d32036 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Mon, 22 May 2023 22:17:39 +0900 Subject: [PATCH 6/6] 9.14.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 765d6c36b..ab4d9b718 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-vue", - "version": "9.13.0", + "version": "9.14.0", "description": "Official ESLint plugin for Vue.js", "main": "lib/index.js", "scripts": {