|
| 1 | +module.exports = { |
| 2 | + parser: 'vue-eslint-parser', |
| 3 | + parserOptions: { |
| 4 | + parser: '@typescript-eslint/parser', |
| 5 | + sourceType: 'module', |
| 6 | + ecmaFeatures: { |
| 7 | + jsx: true, |
| 8 | + tsx: true |
| 9 | + } |
| 10 | + }, |
| 11 | + env: { |
| 12 | + browser: true, |
| 13 | + node: true |
| 14 | + }, |
| 15 | + plugins: ['@typescript-eslint'], |
| 16 | + extends: ['plugin:@typescript-eslint/recommended', 'plugin:vue/vue3-recommended'], |
| 17 | + rules: { |
| 18 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 19 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 20 | + '@typescript-eslint/no-explicit-any': 'off', |
| 21 | + '@typescript-eslint/no-var-requires': 'off', |
| 22 | + '@typescript-eslint/no-empty-function': 'off', |
| 23 | + 'vue/custom-event-name-casing': 'off', |
| 24 | + 'no-use-before-define': 'off', |
| 25 | + '@typescript-eslint/no-use-before-define': 'off', |
| 26 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 27 | + '@typescript-eslint/ban-types': 'off', |
| 28 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 29 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 30 | + 'vue/html-indent': ['error', 4], |
| 31 | + indent: ['error', 4], // 4行缩进 |
| 32 | + 'vue/script-indent': ['error', 4], |
| 33 | + quotes: ['error', 'single'], // 单引号 |
| 34 | + 'vue/html-quotes': ['error', 'single'], |
| 35 | + semi: ['error', 'never'], // 禁止使用分号 |
| 36 | + 'space-infix-ops': ['error', { int32Hint: false }], // 要求操作符周围有空格 |
| 37 | + 'no-multi-spaces': 'error', // 禁止多个空格 |
| 38 | + 'no-whitespace-before-property': 'error', // 禁止在属性前使用空格 |
| 39 | + 'space-before-blocks': 'error', // 在块之前强制保持一致的间距 |
| 40 | + 'space-before-function-paren': ['error', 'never'], // 在“ function”定义打开括号之前强制不加空格 |
| 41 | + 'space-in-parens': ['error', 'never'], // 强制括号左右的不加空格 |
| 42 | + 'space-infix-ops': 'error', // 运算符之间留有间距 |
| 43 | + 'spaced-comment': ['error', 'always'], // 注释间隔 |
| 44 | + 'template-tag-spacing': ['error', 'always'], // 在模板标签及其文字之间需要空格 |
| 45 | + 'no-var': 'error', |
| 46 | + 'prefer-destructuring': [ |
| 47 | + 'error', |
| 48 | + { |
| 49 | + // 优先使用数组和对象解构 |
| 50 | + array: true, |
| 51 | + object: true |
| 52 | + }, |
| 53 | + { |
| 54 | + enforceForRenamedProperties: false |
| 55 | + } |
| 56 | + ], |
| 57 | + 'comma-dangle': ['error', 'never'], // 最后一个属性不允许有逗号 |
| 58 | + 'arrow-spacing': 'error', // 箭头函数空格 |
| 59 | + 'prefer-template': 'error', |
| 60 | + 'template-curly-spacing': 'error', |
| 61 | + 'quote-props': ['error', 'as-needed'], // 对象字面量属性名称使用引号 |
| 62 | + 'object-curly-spacing': ['error', 'always'], // 强制在花括号中使用一致的空格 |
| 63 | + 'no-unneeded-ternary': 'error', // 禁止可以表达为更简单结构的三元操作符 |
| 64 | + 'no-restricted-syntax': ['error', 'WithStatement', 'BinaryExpression[operator="in"]'], // 禁止with/in语句 |
| 65 | + 'no-lonely-if': 'error', // 禁止 if 语句作为唯一语句出现在 else 语句块中 |
| 66 | + 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }], // 要求方法链中每个调用都有一个换行符 |
| 67 | + // 路径别名设置 |
| 68 | + 'no-submodule-imports': ['off', '/@'], |
| 69 | + 'no-implicit-dependencies': ['off', ['/@']], |
| 70 | + '@typescript-eslint/no-explicit-any': 'off' // 类型可以使用any |
| 71 | + } |
| 72 | +} |
0 commit comments