-
Notifications
You must be signed in to change notification settings - Fork 22
/
eslint.config.js
78 lines (73 loc) · 2.39 KB
/
eslint.config.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
// @ts-check
import * as path from 'node:path'
import { fileURLToPath } from 'node:url'
import pluginJs from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
const dirname = path.dirname(fileURLToPath(import.meta.url))
const extensions = '{js,mjs,cjs,ts}'
export default tseslint.config(
{
files: [`src/*.${extensions}`, `bin/*`, `*.${extensions}`],
},
{
ignores: [`dist/`, 'coverage/'],
},
{
languageOptions: {
globals: globals.node,
parserOptions: {
projectService: {
allowDefaultProject: [`*.config.${extensions}`],
},
tsconfigRootDir: dirname,
},
},
linterOptions: { reportUnusedDisableDirectives: 'error' },
},
pluginJs.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
rules: {
// Only disabling these because this code is very old but also battle-tested,
// and coming up with clever typings may break for consumers.
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
// We prefer generic arrays.
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
// We should ignore unused vars with underscores.
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
{ ignoreConditionalTests: false },
],
},
},
{
files: [`src/__tests__/**/*.${extensions}`],
rules: {
// In tests, sometimes we need to make things asynchronous.
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
)