-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.json
153 lines (151 loc) · 4.61 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
{
"extends": [
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"plugin:import/typescript",
"plugin:storybook/recommended"
],
"plugins": ["react", "@emotion", "@typescript-eslint", "import", "unused-imports"],
"env": {
"node": true,
"browser": true,
"jasmine": true,
"jest": true,
"es6": true
},
"rules": {
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{ "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
],
"@typescript-eslint/consistent-type-imports": "error",
"react/no-unknown-property": ["error", { "ignore": ["css"] }],
/* React rules */
"react/no-direct-mutation-state": "error",
"react/no-unused-prop-types": "warn",
"react/self-closing-comp": [
"warn",
{
"component": true,
"html": true
}
],
"react/prop-types": "off",
"react/button-has-type": "warn",
"@typescript-eslint/no-explicit-any": ["off"],
"react/no-array-index-key": "warn",
"react/no-render-return-value": 0,
"react/boolean-prop-naming": [
"error",
{
"rule": "^(is|has)[A-Z]([A-Za-z0-9]?)+",
"message": "Wrong name on boolean prop. Change ({{ propName }}) to start with `is` or `has`"
}
],
/* JSX rules */
"react/jsx-key": "error",
"react/jsx-curly-brace-presence": ["error", "never"],
// Since we are using React 17+ we no longer need these
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"react/no-children-prop": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
/* eslint basic rules */
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "function",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "function"
},
{
"blankLine": "always",
"prev": "*",
"next": "return"
}
],
// Disable this in favour of @typescript-eslint/no-unused-expressions
// so that function calls with optional chaining do not throw warnings
// https://github.com/facebook/create-react-app/issues/8107#issuecomment-565365982
// "no-unused-expressions": "warn",
"no-unused-vars": "off",
"no-debugger": "warn",
"no-console": "warn",
"import/order": [
"error",
{
"groups": ["builtin", "external", ["internal", "parent", "sibling", "index", "object"]],
"pathGroups": [
{
"pattern": "react",
"group": "external"
},
{
"pattern": "components/**",
"group": "internal"
}
],
"pathGroupsExcludedImportTypes": ["react"],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"newlines-between": "always"
}
],
/* Typescript rules */
"@typescript-eslint/naming-convention": [
"error",
{
"selector": ["variable", "parameter", "property"],
"types": ["boolean"],
"format": ["PascalCase"], // As per documentation, prefix is trimmed before checking for format , so we need pascal case for values like `isBoolean` https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md#format-options
"prefix": ["is", "has"]
}
],
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "all",
"argsIgnorePattern": "^__",
"varsIgnorePattern": "^__|React"
}
],
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/prefer-interface": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/ban-ts-comment": "warn"
},
"settings": {
"react": {
"pragma": "React",
"version": "detect"
}
},
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["rollup.config.js"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2022,
"sourceType": "module",
"project": ["./tsconfig.json"] // Specify it only for TypeScript files
}
}