-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy patheslint.config.mjs
196 lines (195 loc) · 6.61 KB
/
eslint.config.mjs
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// @ts-check
import eslint from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import pluginCypress from 'eslint-plugin-cypress/flat';
import pluginJest from 'eslint-plugin-jest';
import tseslint from 'typescript-eslint';
import reactPlugin from 'eslint-plugin-react';
import jsxA11y from 'eslint-plugin-jsx-a11y';
export default tseslint.config(
{
// eslint defaults
...eslint.configs.recommended,
ignores: [
'**/node_modules/',
'**/dist/',
'**/dist-lambdas/',
'**/*.js',
'**/build/',
'*.config.js',
'**/*_.js',
'scripts/archived/**/*',
],
},
{
// eslint default rules that we added. No plugin required.
rules: {
complexity: ['warn', { max: 20 }],
'eol-last': ['error', 'always'],
'id-denylist': ['error', /* 'error', 'err', 'cb', 'callback',*/ 'test'],
'max-lines': [
'error',
{ max: 700, skipBlankLines: true, skipComments: true },
],
'no-restricted-globals': [
'error',
{ name: 'error' },
{ name: 'event' },
{ name: 'status' },
{ name: 'name' },
{ name: 'document' },
],
'no-trailing-spaces': 'error',
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
'no-var': 'error',
'no-warning-comments': [
'error',
{ location: 'anywhere', terms: ['fixme', 'xxx'] },
],
'object-shorthand': 'warn',
'prefer-destructuring': [
'error',
{
AssignmentExpression: {
array: false,
object: true,
},
VariableDeclarator: {
array: false,
object: true,
},
},
{
enforceForRenamedProperties: false,
},
],
},
ignores: [
'**/node_modules/',
'**/dist/',
'**/dist-lambdas/',
'**/*.js',
'**/build/',
'*.config.js',
'**/*_.js',
'scripts/archived/**/*',
],
},
{
// jest configuration and recommendation
files: ['**/*.test.ts', '**/*.test.js'],
...pluginJest.configs['flat/recommended'],
},
{
// @ts-ignore
...reactPlugin.configs.flat.recommended, // React recommendations
rules: {
// @ts-ignore
...reactPlugin.configs.flat.recommended.rules,
'react/prop-types': 'warn', // Temporarily turned off. Ideally this is on so we enforce typed inputs.
},
},
jsxA11y.flatConfigs.recommended, // Accessibility recommendations
prettierConfig, // This config ignores formatting rules in the linter. Linters are not formatters.
pluginCypress.configs.recommended, // cypress recommendations
tseslint.configs.recommendedTypeChecked,
{
// Typescript specific rules. Most are turned off as we have not been using typescript for long enough.
languageOptions: {
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
projectService: {
allowDefaultProject: ['*.js', '*.mjs'],
},
tsconfigRootDir: import.meta.dirname,
ecmaFeatures: {
jsx: true,
},
},
},
ignores: [
'**/node_modules/',
'**/dist/',
'**/dist-lambdas/',
'**/*.js',
'**/build/',
'*.config.js',
'**/*_.js',
'scripts/archived/**/*',
],
rules: {
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-array-delete': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'off',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-misused-new': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: false,
},
],
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
// Do not allow unused variables unless they have the _ prefix or they are an error
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'none',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-wrapper-object-types': 'off',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/prefer-as-const': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'off',
'prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'error',
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/unbound-method': 'off',
},
},
{
files: ['**/*.js', 'scripts/archived/**/*', 'cypress/**/*.ts'], // Do not use typechecking on javascript files, archived scripts, or cypress which has different promise chains
extends: [tseslint.configs.disableTypeChecked],
},
);