123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import {
- defineConfigWithVueTs,
- vueTsConfigs,
- } from '@vue/eslint-config-typescript';
- import pluginVue from 'eslint-plugin-vue';
- import { globalIgnores } from 'eslint/config';
- import globals from 'globals';
- import eslintConfigPrettier from 'eslint-config-prettier';
- // 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/**',
-
- // 依赖
- '**/node_modules/**',
-
- // Git相关
- '**/.git/**',
-
- // 缓存目录
- '**/.cache/**',
- '**/.temp/**',
- '**/.eslintcache',
-
- // 编辑器目录和文件
- '**/.vscode/**',
- '**/.idea/**',
- '**/*.suo',
- '**/*.ntvs*',
- '**/*.njsproj',
- '**/*.sln',
- '**/*.sw?',
-
- // 配置文件
- '**/*.config.js',
- '**/*.config.ts',
- '**/*.config.mjs',
- '**/*.config.cjs',
- '**/rspack.*.js',
- '**/rspack.*.ts',
- '**/vite.*.js',
- '**/vite.*.ts',
-
- // 环境文件
- '**/.env*',
- '!**/.env.example',
-
- // 包管理器文件
- '**/pnpm-lock.yaml',
- '**/package-lock.json',
- '**/yarn.lock',
-
- // 历史文件
- '**/.history/**',
-
- // 日志文件
- '**/*.log',
- '**/npm-debug.log*',
- '**/yarn-debug.log*',
- '**/yarn-error.log*',
- '**/pnpm-debug.log*',
-
- // 系统文件
- '**/.DS_Store',
- '**/Thumbs.db'
- ]),
- {
- languageOptions: {
- globals: {
- ...globals.browser,
- ...globals.node,
- }
- }
- },
- // Vue规则配置
- pluginVue.configs['flat/essential'],
- pluginVue.configs['flat/strongly-recommended'],
- eslintConfigPrettier,
- {
- rules: {
- // Vue特定规则
- 'vue/multi-word-component-names': 'warn',
- 'vue/no-unused-vars': 'warn',
- 'vue/html-self-closing': ['warn', {
- html: {
- void: 'always',
- normal: 'always',
- component: 'always'
- }
- }],
- 'vue/max-attributes-per-line': ['warn', {
- singleline: 3,
- multiline: 1
- }],
- // 通用规则
- 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- '@typescript-eslint/no-require-imports': 'error',
- }
- },
- // TypeScript规则配置
- vueTsConfigs.recommended,
- {
- rules: {
- '@typescript-eslint/explicit-function-return-type': 'off',
- '@typescript-eslint/explicit-module-boundary-types': 'off',
- '@typescript-eslint/no-explicit-any': 'warn',
- '@typescript-eslint/no-unused-vars': ['warn', {
- argsIgnorePattern: '^_',
- varsIgnorePattern: '^_'
- }],
- }
- },
- );
|