-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheslintrc.cjs
134 lines (117 loc) · 3.69 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
module.exports = {
extends: [
'prettier',
'@remix-run/eslint-config',
'plugin:import/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
plugins: ['import', 'unused-imports', 'simple-import-sort', '@typescript-eslint'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: true,
tsconfigRootDir: __dirname,
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
project: ['tsconfig.json'],
},
node: {
project: ['tsconfig.json'],
},
},
},
rules: {
/** No absolute imports */
'import/no-absolute-path': 'error',
/** Ensures all imports appear before other statements */
'import/first': ['error'],
/** Ensures there’s an empty line between imports and other statements */
'import/newline-after-import': ['warn', { count: 1 }],
/** Sorts imports automatically */
'simple-import-sort/imports': 'warn',
/** Ensures no unused imports are present, and only _ prefixed variables can be unused */
'no-unused-vars': 'off',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'unused-imports/no-unused-imports': 'error',
'@typescript-eslint/no-misused-promises': 'off',
'no-restricted-syntax': [
'warn',
{
selector: 'TSEnumDeclaration',
message: 'Don’t declare enums! Use string literal unions instead, they’re safer and more ergonomic.',
},
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'react-router-dom',
importNames: ['defer'],
message: "Please import defer from '~/domains/routing/routing.utils' instead.",
},
{
name: 'react-router-dom',
importNames: ['useLoaderData'],
message: "Please import useLoaderData from '~/domains/routing/routing.utils' instead.",
},
{
name: 'react-router-dom',
importNames: ['useActionData'],
message: "Please import useActionData from '~/domains/routing/routing.utils' instead.",
},
],
},
],
'@typescript-eslint/no-unnecessary-condition': 'warn',
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
/** Prefer types over interfaces */
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
/** Standardises arrays. Simple arrays use brackets, complex arrays uses generic syntax
* @example - ❌ `const foo: Array<string> = [];`
* @example - ✅ `const foo: string[] = [];`
* @example - ❌ `const foo: ReturnType<typeof bar>[] = [];`
* @example - ✅ `const foo: Array<ReturnType<typeof bar>> = [];`
*/
'@typescript-eslint/array-type': ['warn'],
/** Enforces generics on the cunstructor, not as type annotation.
* @example - ❌ `const foo: Foo<string> = new Foo();`
* @example - ✅ `const foo = new Foo<string>();`
*/
'@typescript-eslint/consistent-generic-constructors': ['warn', 'constructor'],
/** Prefer Record<X,Y> over {[key: X]: Y} syntax */
'@typescript-eslint/consistent-indexed-object-style': ['warn', 'record'],
/** Already handled by unused-imports */
'@typescript-eslint/no-unused-vars': 'off',
/** React uses that a lot */
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
'ts-nocheck': true,
'ts-check': false,
minimumDescriptionLength: 5,
},
],
},
};