diff --git a/lib/utils/index.js b/lib/utils/index.js index e784f2ab3..b302cd6cb 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -550,6 +550,12 @@ module.exports = { const isAppVueComponent = isObjectArgument(node) return isAppVueComponent } + if (callee.name === 'defineComponent') { + // for Vue.js 3.x + // defineComponent({}) + const isDestructedVueComponent = isObjectArgument(node) + return isDestructedVueComponent + } } } diff --git a/tests/lib/rules/no-dupe-keys.js b/tests/lib/rules/no-dupe-keys.js index 0844173f0..a3bc06e77 100644 --- a/tests/lib/rules/no-dupe-keys.js +++ b/tests/lib/rules/no-dupe-keys.js @@ -639,6 +639,44 @@ ruleTester.run('no-dupe-keys', rule, { message: 'Duplicated key \'foo\'.', line: 9 }] + }, + { + filename: 'test.js', + code: ` + defineComponent({ + foo: { + bar: String + }, + data: { + bar: null + }, + }) + `, + options: [{ groups: ['foo'] }], + parserOptions: { ecmaVersion: 6 }, + errors: [{ + message: 'Duplicated key \'bar\'.', + line: 7 + }] + }, + { + filename: 'test.js', + code: ` + export default defineComponent({ + foo: { + bar: String + }, + data: { + bar: null + }, + }) + `, + options: [{ groups: ['foo'] }], + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ + message: 'Duplicated key \'bar\'.', + line: 7 + }] } ] }) diff --git a/tests/lib/utils/vue-component.js b/tests/lib/utils/vue-component.js index 69d663e92..794075d47 100644 --- a/tests/lib/utils/vue-component.js +++ b/tests/lib/utils/vue-component.js @@ -311,6 +311,12 @@ function invalidTests (ext) { `, parserOptions, errors: (ext === 'js' ? [] : [makeError(2)]).concat([makeError(8)]) + }, + { + filename: `test.${ext}`, + code: `export default defineComponent({})`, + parserOptions, + errors: [makeError(1)] } ] }