/
index.ts
151 lines (150 loc) · 5.05 KB
/
index.ts
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
import eslintConfigPrettier from 'eslint-config-prettier';
export const eslint = {
$schema: 'https://json.schemastore.org/eslintrc',
extends: [
'eslint:recommended',
require.resolve('@umijs/lint/dist/config/eslint'),
'plugin:unicorn/recommended',
],
plugins: ['unicorn', 'import', 'unused-imports', 'simple-import-sort'],
rules: {
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-explicit-any': 0,
'import/first': 'error',
'no-empty': 'warn',
'no-extra-boolean-cast': 'warn',
'no-unused-vars': 0,
'react/display-name': 0,
'react/prop-types': 0,
'react/react-in-jsx-scope': 0,
'unicorn/explicit-length-check': 'warn',
'unicorn/filename-case': 0,
'unicorn/no-array-for-each': 'warn',
'unicorn/no-array-reduce': 0,
'unicorn/no-empty-file': 'warn',
'unicorn/no-negated-condition': 'warn',
'unicorn/no-nested-ternary': 0,
'unicorn/no-typeof-undefined': 'warn',
'unicorn/no-useless-undefined': 'warn',
'unicorn/prefer-code-point': 'warn',
'unicorn/prefer-logical-operator-over-ternary': 0,
'unicorn/prefer-module': 0,
// 禁用这条规则的原因 => https://github.com/yuntijs/lowcode-tools/commit/7c9e8e74841dceb44cbba6a9e0879fcf45b6511d#diff-93b5caf9c960ad24ccdb47d454518126952db3bd93941042f68ff2e9d7e3c7f1R39-R42
'unicorn/prefer-regexp-test': 0,
'unicorn/prefer-spread': 'warn',
'unicorn/prefer-string-replace-all': 'warn',
'unicorn/prefer-type-error': 'warn',
'unicorn/prevent-abbreviations': 0,
'unicorn/switch-case-braces': 'warn',
'unused-imports/no-unused-vars': [
'warn',
{ args: 'after-used', argsIgnorePattern: '^_', vars: 'all', varsIgnorePattern: '^_' },
],
// ~ change some rules to warn which can be automatically fixed by the `--fix` CLI option
'unicorn/better-regex': 'warn',
'unicorn/prefer-optional-catch-binding': 'warn',
'unicorn/catch-error-name': 'warn',
'unicorn/prefer-export-from': 'warn',
'unicorn/prefer-ternary': 'warn',
'unicorn/prefer-number-properties': 'warn',
'unicorn/no-lonely-if': 'warn',
'unused-imports/no-unused-imports': 'warn',
'unicorn/text-encoding-identifier-case': 'warn',
'unicorn/no-array-push-push': 'warn',
'unicorn/no-array-callback-reference': 'warn',
'unicorn/numeric-separators-style': 'warn',
'unicorn/prefer-at': 'warn',
'unicorn/no-useless-fallback-in-spread': 'warn',
'unicorn/prefer-date-now': 'warn',
'unicorn/consistent-function-scoping': 'warn',
'unicorn/no-unreadable-iife': 'warn',
'unicorn/prefer-query-selector': 'warn',
'unicorn/prefer-dom-node-append': 'warn',
'unicorn/prefer-dom-node-remove': 'warn',
'unicorn/prefer-add-event-listener': 'warn',
'unicorn/no-useless-promise-resolve-reject': 'warn',
'unicorn/no-useless-switch-case': 'warn',
'unicorn/prefer-set-has': 'warn',
'unicorn/prefer-string-slice': 'warn',
'unicorn/prefer-includes': 'warn',
'unicorn/escape-case': 'warn',
'no-param-reassign': ['warn'],
'simple-import-sort/exports': 'warn',
'@typescript-eslint/no-unused-expressions': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-use-before-define': 'warn',
'@typescript-eslint/no-empty-interface': 'warn',
'react/jsx-sort-props': 'warn',
'react/jsx-no-useless-fragment': 'off',
'array-callback-return': 'warn',
'guard-for-in': 'warn',
'import/newline-after-import': 'warn',
'import/no-duplicates': 'warn',
'react/no-unescaped-entities': 'warn',
'react/no-unknown-property': 'warn',
// ~ merge from eslint-config-tenx
'unicorn/prefer-node-protocol': 0,
'unicorn/consistent-destructuring': 0,
'unicorn/no-null': 0,
'unicorn/prefer-top-level-await': 0,
'strict': [0],
'no-sequences': [0],
'no-mixed-operators': [0],
'no-useless-escape': [0],
'indent': ['error', 2, { SwitchCase: 1 }],
'linebreak-style': ['error', 'unix'],
'quotes': ['error', 'single'],
'jsx-quotes': ['error', 'prefer-double'],
'semi': 'off',
'array-bracket-spacing': 'off',
'max-len': [
'error',
100,
{
comments: 100,
ignoreComments: true,
ignoreTrailingComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
'no-nested-ternary': ['error'],
'no-debugger': ['error'],
'no-console': [
'error',
{
allow: ['warn'],
},
],
'no-shadow': ['warn'],
'prefer-promise-reject-errors': [
'warn',
{
allowEmptyReject: true,
},
],
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-key': 'error',
...eslintConfigPrettier.rules,
},
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'no-undef': 'off',
'no-unused-expressions': 'off',
'no-shadow': 'off',
},
},
],
globals: {
__root__dirname: true,
Cookies: true,
fetchMock: true,
mockStore: true,
initStore: true,
},
};