-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc
131 lines (131 loc) · 3.52 KB
/
.eslintrc
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
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
},
// ! NB: empty object is intentional, mitigates module alias issue
"import/resolver": {
"typescript": {}
}
},
"env": {
"browser": true,
"es2021": true,
"jest": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:jest/recommended",
"plugin:jest-dom/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:storybook/recommended",
"plugin:testing-library/react",
"prettier"
],
"plugins": [
"@typescript-eslint",
"react",
"import",
"typescript-sort-keys",
"unused-imports",
"prefer-arrow",
"react-hooks",
"jest",
"jest-dom",
"testing-library"
],
"rules": {
// allow non-null assertion operators
"@typescript-eslint/no-non-null-assertion": "off",
// allow empty object types (e.g. for interfaces)
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/ban-ts-comment": [
"error",
// allow TypeScript bypass directives if a description is specified
{
"ts-ignore": "allow-with-description",
"ts-nocheck": "allow-with-description"
}
],
// disallow unused variables
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-unused-expressions": [
"error",
{
"allowShortCircuit": true,
"allowTernary": true
}
],
// suppress errors for missing React import (prefer modern JSX transform)
"react/react-in-jsx-scope": "off",
// prevent multiple components per file
// NB: this rule is disabled because it is not compatible with the structure of our library
// "react/no-multi-comp": "error",
// enforce arrow functions for React components
"react/function-component-definition": [
"error",
{
"namedComponents": "arrow-function",
"unnamedComponents": "arrow-function"
}
],
// warn on use of type `any`
"@typescript-eslint/no-explicit-any": "warn",
// explicitly handle promises (e.g. `await`, `void`)
"@typescript-eslint/no-floating-promises": "error",
// enforce type imports
"@typescript-eslint/consistent-type-imports": "error",
// prevent cyclic dependencies
"import/no-cycle": "error",
// prevent duplicate imports
"import/no-duplicates": "error",
// remove unused imports
"unused-imports/no-unused-imports": "warn",
// enforce import group order
"import/order": [
"error",
{
"alphabetize": {
"caseInsensitive": true,
"order": "asc"
},
// separate import groups (e.g. external dependencies from internal dependencies)
"groups": [
"builtin",
"external",
[
"internal",
// NB: TS aliased paths fall into `unknown` category. See https://github.com/import-js/eslint-plugin-import/issues/1379
"unknown",
"parent",
"sibling",
"index",
"object"
],
"type"
],
"newlines-between": "always"
}
]
}
}