123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- 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}'],
- rules: {
- '@typescript-eslint/ban-ts-comment': 'off', // 彻底关闭 ts-comment 警告
- },
- },
- 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,
- // 添加全局变量
- defineOptions: 'readonly', // 允许使用 defineOptions
- },
- parserOptions: {
- ecmaFeatures: {
- jsx: true,
- },
- },
- },
- linterOptions: {
- reportUnusedDisableDirectives: false,
- },
- },
- // Vue规则配置
- pluginVue.configs['flat/essential'],
- pluginVue.configs['flat/strongly-recommended'],
- eslintConfigPrettier,
- {
- rules: {
- // 禁用烦人的 ts-comment 警告
- '@typescript-eslint/ban-ts-comment': 'off',
- // Vue特定规则
- 'vue/multi-word-component-names': 'off', // 关闭组件名必须是多词的规则
- 'vue/first-attribute-linebreak': 'off', // 关闭属性换行规则
- 'vue/no-unused-vars': 'off', // 关闭未使用变量的警告
- 'vue/html-self-closing': 'off', // 关闭要求HTML元素自闭合的规则
- 'vue/max-attributes-per-line': 'off', // 关闭每行最大属性数量限制
- 'vue/require-default-prop': 'off', // 关闭props必须有默认值的要求
- 'vue/attribute-hyphenation': 'off', // 关闭属性必须使用连字符的要求
- 'vue/no-reserved-component-names': 'off', // 关闭组件名称限制(允许使用Dialog等HTML保留名称)
- 'vue/operator-linebreak': 'off',
- 'vue/singleline-html-element-content-newline': 'off',
- 'vue/no-v-model-argument': 'off',
- 'vue/require-prop-types': 'off',
- 'vue/quote-props': 'off',
- 'vue/no-irregular-whitespace': 'off',
- 'vue/prop-name-casing': 'off',
- 'vue/html-indent': 'off',
- // 通用规则
- 'no-console': 'off', // 关闭控制台语句的警告
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- '@typescript-eslint/no-require-imports': 'off', // 允许 require 导入
- '@typescript-eslint/ban-ts-comment': 'off', // 完全关闭 ts-comment 警告
- 'prefer-const': 'warn', // 将never reassigned的let改为warning而不是error
- '@typescript-eslint/no-unused-expressions': [
- 'error',
- {
- allowShortCircuit: true,
- allowTernary: false,
- allowTaggedTemplates: false,
- },
- ],
- },
- },
- // TypeScript规则配置
- vueTsConfigs.recommended,
- {
- rules: {
- '@typescript-eslint/ban-ts-comment': 'off', // 彻底关闭 ts-comment 警告
- '@typescript-eslint/explicit-function-return-type': 'off',
- '@typescript-eslint/explicit-module-boundary-types': 'off',
- '@typescript-eslint/no-explicit-any': 'off', // 关闭 any 类型的警告
- '@typescript-eslint/no-unused-vars': 'off', // 关闭未使用变量的警告
- '@typescript-eslint/no-unsafe-function-type': 'off', // 关闭Function类型警告
- },
- },
- );
|