-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.json
140 lines (124 loc) · 3.98 KB
/
.eslintrc.json
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
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": true
},
"extends": [
"next",
"prettier",
"plugin:import/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript"
],
"plugins": [
"@typescript-eslint",
"simple-import-sort",
"unused-imports",
"import"
],
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "."
}
}
},
"rules": {
/** Only single quotes **/
"quotes": ["error", "single", { "avoidEscape": true }],
/** We live to remove this rule. */
"@typescript-eslint/no-explicit-any": "off",
/** We do too much of this with the singletons */
"import/no-anonymous-default-export": "off",
/** 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",
/** We only use namespaces in our generated types and those are not in our control */
"@typescript-eslint/no-namespace": "off",
/** 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."
}
],
"@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",
"@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
}
],
"no-restricted-imports": [
"error",
{
"paths": [
/** Prevents us from using global lodash imports that break tree-shaking */
{
"name": "lodash",
"message": "Import [module] from lodash/[module] instead"
}
]
}
],
"react/jsx-curly-brace-presence": [
"warn",
{
"props": "never",
"children": "never"
}
],
"object-curly-spacing": ["warn", "always"]
}
}