|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + env: { |
| 4 | + browser: true, |
| 5 | + node: true, |
| 6 | + es2021: true, |
| 7 | + }, |
| 8 | + parser: 'vue-eslint-parser', |
| 9 | + extends: [ |
| 10 | + 'eslint:recommended', |
| 11 | + 'plugin:vue/vue3-recommended', |
| 12 | + 'plugin:@typescript-eslint/recommended', |
| 13 | + 'plugin:prettier/recommended', |
| 14 | + // eslint-config-prettier 的缩写 |
| 15 | + 'prettier', |
| 16 | + 'vue-global-api', |
| 17 | + '.eslintrc-auto-import.json', |
| 18 | + ], |
| 19 | + parserOptions: { |
| 20 | + ecmaVersion: 12, |
| 21 | + parser: '@typescript-eslint/parser', |
| 22 | + sourceType: 'module', |
| 23 | + }, |
| 24 | + // eslint-plugin-vue @typescript-eslint/eslint-plugin eslint-plugin-prettier的缩写 |
| 25 | + plugins: ['vue', '@typescript-eslint', 'prettier', 'import', 'simple-import-sort'], |
| 26 | + rules: { |
| 27 | + 'simple-import-sort/imports': 'error', |
| 28 | + 'simple-import-sort/exports': 'error', |
| 29 | + 'vue/no-multiple-template-root': 'off', // 解决template中最顶层只能返回一个元素的检测报错 |
| 30 | + 'import/no-unresolved': [ |
| 31 | + // 解决无法识别问题 |
| 32 | + 2, |
| 33 | + { |
| 34 | + ignore: ['./'], |
| 35 | + }, |
| 36 | + ], |
| 37 | + 'import/no-extraneous-dependencies': ['error', { devDependencies: true }], // 解决依赖问题 |
| 38 | + 'no-param-reassign': [ |
| 39 | + // 解决不能直接修改参数问题 |
| 40 | + 'error', |
| 41 | + { |
| 42 | + props: true, |
| 43 | + ignorePropertyModificationsFor: ['request', 'res', 'response', 'state', 'config'], |
| 44 | + }, |
| 45 | + ], |
| 46 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 47 | + '@typescript-eslint/no-unused-vars': 'off', |
| 48 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 49 | + '@typescript-eslint/no-explicit-any': 'off', |
| 50 | + '@typescript-eslint/no-var-requires': 'off', |
| 51 | + '@typescript-eslint/no-empty-function': 'off', |
| 52 | + '@typescript-eslint/no-use-before-define': 'off', |
| 53 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 54 | + '@typescript-eslint/ban-types': 'off', |
| 55 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 56 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 57 | + 'no-var': 'error', |
| 58 | + 'prettier/prettier': 'error', |
| 59 | + // 禁止出现console |
| 60 | + // "no-console": "warn", |
| 61 | + // 禁用debugger |
| 62 | + // "no-debugger": "warn", |
| 63 | + // 禁止出现重复的 case 标签 |
| 64 | + 'no-duplicate-case': 'warn', |
| 65 | + // 禁止出现空语句块 |
| 66 | + 'no-empty': 'warn', |
| 67 | + // 禁止不必要的括号 |
| 68 | + 'no-extra-parens': 'off', |
| 69 | + // 禁止对 function 声明重新赋值 |
| 70 | + 'no-func-assign': 'warn', |
| 71 | + // 禁止在 return、throw、continue 和 break 语句之后出现不可达代码 |
| 72 | + 'no-unreachable': 'warn', |
| 73 | + // 强制所有控制语句使用一致的括号风格 |
| 74 | + // curly: 'warn', |
| 75 | + // 要求 switch 语句中有 default 分支 |
| 76 | + 'default-case': 'warn', |
| 77 | + // 强制尽可能地使用点号 |
| 78 | + 'dot-notation': 'warn', |
| 79 | + // 要求使用 === 和 !== |
| 80 | + eqeqeq: 'warn', |
| 81 | + // 禁止 if 语句中 return 语句之后有 else 块 |
| 82 | + 'no-else-return': 'warn', |
| 83 | + // 禁止出现空函数 |
| 84 | + 'no-empty-function': 'warn', |
| 85 | + // 禁用不必要的嵌套块 |
| 86 | + 'no-lone-blocks': 'warn', |
| 87 | + // 禁止使用多个空格 |
| 88 | + 'no-multi-spaces': 'warn', |
| 89 | + // 禁止多次声明同一变量 |
| 90 | + 'no-redeclare': 'off', |
| 91 | + '@typescript-eslint/no-redeclare': ['error'], |
| 92 | + // 禁止在 return 语句中使用赋值语句 |
| 93 | + 'no-return-assign': 'warn', |
| 94 | + // 禁用不必要的 return await |
| 95 | + 'no-return-await': 'warn', |
| 96 | + // 禁止自我赋值 |
| 97 | + 'no-self-assign': 'warn', |
| 98 | + // 禁止自身比较 |
| 99 | + 'no-self-compare': 'warn', |
| 100 | + // 禁止不必要的 catch 子句 |
| 101 | + 'no-useless-catch': 'warn', |
| 102 | + // 禁止多余的 return 语句 |
| 103 | + 'no-useless-return': 'warn', |
| 104 | + // 禁止变量声明与外层作用域的变量同名 |
| 105 | + 'no-shadow': 'off', |
| 106 | + // 允许delete变量 |
| 107 | + 'no-delete-var': 'off', |
| 108 | + // 强制数组方括号中使用一致的空格 |
| 109 | + 'array-bracket-spacing': 'warn', |
| 110 | + // 强制在代码块中使用一致的大括号风格 |
| 111 | + 'brace-style': 'warn', |
| 112 | + // 强制使用骆驼拼写法命名约定 |
| 113 | + // camelcase: 'warn', |
| 114 | + // 强制使用一致的缩进 |
| 115 | + indent: 'off', |
| 116 | + // 强制可嵌套的块的最大深度4 |
| 117 | + 'max-depth': 'warn', |
| 118 | + // 强制最大行数 300 |
| 119 | + // "max-lines": ["warn", { "max": 1200 }], |
| 120 | + // 强制函数最大代码行数 50 |
| 121 | + // 'max-lines-per-function': ['warn', { max: 70 }], |
| 122 | + // 强制函数块最多允许的的语句数量20 |
| 123 | + 'max-statements': ['warn', 100], |
| 124 | + // 强制回调函数最大嵌套深度 |
| 125 | + 'max-nested-callbacks': ['warn', 3], |
| 126 | + // 强制函数定义中最多允许的参数数量 |
| 127 | + 'max-params': ['warn', 3], |
| 128 | + // 强制每一行中所允许的最大语句数量 |
| 129 | + 'max-statements-per-line': ['warn', { max: 1 }], |
| 130 | + // 要求方法链中每个调用都有一个换行符 |
| 131 | + 'newline-per-chained-call': ['warn', { ignoreChainWithDepth: 3 }], |
| 132 | + // 禁止 if 作为唯一的语句出现在 else 语句中 |
| 133 | + 'no-lonely-if': 'warn', |
| 134 | + // 禁止空格和 tab 的混合缩进 |
| 135 | + 'no-mixed-spaces-and-tabs': 'warn', |
| 136 | + // 禁止出现多行空行 |
| 137 | + 'no-multiple-empty-lines': 'warn', |
| 138 | + // 禁止出现; |
| 139 | + semi: ['warn', 'never'], |
| 140 | + // 强制在块之前使用一致的空格 |
| 141 | + 'space-before-blocks': 'warn', |
| 142 | + // 强制在 function的左括号之前使用一致的空格 |
| 143 | + // 'space-before-function-paren': ['warn', 'never'], |
| 144 | + // 强制在圆括号内使用一致的空格 |
| 145 | + 'space-in-parens': 'warn', |
| 146 | + // 要求操作符周围有空格 |
| 147 | + 'space-infix-ops': 'warn', |
| 148 | + // 强制在一元操作符前后使用一致的空格 |
| 149 | + 'space-unary-ops': 'warn', |
| 150 | + // 强制在注释中 // 或 /* 使用一致的空格 |
| 151 | + // "spaced-comment": "warn", |
| 152 | + // 强制在 switch 的冒号左右有空格 |
| 153 | + 'switch-colon-spacing': 'warn', |
| 154 | + // 强制箭头函数的箭头前后使用一致的空格 |
| 155 | + 'arrow-spacing': 'warn', |
| 156 | + 'prefer-const': 'warn', |
| 157 | + 'prefer-rest-params': 'warn', |
| 158 | + 'no-useless-escape': 'warn', |
| 159 | + 'no-irregular-whitespace': 'warn', |
| 160 | + 'no-prototype-builtins': 'warn', |
| 161 | + 'no-fallthrough': 'warn', |
| 162 | + 'no-extra-boolean-cast': 'warn', |
| 163 | + 'no-case-declarations': 'warn', |
| 164 | + 'no-async-promise-executor': 'warn', |
| 165 | + }, |
| 166 | +} |
0 commit comments