-
Notifications
You must be signed in to change notification settings - Fork 11
/
.eslintrc.cjs
133 lines (129 loc) · 3.71 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
/**@type {import('eslint').Linter.Config} */
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
ignorePatterns: ["dist", ".eslintrc.cjs", "packages/config/src/index.d.ts"],
parserOptions: {
project: "./tsconfig.eslint.json",
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
es2020: true,
node: true,
},
settings: {
react: {
version: "detect",
},
},
plugins: ["@typescript-eslint", "react-refresh"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"prettier",
],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-debugger": "error",
"no-console": "error",
// Typescript
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/naming-convention": [
"error",
{
selector: ["class"],
format: ["PascalCase"],
},
{
selector: "interface",
format: ["PascalCase"],
custom: {
regex: "^I[A-Z]",
match: false,
},
},
],
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/prefer-nullish-coalescing": [
"warn",
{
ignorePrimitives: { string: true },
ignoreConditionalTests: true,
},
],
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/no-unnecessary-condition": "warn",
// Typescript extension rules: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules#extension-rules
"brace-style": "off",
"default-param-last": "off",
"@typescript-eslint/default-param-last": ["warn"],
// React styles
// Disabling due to false positives
// "react/boolean-prop-naming": [
// "warn",
// {
// propTypeNames: ["bool", "boolean"],
// rule: "^(is|has|was|should|show)[A-Z]([A-Za-z0-9]?)+",
// },
// ],
"react/destructuring-assignment": "off",
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react/button-has-type": "warn",
"react/no-array-index-key": "warn",
"react/prop-types": "off",
"react/no-multi-comp": ["warn", { ignoreStateless: true }],
"react/no-unescaped-entities": "off",
// Formatting (handled by prettier)
"@typescript-eslint/brace-style": "off",
},
overrides: [
{
files: ["src/lib/**/*", "src/app/**/*"],
rules: {
"import/no-nodejs-modules": [
"error",
{
allow: [
"constants/defaults",
"constants/routes",
"constants/storage",
"constants/support",
"constants/colors",
"constants/user",
"constants/analytics",
"constants/file-items",
"constants/status-code",
"constants/strings/CommonStrings",
"constants/strings/FilesStrings",
"constants/strings/PolicyStrings",
"constants/strings/RouteStrings",
],
},
],
},
},
{
files: ["**.test.ts", "**.spec.ts", "scripts/**/*"],
rules: {
// Floating promises in tests
// https://github.com/nodejs/node/issues/51292
"@typescript-eslint/no-floating-promises": "off",
"import/no-nodejs-modules": "off",
"no-console": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
],
};