From 8962133cb944c13424284aabd70e2383105d526d Mon Sep 17 00:00:00 2001 From: Dtsiantaris <44876922+Dtsiantaris@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:54:48 +0200 Subject: [PATCH] fix(create-quasar): correctly configure typescript-eslint/consistent-type-imports rule (#17760) --- .../ts-vite-2/eslint/_eslint.config.js | 17 +++++++++++------ .../ts-webpack-4/eslint/_eslint.config.js | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/create-quasar/templates/app/quasar-v2/ts-vite-2/eslint/_eslint.config.js b/create-quasar/templates/app/quasar-v2/ts-vite-2/eslint/_eslint.config.js index be00b6fc289..24320bf8e41 100644 --- a/create-quasar/templates/app/quasar-v2/ts-vite-2/eslint/_eslint.config.js +++ b/create-quasar/templates/app/quasar-v2/ts-vite-2/eslint/_eslint.config.js @@ -35,14 +35,23 @@ export default [ */ ...pluginVue.configs[ 'flat/essential' ], + { + files: ['**/*.ts', '**/*.vue'], + rules: { + '@typescript-eslint/consistent-type-imports': [ + 'error', + { prefer: 'type-imports' } + ], + } + }, // https://github.com/vuejs/eslint-config-typescript ...vueTsEslintConfig({ // Optional: extend additional configurations from typescript-eslint'. // Supports all the configurations in // https://typescript-eslint.io/users/configs#recommended-configurations extends: [ - // By default, only the recommended rules are enabled. - 'recommended' + // By default, only the 'recommendedTypeChecked' rules are enabled. + 'recommendedTypeChecked' // You can also manually enable the stylistic rules. // "stylistic", @@ -71,10 +80,6 @@ export default [ // add your custom rules here rules: { 'prefer-promise-reject-errors': 'off', - '@typescript-eslint/consistent-type-imports': [ - 'error', - { prefer: 'type-imports' } - ], // allow debugger during development only 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' diff --git a/create-quasar/templates/app/quasar-v2/ts-webpack-4/eslint/_eslint.config.js b/create-quasar/templates/app/quasar-v2/ts-webpack-4/eslint/_eslint.config.js index f1655326e50..1da668fd247 100644 --- a/create-quasar/templates/app/quasar-v2/ts-webpack-4/eslint/_eslint.config.js +++ b/create-quasar/templates/app/quasar-v2/ts-webpack-4/eslint/_eslint.config.js @@ -35,14 +35,24 @@ export default [ */ ...pluginVue.configs[ 'flat/essential' ], + // this rule needs to be above the vueTsEslintConfig to avoid error: 'You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file.' + { + files: ['**/*.ts', '**/*.vue'], + rules: { + '@typescript-eslint/consistent-type-imports': [ + 'error', + { prefer: 'type-imports' } + ], + } + }, // https://github.com/vuejs/eslint-config-typescript ...vueTsEslintConfig({ // Optional: extend additional configurations from typescript-eslint'. // Supports all the configurations in // https://typescript-eslint.io/users/configs#recommended-configurations extends: [ - // By default, only the recommended rules are enabled. - 'recommended' + // By default, only the 'recommendedTypeChecked' rules are enabled. + 'recommendedTypeChecked' // You can also manually enable the stylistic rules. // "stylistic", @@ -71,10 +81,6 @@ export default [ // add your custom rules here rules: { 'prefer-promise-reject-errors': 'off', - '@typescript-eslint/consistent-type-imports': [ - 'error', - { prefer: 'type-imports' } - ], // allow debugger during development only 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'