-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path.eslintrc.cjs
71 lines (71 loc) · 1.92 KB
/
.eslintrc.cjs
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
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
env: {
node: true,
browser: true,
es6: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
// ES2021 syntax support
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
// Enable JSX parsing
jsx: true,
},
},
globals: {
// For browser-based globals
window: 'readonly',
document: 'readonly',
Edit: 'writable',
console: 'writable',
_: 'writable',
$: 'writable',
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:import-x/recommended',
'plugin:import-x/typescript',
// Make prettier as the last item in the extends array, so that it has the opportunity to override other configs
'plugin:prettier/recommended',
],
settings: {
react: {
version: 'detect',
},
// 因为默认的 eslint-plugin-import 只支持 js 和 jsx,对于 ts 和 tsx 需要加下面这两个配置,
'import-x/parsers': {
// 使用 TypeScript parser
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
// https://devrsi0n.com/articles/eslint-typescript-import-unsolve
'import-x/resolver': {
typescript: true,
node: true,
},
},
rules: {
'@typescript-eslint/no-unused-vars': 'warn',
'react/jsx-curly-brace-presence': 'warn',
'react/jsx-no-leaked-render': 'warn',
quotes: ['warn', 'single'],
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
'prettier/prettier': 'warn',
'react-hooks/exhaustive-deps': 'warn',
'react/no-unstable-nested-components': ['warn', { allowAsProps: true }],
// 导入类型时需添加 type 修饰符
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
},
],
},
};