|
| 1 | +/* eslint-env node */ |
| 2 | +require('@rushstack/eslint-patch/modern-module-resolution') // 这个库是用来解决monoRep可能出现的问题的,后期可以考虑把项目转成monoRep |
| 3 | + |
| 4 | +// https://cn.eslint.org/docs/rules/ |
| 5 | +/* |
| 6 | + * "off"或者0,不启用这个规则 |
| 7 | + * "warn"或者1,出现问题会有警告 |
| 8 | + * "error"或者2,出现问题会报错 |
| 9 | + * --------------------------- |
| 10 | + * extends 直接应用别人的规范,包括其parser,overrides,rules等等 |
| 11 | + * plugin 引入别人新增的规则,具体是否开启要在rules中自己配置。 |
| 12 | + */ |
| 13 | + |
| 14 | +module.exports = { |
| 15 | + root: true, |
| 16 | + env: { |
| 17 | + browser: true, |
| 18 | + node: true, |
| 19 | + es6: true, |
| 20 | + }, |
| 21 | + extends: [ |
| 22 | + 'eslint:recommended', |
| 23 | + 'plugin:vue/vue3-essential', |
| 24 | + 'plugin:vue/recommended', |
| 25 | + 'plugin:@typescript-eslint/eslint-recommended', // 使用推荐的规则,来自@typescript-eslint/eslint-plugin |
| 26 | + 'plugin:prettier/recommended', // prettier配置 关闭 ESLint 中与 Prettier 中会发生冲突的规则 |
| 27 | + ], |
| 28 | + globals: { |
| 29 | + // script setup |
| 30 | + defineProps: 'readonly', |
| 31 | + defineEmits: 'readonly', |
| 32 | + defineExpose: 'readonly', |
| 33 | + defineOptions: 'readonly', |
| 34 | + withDefaults: 'readonly', |
| 35 | + NodeJS: 'readonly', |
| 36 | + }, |
| 37 | + plugins: [ |
| 38 | + '@typescript-eslint', |
| 39 | + 'simple-import-sort', // import和export排序 |
| 40 | + 'prettier', // 将 Prettier 的规则设置到 ESLint 的规则中 |
| 41 | + ], |
| 42 | + parserOptions: { |
| 43 | + parser: { |
| 44 | + js: 'espree', |
| 45 | + jsx: 'espree', |
| 46 | + ts: '@typescript-eslint/parser', |
| 47 | + tsx: '@typescript-eslint/parser', |
| 48 | + // Leave the template parser unspecified, so that it could be determined by `<script lang="...">` |
| 49 | + }, |
| 50 | + extraFileExtensions: ['.vue'], // .vue文件将被这个parser解析 |
| 51 | + ecmaVersion: 'latest', // es使用最新版本语法解析 |
| 52 | + sourceType: 'module', // esm,允许import和export |
| 53 | + ecmaFeatures: { |
| 54 | + jsx: true, |
| 55 | + tsx: true, |
| 56 | + }, |
| 57 | + }, |
| 58 | + parser: 'vue-eslint-parser', |
| 59 | + overrides: [ |
| 60 | + { |
| 61 | + files: ['*.ts', '*.tsx', '*.vue'], |
| 62 | + rules: { |
| 63 | + // The core 'no-unused-vars' rules (in the eslint:recommeded ruleset) |
| 64 | + // does not work with type definitions |
| 65 | + 'no-unused-vars': 'off', |
| 66 | + '@typescript-eslint/no-unused-vars': 'warn', |
| 67 | + }, |
| 68 | + }, |
| 69 | + ], |
| 70 | + |
| 71 | + rules: { |
| 72 | + 'simple-import-sort/imports': 'error', // import sort排序 |
| 73 | + 'simple-import-sort/exports': 'error', // export sort排序 |
| 74 | + 'vue/multi-word-component-names': 0, // 组件名多单词 |
| 75 | + 'vue/no-multiple-template-root': 'off', // v3支持多个根组件了,这个规则主要是针对v2的 |
| 76 | + 'vue/no-v-model-argument': 'off', // 禁止使用v-model的参数 eg: v-model:argName = 'argValue' |
| 77 | + 'vue/no-dupe-keys': 'off', |
| 78 | + '@typescript-eslint/consistent-type-imports': 'off', |
| 79 | + // 'import-type': 'error', |
| 80 | + // 'vue/custom-event-name-casing': 'off', |
| 81 | + // 'vue/require-default-prop': 'off', |
| 82 | + // 'vue/require-prop-types': 'off', |
| 83 | + // 'vue/define-component': 'off', |
| 84 | + }, |
| 85 | +} |
0 commit comments