-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.mjs
166 lines (149 loc) · 4.12 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
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import functional from 'eslint-plugin-functional';
import guardian from '@guardian/eslint-config';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
// this is a workaround for variables that are used in a way that eslint doesn't recognize
const noUnusedVarsPattern = '^_|React|req|res|next|error|idxPaths|Schema$';
const config = tseslint.config(
{
// ignore files we don't want to lint
ignores: [
'**/cdk/',
'**/storybook-static/',
'build/',
'scripts/okta/okta-login.js',
],
},
{
extends: [
...guardian.configs.javascript,
eslint.configs.recommended,
...guardian.configs.react,
...tseslint.configs.recommendedTypeChecked,
...guardian.configs.jest,
...guardian.configs.storybook,
functional.configs.noMutations,
eslintPluginPrettierRecommended,
...guardian.configs.comments,
],
plugins: {
functional,
},
languageOptions: {
ecmaVersion: 2022,
sourceType: 'commonjs',
parserOptions: {
projectService: {
// lint additional files that are not part of the tsconfig
allowDefaultProject: ['eslint.config.mjs', 'cypress.config.ts'],
},
ecmaFeatures: {
jsx: true,
},
// list of all tsconfig files that should be used for type checking
project: [
'./tsconfig.json',
'./cypress/tsconfig.json',
'./scripts/okta/tsconfig.json',
],
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
// fix no-unused-vars errors based on `noUnusedVarsPattern`
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: noUnusedVarsPattern,
caughtErrors: 'none',
caughtErrorsIgnorePattern: noUnusedVarsPattern,
destructuredArrayIgnorePattern: noUnusedVarsPattern,
varsIgnorePattern: noUnusedVarsPattern,
ignoreRestSiblings: true,
},
],
// override functional rules
'functional/immutable-data': [
'error',
{
ignoreImmediateMutation: true,
},
],
'functional/prefer-immutable-types': 'off',
'functional/type-declaration-immutability': 'off',
// eslint rules
'no-var': 'error',
'no-param-reassign': 'error',
'no-sequences': 'error',
'no-console': 'error',
'prefer-const': 'error',
// disabled @guardian/eslint-config rules, we should enable some of them later
'import/order': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'eslint-comments/require-description': 'off',
'import/no-default-export': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'sort-imports': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'import/no-named-as-default': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'import/no-named-as-default-member': 'off',
'import/no-cycle': 'off',
'@typescript-eslint/only-throw-error': 'off',
},
},
{
// rules specific to storybook files
files: ['**/*.stories.tsx'],
rules: {
'functional/immutable-data': 'off',
},
},
{
// rules specific to test files
files: ['**/*.test.tsx', '**/*.test.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@eslint-community/eslint-comments/require-description': 'off',
},
},
{
// rules specific to cypress test files
files: ['**/*.cy.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
},
{
// rules specific to files that are not part of the main codebase
files: [
'__mocks__/**/*',
'.storybook/**/*',
'cypress/**/*',
'scripts/**/*',
'util/**/*',
'.swcrc.config.js',
'babel.config.js',
'cypress.config.ts',
'jest.config.js',
'webpack.config.js',
'webpack.development.js',
],
rules: {
'@eslint-community/eslint-comments/require-description': 'off',
},
},
);
export default config;