-
Notifications
You must be signed in to change notification settings - Fork 23
/
.eslintrc.json
189 lines (189 loc) · 7.11 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx", "eslint-comments", "promise", "unicorn", "license-header"],
"extends": [
"plugin:@next/next/recommended",
"airbnb",
"airbnb/hooks",
"plugin:eslint-comments/recommended",
"plugin:promise/recommended",
"plugin:unicorn/recommended",
"prettier"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
}
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
],
"@next/next/no-html-link-for-pages": "off",
// React is already in-scope for all files compiled with Next.js
"react/react-in-jsx-scope": "off",
// SSR does not support useLayoutEffect
"no-restricted-imports": [
"error",
{
"name": "react",
"importNames": ["useLayoutEffect"],
"message": "`useLayoutEffect` causes a warning in SSR. Use `useEffect`"
}
],
// Enables for of and for in loops since airbnb does not allow them
"no-restricted-syntax": "off",
// Enforces camelcase
"camelcase": [
"error",
{
"ignoreDestructuring": true
}
],
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
"no-prototype-builtins": "off",
// Does not allow unreachable loops unless its a for of loop
"no-unreachable-loop": ["error", { "ignore": ["ForInStatement", "ForOfStatement"] }],
// The default case may not be necessary when explicitly knowing return types
"default-case": "warn",
// Can make ugly code
"consistent-return": "off",
// Can make ugly code
"no-case-declarations": "off",
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
"react/destructuring-assignment": "off",
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
"react/jsx-filename-extension": "off",
// Allow only arrow function based components
"react/function-component-definition": [2, { "namedComponents": "function-declaration" }],
// Common practice in React
"react/jsx-props-no-spreading": "off",
// Warn when the index is used as a key instead of a unique value
"react/no-array-index-key": "warn",
// Sometimes its useful to return a useless fragment instead of adding a null as a union type
"react/jsx-no-useless-fragment": "warn",
// Common abbreviations are known and readable
"unicorn/prevent-abbreviations": "off",
// Airbnb prefers forEach
"unicorn/no-array-for-each": "off",
// React prefers capitalized file names for components
"unicorn/filename-case": "off",
// Enables Array.reduce()
"unicorn/no-array-reduce": "off",
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
"import/prefer-default-export": "off",
// It's not accurate in the monorepo style
"import/no-extraneous-dependencies": "off",
// Import for import of components
"import/no-cycle": "off",
"eslint-comments/disable-enable-pair": "off",
"promise/no-nesting": "off",
"react/require-default-props": "off",
"unicorn/no-abusive-eslint-disable": "off",
"eslint-comments/no-unlimited-disable": "off",
"unicorn/no-null": "off",
"unicorn/prefer-module": "off",
"license-header/header": [ "error", "./license-header.js" ],
"unicorn/prefer-top-level-await": "off"
}
},
{
"files": ["*.ts", "*.tsx"],
"plugins": ["@typescript-eslint", "typescript-enum"],
"extends": [
"plugin:@nrwl/nx/typescript",
"airbnb-typescript",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
// enums are bad https://www.youtube.com/watch?v=jjMbPt_H3RQ
"plugin:typescript-enum/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.base.json",
"ecmaVersion": 13,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
// It's not accurate in the monorepo style
"import/no-extraneous-dependencies": "off",
// Required for react component imports
"import/no-named-as-default": "off",
// Requires return type
"@typescript-eslint/explicit-function-return-type": "error",
// Allows the use of functions before definition
"@typescript-eslint/no-use-before-define": ["off"],
// Allows variables starting with _ to be ignored if not used
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
// Disallows function overloading
"@typescript-eslint/unified-signatures": "error",
// Requires function return types
"@typescript-eslint/prefer-function-type": "error",
// Requires classes to make member access explicit
"@typescript-eslint/explicit-member-accessibility": "error",
// Requires the use of interface over type when possible
"@typescript-eslint/consistent-type-definitions": "error",
// Requires consistent type casting
"@typescript-eslint/consistent-type-assertions": "error",
// Requires the T[] type syntax for an array
"@typescript-eslint/array-type": "error",
// Next.js does not require all anchor tags to have an href
"jsx-a11y/anchor-is-valid": "off",
"@typescript-eslint/ban-ts-comment": "off",
"react/no-unused-prop-types": "off",
"no-case-declarations": "off",
"no-underscore-dangle": "off",
"@typescript-eslint/naming-convention": "warn"
}
},
{
"files": ["*.js", "*.jsx", "*.mjs"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {
// Allow CJS until ESM support improves
"unicorn/prefer-module": "off",
"unicorn/import-style": "off",
"no-param-reassign": "off",
"import/extensions": "off"
}
},
{
"files": ["*.stories.jsx", "*.stories.tsx"],
"rules": {
"react/function-component-definition": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off"
}
},
{
"files": ["*.spec.js", "*.spec.ts", "*.spec.jsx", "*.spec.tsx"],
"rules": {
"@typescript-eslint/no-unsafe-call": "off"
}
}
]
}