-
Notifications
You must be signed in to change notification settings - Fork 180
/
.eslintrc.cjs
152 lines (145 loc) · 5.04 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
// @ts-check
const { defineConfig } = require('eslint-define-config');
const { readGitignoreFiles } = require('eslint-gitignore');
/// <reference types="@eslint-types/prettier" />
/// <reference types="@eslint-types/typescript-eslint" />
/// <reference types="@eslint-types/unicorn" />
module.exports = defineConfig({
ignorePatterns: [
...readGitignoreFiles(),
'templates',
'.eslintrc.cjs', // Skip self linting
],
root: true,
env: {
node: true,
},
reportUnusedDisableDirectives: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:unicorn/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
project: ['./tsconfig.lint.json'],
warnOnUnsupportedTypeScriptVersion: false,
},
rules: {
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-else-return': 'error',
'prefer-exponentiation-operator': 'error',
'prefer-template': 'error',
quotes: 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/filename-case': 'off',
'unicorn/import-style': [
'error',
{ styles: { 'node:path': { named: true } } },
],
'unicorn/no-array-callback-reference': 'off', // reduces readability
'unicorn/no-array-reduce': 'off',
'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-module': 'off',
'unicorn/prefer-ternary': 'off', // ternaries aren't always better
'unicorn/prefer-type-error': 'off',
// TODO @Shinigami92 2024-04-27: Potentially enable later
'unicorn/no-process-exit': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-native-coercion-functions': 'off',
'unicorn/prefer-string-raw': 'off',
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prefer-structured-clone': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/prevent-abbreviations': 'off',
'@typescript-eslint/array-type': [
'error',
{ default: 'array-simple', readonly: 'generic' },
],
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': 'allow-with-description',
},
],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: false,
fixStyle: 'separate-type-imports',
},
],
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
format: ['PascalCase'],
selector: ['class', 'interface', 'typeAlias'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
format: ['UPPER_CASE', 'snake_case'],
selector: ['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-non-null-assertion': 'warn',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@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/quotes': ['error', 'single', { avoidEscape: true }],
// TODO @Shinigami92 2024-02-29: Enable restrict-template-expressions later
// '@typescript-eslint/restrict-template-expressions': [
// 'error',
// { allowNumber: true, allowBoolean: true },
// ],
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{ requireDefaultForNonUnion: true },
],
'@typescript-eslint/unbound-method': 'off',
// TODO @Shinigami92 2024-02-29: Remove these later
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unified-signatures': 'off',
},
overrides: [
{
files: ['test/migrations/*.js'],
rules: {
'unicorn/prefer-module': 'off',
'@typescript-eslint/no-throw-literal': 'off',
},
},
],
});