-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
184 lines (173 loc) · 4.48 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
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
/**
* @type { ESLint.ConfigData }
*/
module.exports = {
globals: {
KeyboardEvent: true,
Element: true,
HTMLElement: true,
location: true
},
ignorePatterns: [
'.server',
'.public',
'src/__fixtures__',
'coverage',
'.husky',
'.github',
'node_modules',
'.sonarlint',
'raw-assets'
],
overrides: [
{
extends: [
'standard',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:jsdoc/recommended-typescript-flavor',
'plugin:n/recommended',
'plugin:promise/recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'prettier'
],
env: {
browser: false
},
files: ['**/*.{cjs,js,ts}'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname
},
plugins: [
'@typescript-eslint',
'import',
'jsdoc',
'n',
'promise',
'prettier'
],
rules: {
'prettier/prettier': [
'error',
{
endOfLine: 'auto'
}
],
'no-console': 'error',
// Turn off strict type checking rules
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
// JSDoc blocks are optional by default
'jsdoc/require-jsdoc': 'off',
// JSDoc @param types are mandatory for JavaScript
'jsdoc/require-param-description': 'off',
'jsdoc/require-param-type': 'error',
'jsdoc/require-param': 'off',
// JSDoc @property description is optional
'jsdoc/require-property-description': 'off',
// JSDoc @returns is optional
'jsdoc/require-returns-description': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/require-returns': 'off',
// Check for mandatory file extensions
// https://nodejs.org/api/esm.html#mandatory-file-extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Skip rules handled by TypeScript compiler
'import/default': 'off',
'import/namespace': 'off',
'n/no-extraneous-require': 'off',
'n/no-extraneous-import': 'off',
'n/no-missing-require': 'off',
'n/no-missing-import': 'off',
// Allow import devDependencies in tests
'n/no-unpublished-import': [
'error',
{
allowModules: [
'copy-webpack-plugin',
'clean-webpack-plugin',
'terser-webpack-plugin',
'webpack-assets-manifest'
]
}
]
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.cjs', '.js']
},
'import/resolver': {
node: true,
typescript: true
}
}
},
{
files: ['**/*.js'],
parserOptions: {
sourceType: 'module'
}
},
{
env: {
commonjs: true
},
files: ['**/*.cjs'],
parserOptions: {
sourceType: 'commonjs'
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
// Allow require devDependencies in config files
'n/no-unpublished-require': [
'error',
{
allowModules: []
}
]
}
},
{
env: {
browser: true,
node: false
},
files: ['src/client/**/*.js']
},
{
env: {
'jest/globals': true
},
extends: [
'plugin:jest-formatting/recommended',
'plugin:jest/recommended',
'plugin:jest/style'
],
files: ['**/*.test.{cjs,js}', '**/__mocks__/**', 'test-helpers/**'],
plugins: ['jest'],
rules: {
// Allow Jest to assert on mocked unbound methods
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
// Allow import devDependencies in tests
'n/no-unpublished-import': [
'error',
{
allowModules: ['nock', 'cheerio', 'jest-fetch-mock']
}
]
}
}
],
root: true
}
/**
* @import { ESLint } from 'eslint'
*/