forked from faker-js/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
190 lines (181 loc) · 6.22 KB
/
.eslintrc.js
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
// @ts-check
const { defineConfig } = require('eslint-define-config');
const { readGitignoreFiles } = require('eslint-gitignore');
module.exports = defineConfig({
ignorePatterns: [
...readGitignoreFiles(),
'.eslintrc.js', // Skip self linting
],
root: true,
env: {
browser: true,
node: true,
},
reportUnusedDisableDirectives: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:prettier/recommended',
'plugin:deprecation/recommended',
'plugin:jsdoc/recommended-typescript-error',
'plugin:unicorn/recommended',
],
parserOptions: {
project: ['./tsconfig.json'],
warnOnUnsupportedTypeScriptVersion: false,
},
rules: {
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-else-return': 'error',
'no-restricted-globals': ['error', 'Intl'],
'prefer-template': 'error',
'unicorn/no-nested-ternary': 'off', // incompatible with prettier
'unicorn/no-null': 'off', // incompatible with TypeScript
'unicorn/no-zero-fractions': 'off', // deactivated to raise awareness of floating operations
'unicorn/number-literal-case': 'off', // incompatible with prettier
'unicorn/prefer-ternary': 'off', // ternaries aren't always better
// TODO @Shinigami92 2023-09-23: prefer-at should be turned on when we drop support for Node 14.
'unicorn/prefer-at': 'off',
// TODO @Shinigami92 2023-09-23: prefer-string-replace-all should be turned on when we drop support for Node 14.
'unicorn/prefer-string-replace-all': 'off',
// TODO @ST-DDT 2023-10-28: The following rule should be turned on when we switch to esm.
'unicorn/prefer-top-level-await': 'off',
// TODO @Shinigami92 2023-09-23: The following rules currently conflict with our code.
// Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently.
'unicorn/better-regex': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/import-style': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/no-useless-switch-case': 'off',
'unicorn/numeric-separators-style': 'off',
'unicorn/prefer-code-point': 'off',
'unicorn/prefer-export-from': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-string-slice': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/require-array-join-separator': 'off',
'unicorn/switch-case-braces': 'off',
'@typescript-eslint/array-type': [
'error',
{ default: 'array-simple', readonly: 'generic' },
],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
format: ['PascalCase'],
selector: ['class', 'interface', 'typeAlias', 'enumMember'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
format: ['PascalCase'],
selector: ['typeParameter'],
prefix: ['T'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
],
'@typescript-eslint/no-inferrable-types': [
'error',
{ ignoreParameters: true },
],
'@typescript-eslint/no-unnecessary-condition': 'off', // requires `strictNullChecks` to be enabled
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: 'block-like', next: '*' },
],
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/restrict-template-expressions': [
'error',
{ allowNumber: true, allowBoolean: true },
],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off', // incompatible with our api docs generation
// TODO @ST-DDT 2023-10-10: The following rules currently conflict with our code.
// Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently.
'@typescript-eslint/no-confusing-void-expression': 'off',
'jsdoc/require-jsdoc': 'off', // Enabled only for src/**/*.ts
'jsdoc/require-returns': 'off',
'jsdoc/sort-tags': [
'error',
{
tagSequence: [
{ tags: ['template'] },
{ tags: ['internal'] },
{ tags: ['param'] },
{ tags: ['returns'] },
{ tags: ['throws'] },
{ tags: ['see'] },
{ tags: ['example'] },
{ tags: ['since'] },
{ tags: ['default'] },
{ tags: ['deprecated'] },
],
},
],
'jsdoc/tag-lines': 'off',
},
settings: {
jsdoc: {
mode: 'typescript',
},
},
overrides: [
{
files: ['src/**/*.ts'],
rules: {
'jsdoc/require-jsdoc': 'error',
},
},
{
files: ['src/locale/**/*.ts'],
rules: {
'unicorn/filename-case': 'off', // our locale files have a custom naming scheme
},
},
{
files: ['src/definitions/**/*.ts', 'src/locales/**/*.ts'],
rules: {
'unicorn/filename-case': [
'error',
{
case: 'snakeCase',
// TODO @ST-DDT 2023-10-21: rename the definitions in v9
ignore: [
/chemicalElement\.ts$/,
/directoryPaths\.ts$/,
/mimeTypes\.ts$/,
],
},
],
'unicorn/text-encoding-identifier-case': 'off',
},
},
{
files: ['test/**/*.spec.ts'],
extends: ['plugin:vitest/recommended'],
rules: {
'deprecation/deprecation': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowNumber: true,
allowBoolean: true,
allowAny: true,
},
],
'vitest/expect-expect': 'off',
'vitest/prefer-each': 'error',
'vitest/valid-expect': ['error', { maxArgs: 2 }],
},
},
],
});