From 6c58f1a24d8f675356fe0adec6730e52f6082616 Mon Sep 17 00:00:00 2001 From: lihongda03 Date: Sat, 10 Sep 2022 23:50:34 +0800 Subject: [PATCH 1/3] fix(no-undef-components): report error on type-only imports --- lib/rules/no-undef-components.js | 13 +++- tests/lib/rules/no-undef-components.js | 60 +++++++++++++++++++ .../util-types/ast/es-ast.ts | 1 + typings/eslint/index.d.ts | 3 + 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/lib/rules/no-undef-components.js b/lib/rules/no-undef-components.js index f6e66400c..dc58fd2e9 100644 --- a/lib/rules/no-undef-components.js +++ b/lib/rules/no-undef-components.js @@ -50,7 +50,9 @@ module.exports = { } ], messages: { - undef: "The '<{{name}}>' component has been used, but not defined." + undef: "The '<{{name}}>' component has been used, but not defined.", + typeOnly: + "The '<{{name}}>' component has been used, but '{{name}}' only refers to a type." } }, /** @param {RuleContext} context */ @@ -121,6 +123,7 @@ module.exports = { // For + + + `, + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + parser: require.resolve('@typescript-eslint/parser') + }, + parser: require.resolve('vue-eslint-parser'), + errors: [ + { + message: + "The '' component has been used, but 'Foo' only refers to a type.", + line: 12 + }, + { + message: + "The '' component has been used, but 'HelloWorld1' only refers to a type.", + line: 13 + }, + { + message: + "The '' component has been used, but 'HelloWorld2' only refers to a type.", + line: 14 + }, + { + message: + "The '' component has been used, but 'HelloWorld3' only refers to a type.", + line: 15 + }, + { + message: + "The '' component has been used, but 'HelloWorld4' only refers to a type.", + line: 16 + }, + { + message: + "The '' component has been used, but 'HelloWorld5' only refers to a type.", + line: 17 + } + ] + }, // options API { diff --git a/typings/eslint-plugin-vue/util-types/ast/es-ast.ts b/typings/eslint-plugin-vue/util-types/ast/es-ast.ts index 16a734d2e..f4dd208c3 100644 --- a/typings/eslint-plugin-vue/util-types/ast/es-ast.ts +++ b/typings/eslint-plugin-vue/util-types/ast/es-ast.ts @@ -268,6 +268,7 @@ export interface ImportDeclaration extends HasParentNode { | ImportNamespaceSpecifier )[] source: Literal & { value: string } + importKind?: 'type' | 'value' } export interface ImportSpecifier extends HasParentNode { type: 'ImportSpecifier' diff --git a/typings/eslint/index.d.ts b/typings/eslint/index.d.ts index 7bfda0245..949d56f6d 100644 --- a/typings/eslint/index.d.ts +++ b/typings/eslint/index.d.ts @@ -54,6 +54,9 @@ export namespace Scope { eslintExplicitGlobal?: boolean | undefined eslintExplicitGlobalComments?: Comment[] | undefined eslintImplicitGlobalSetting?: 'readonly' | 'writable' | undefined + + isTypeVariable?: boolean + isValueVariable?: boolean } interface Reference { identifier: VAST.Identifier From 055b5896814a7fd806c1b6e4a49aaff8fdaa904e Mon Sep 17 00:00:00 2001 From: Amorites <751809522@qq.com> Date: Sun, 11 Sep 2022 21:01:17 +0800 Subject: [PATCH 2/3] chore: support optional chaining operator in vuepress --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 40f2ceeee..cbaefbd88 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2020", + "target": "ES2019", "module": "commonjs", "lib": ["es2020"], "allowJs": true, From 3c5ec6474a7a23ab12c65d005f20412e2fb2d5d9 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Tue, 13 Sep 2022 20:55:53 +0200 Subject: [PATCH 3/3] Lint --- tests/lib/rules/no-undef-components.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/lib/rules/no-undef-components.js b/tests/lib/rules/no-undef-components.js index c41caef9c..fc3461e5a 100644 --- a/tests/lib/rules/no-undef-components.js +++ b/tests/lib/rules/no-undef-components.js @@ -667,10 +667,10 @@ tester.run('no-undef-components', rule, {