1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
| // const config = require('./.prettierrc');
|
| module.exports = {
| root: true,
| env: {
| // browser: true,
| // es2021: true,
| node: true,
| },
| globals: {
| // Ref sugar (take 2)
| $: 'readonly',
| $$: 'readonly',
| $ref: 'readonly',
| $shallowRef: 'readonly',
| $computed: 'readonly',
|
| // index.d.ts
| // global.d.ts
| Fn: 'readonly',
| PromiseFn: 'readonly',
| RefType: 'readonly',
| LabelValueOptions: 'readonly',
| EmitType: 'readonly',
| TargetContext: 'readonly',
| ComponentElRef: 'readonly',
| ComponentRef: 'readonly',
| ElRef: 'readonly',
| global: 'readonly',
| ComponentRoutes: 'readonly',
| ValueOf: 'readonly',
|
| // script setup
| defineProps: 'readonly',
| defineEmits: 'readonly',
| defineExpose: 'readonly',
| withDefaults: 'readonly',
| defineOptions: 'readonly',
| ITableCol: 'readonly',
| ITableBtn: 'readonly',
| API: true,
| PropType: true,
| OperationBtnType: true,
| EChartsOption: true,
| WeMapModel: true,
| },
|
| extends: [
| 'eslint:recommended',
| 'plugin:vue/vue3-essential',
| 'plugin:@typescript-eslint/recommended',
|
| 'prettier', //?
| '@vue/prettier', // @vue/eslint-config-prettier
| '@vue/eslint-config-typescript',
| './.eslintrc-auto-import.json',
| ],
| overrides: [],
|
| parser: 'vue-eslint-parser',
| parserOptions: {
| parser: '@typescript-eslint/parser',
| ecmaVersion: 'latest',
| sourceType: 'module',
| jsxPragma: 'React',
| ecmaFeatures: {
| jsx: true,
| },
| },
|
| plugins: ['vue', '@typescript-eslint', 'prettier'],
| // prettier: eslint-plugin-prettier
| rules: {
| // eslint-plugin-prettier
| 'prettier/prettier': [
| 'error',
| {
| // 一行最多 100 字符
| printWidth: 100,
| // 使用 4 个空格缩进
| tabWidth: 2,
| // 不使用缩进符,而使用空格
| useTabs: false,
| // 行尾不需要有分号
| semi: true,
| // 使用单引号
| singleQuote: true,
| // 对象的 key 仅在必要时用引号
| quoteProps: 'as-needed',
| // jsx 不使用单引号,而使用双引号
| jsxSingleQuote: false,
| // 尾随逗号
| trailingComma: 'es5',
| // 大括号内的首尾需要空格
| bracketSpacing: true,
| // jsx 标签的反尖括号需要换行
| jsxBracketSameLine: false,
| // 箭头函数,只有一个参数的时候,也需要括号
| arrowParens: 'always',
| // 每个文件格式化的范围是文件的全部内容
| rangeStart: 0,
| rangeEnd: Infinity,
| // 不需要写文件开头的 @prettier
| requirePragma: false,
| // 不需要自动在文件开头插入 @prettier
| insertPragma: false,
| // 使用默认的折行标准
| proseWrap: 'preserve',
| // 根据显示样式决定 html 要不要折行
| htmlWhitespaceSensitivity: 'css',
| // 换行符使用 lf
| endOfLine: 'auto',
| },
| ],
|
| // 自定义规则
|
| 'no-debugger': 'error',
| 'comma-dangle': [
| 'error',
| {
| arrays: 'always-multiline',
| objects: 'always-multiline',
| imports: 'always-multiline',
| exports: 'always-multiline',
| functions: 'never',
| },
| ],
| 'vue/no-use-v-if-with-v-for': 0,
| // 'vue/no-use-v-if-with-v-for': [
| // 'error',
| // {
| // allowUsingIterationVar: true,
| // },
| // ],
| 'vue/multi-word-component-names': 'off',
| '@typescript-eslint/no-explicit-any': ['off'], //禁止使用any
| '@typescript-eslint/explicit-module-boundary-types': 'off', // setup()
| '@typescript-eslint/ban-types': 'off',
| '@typescript-eslint/ban-ts-comment': 'off',
| '@typescript-eslint/no-empty-function': 'off',
| '@typescript-eslint/no-non-null-assertion': 'off',
| '@typescript-eslint/no-namespace': 'off',
| '@typescript-eslint/no-var-requires': 'off',
| // note you must disable the base rule as it can report incorrect errors
| '@typescript-eslint/no-unused-vars': [
| 'warn',
| {
| argsIgnorePattern: '^_',
| varsIgnorePattern: '^_',
| },
| ],
| 'no-unused-vars': [
| 'warn',
| {
| argsIgnorePattern: '^_',
| varsIgnorePattern: '^_',
| },
| ],
| eqeqeq: 2, //必须使用全等
| 'max-lines': ['error', 750], //限制行数 请勿修改 请优化你的代码
| complexity: ['error', 18], // 限制复杂度
| 'require-await': 'error',
| 'no-useless-catch': 0,
| 'no-empty': 0,
| 'no-async-promise-executor': 0,
| 'prefer-const': 0,
| },
| };
|
|