From af37e73260ef73c03c05f95048fa2484c3c9ab9a Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 5 Apr 2025 08:13:49 +0800 Subject: [PATCH] feat: use Vue official ESLint template --- template-eslint/vue-js/eslint.config.mjs | 15 ++++++++---- template-eslint/vue-ts/eslint.config.mjs | 31 +++++++++++++++--------- template-eslint/vue-ts/package.json | 1 - 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/template-eslint/vue-js/eslint.config.mjs b/template-eslint/vue-js/eslint.config.mjs index 9030a6b..04c0b47 100644 --- a/template-eslint/vue-js/eslint.config.mjs +++ b/template-eslint/vue-js/eslint.config.mjs @@ -1,10 +1,15 @@ import js from '@eslint/js'; -import vue from 'eslint-plugin-vue'; +import pluginVue from 'eslint-plugin-vue'; +import { defineConfig, globalIgnores } from 'eslint/config'; import globals from 'globals'; -export default [ +export default defineConfig([ + { + name: 'app/files-to-lint', + files: ['**/*.{js,mjs,jsx,vue}'], + }, + globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']), { languageOptions: { globals: globals.browser } }, js.configs.recommended, - ...vue.configs['flat/essential'], - { ignores: ['dist/'] }, -]; + ...pluginVue.configs['flat/essential'], +]); diff --git a/template-eslint/vue-ts/eslint.config.mjs b/template-eslint/vue-ts/eslint.config.mjs index 4ba01b2..f78981a 100644 --- a/template-eslint/vue-ts/eslint.config.mjs +++ b/template-eslint/vue-ts/eslint.config.mjs @@ -1,14 +1,23 @@ -import js from '@eslint/js'; -import vue from 'eslint-plugin-vue'; +import { + defineConfigWithVueTs, + vueTsConfigs, +} from '@vue/eslint-config-typescript'; +import pluginVue from 'eslint-plugin-vue'; +import { globalIgnores } from 'eslint/config'; import globals from 'globals'; -import ts from 'typescript-eslint'; -import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'; -export default [ +// To allow more languages other than `ts` in `.vue` files, uncomment the following lines: +// import { configureVueProject } from '@vue/eslint-config-typescript' +// configureVueProject({ scriptLangs: ['ts', 'tsx'] }) +// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup + +export default defineConfigWithVueTs( + { + name: 'app/files-to-lint', + files: ['**/*.{ts,mts,tsx,vue}'], + }, + globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']), { languageOptions: { globals: globals.browser } }, - js.configs.recommended, - ...ts.configs.recommended, - ...vue.configs['flat/essential'], - ...defineConfigWithVueTs(vueTsConfigs.recommended), - { ignores: ['dist/'] }, -]; + pluginVue.configs['flat/essential'], + vueTsConfigs.recommended, +); diff --git a/template-eslint/vue-ts/package.json b/template-eslint/vue-ts/package.json index db0bb98..606394e 100644 --- a/template-eslint/vue-ts/package.json +++ b/template-eslint/vue-ts/package.json @@ -6,7 +6,6 @@ "lint": "eslint ." }, "devDependencies": { - "@eslint/js": "^9.23.0", "@vue/eslint-config-typescript": "^14.5.0", "eslint": "^9.23.0", "eslint-plugin-vue": "^10.0.0",