1 | // Based on eslint-config-react-app; https://github.com/facebookincubator/create-react-app/blob/cd3d04b71e91f533bdbdc3856775e1da81d445cf/packages/eslint-config-react-app/index.js
|
2 |
|
3 | {
|
4 | "parser": "babel-eslint",
|
5 | "plugins": ["import", "jsx-a11y", "react", "react-hooks", "@kaliber/eslint-plugin"],
|
6 | "root": true,
|
7 | "env": {
|
8 | "browser": true,
|
9 | "commonjs": true,
|
10 | "es6": true,
|
11 | "jest": true,
|
12 | "node": true
|
13 | },
|
14 |
|
15 | "settings": {
|
16 | "import/resolver": {
|
17 | "@kaliber/build/eslint-resolver-plugins/absolute-path-resolver-plugin": {
|
18 | "path": "./src"
|
19 | }
|
20 | },
|
21 | "react": {
|
22 | "version": "detect"
|
23 | }
|
24 | },
|
25 |
|
26 | "parserOptions": {
|
27 | "ecmaVersion": 2020,
|
28 | "sourceType": "module",
|
29 | "ecmaFeatures": {
|
30 | "jsx": true,
|
31 | "generators": true,
|
32 | "experimentalObjectRestSpread": true
|
33 | }
|
34 | },
|
35 |
|
36 | "globals": {
|
37 | "Component": true,
|
38 | "React": true,
|
39 | "cx": true
|
40 | },
|
41 |
|
42 | "rules": {
|
43 | // http://eslint.org/docs/rules/
|
44 | "@kaliber/component-properties": "warn",
|
45 | "@kaliber/layout-class-name": "warn",
|
46 | "@kaliber/naming-policy": "warn",
|
47 | "@kaliber/no-default-export": "warn",
|
48 | "@kaliber/no-relative-parent-import": "warn",
|
49 |
|
50 | "brace-style": ["warn", "1tbs", { "allowSingleLine": true }],
|
51 | "indent": ["warn", 2, {
|
52 | "SwitchCase": 1,
|
53 | "flatTernaryExpressions": true
|
54 | //"ignoredNodes": ["ConditionalExpression"]
|
55 | }],
|
56 |
|
57 | "accessor-pairs": "warn",
|
58 | "array-callback-return": "warn",
|
59 | "arrow-spacing": "warn",
|
60 | "block-spacing": "warn",
|
61 | "comma-dangle": ["warn", "only-multiline"],
|
62 | "comma-spacing": "warn",
|
63 | "comma-style": "warn",
|
64 | "default-case": ["warn", { "commentPattern": "^no default$" }],
|
65 | "dot-location": ["warn", "property"],
|
66 | "eol-last": "warn",
|
67 | "eqeqeq": "warn",
|
68 | "keyword-spacing": "warn",
|
69 | "new-parens": "warn",
|
70 | "no-array-constructor": "warn",
|
71 | "no-caller": "warn",
|
72 | "no-class-assign": "warn",
|
73 | "no-compare-neg-zero": "warn",
|
74 | "no-cond-assign": "warn",
|
75 | "no-const-assign": "warn",
|
76 | "no-constant-condition": "warn",
|
77 | "no-control-regex": "warn",
|
78 | "no-debugger": "warn",
|
79 | "no-delete-var": "warn",
|
80 | "no-dupe-args": "warn",
|
81 | "no-dupe-class-members": "warn",
|
82 | "no-dupe-keys": "warn",
|
83 | "no-duplicate-case": "warn",
|
84 | "no-empty-character-class": "warn",
|
85 | "no-empty-pattern": "warn",
|
86 | "no-eval": "warn",
|
87 | "no-ex-assign": "warn",
|
88 | "no-extend-native": "warn",
|
89 | "no-extra-bind": "warn",
|
90 | "no-extra-boolean-cast": "warn",
|
91 | "no-extra-label": "warn",
|
92 | "no-extra-parens": ["warn", "functions"],
|
93 | "no-fallthrough": "warn",
|
94 | "no-floating-decimal": "warn",
|
95 | "no-func-assign": "warn",
|
96 | "no-global-assign": "warn",
|
97 | "no-implied-eval": "warn",
|
98 | "no-invalid-regexp": "warn",
|
99 | "no-irregular-whitespace": "warn",
|
100 | "no-iterator": "warn",
|
101 | "no-label-var": "warn",
|
102 | "no-labels": ["warn", { "allowLoop": true, "allowSwitch": false }],
|
103 | "no-lone-blocks": "warn",
|
104 | "no-loop-func": "warn",
|
105 | "no-mixed-spaces-and-tabs": "warn",
|
106 | // "no-multi-spaces": ["warn", { "ignoreEOLComments": true, "exceptions": { "Property": true, "VariableDeclarator": true, "ImportDeclaration": true } }], // needs better config to fit our needs
|
107 | "no-path-concat": "warn",
|
108 | "no-proto": "warn",
|
109 | "no-return-assign": "warn",
|
110 | "no-return-await": "warn",
|
111 | "no-trailing-spaces": "warn",
|
112 | "no-unneeded-ternary": "warn",
|
113 | "no-unsafe-negation": "warn",
|
114 | "no-useless-return": "warn",
|
115 | "object-curly-spacing": ["warn", "always"],
|
116 | "object-shorthand": ["warn", "always"],
|
117 | "quotes": ["warn", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
|
118 | "semi": ["warn", "never"],
|
119 | "semi-spacing": ["warn", { "before": false, "after": true }],
|
120 | "space-before-blocks": "warn",
|
121 | "space-before-function-paren": ["warn", { "anonymous": "never", "named": "never", "asyncArrow": "always" }],
|
122 | "space-infix-ops": "warn",
|
123 | "space-unary-ops": ["warn", { "words": true, "nonwords": false }],
|
124 | "template-tag-spacing": "warn",
|
125 | "no-mixed-operators": [
|
126 | "warn",
|
127 | {
|
128 | "groups": [
|
129 | ["&", "|", "^", "~", "<<", ">>", ">>>"],
|
130 | ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
131 | ["&&", "||"],
|
132 | ["in", "instanceof"],
|
133 | ],
|
134 | "allowSamePrecedence": false
|
135 | },
|
136 | ],
|
137 | "no-multi-str": "warn",
|
138 | "no-native-reassign": "warn",
|
139 | "no-negated-in-lhs": "warn",
|
140 | "no-new-func": "warn",
|
141 | "no-new-object": "warn",
|
142 | "no-new-symbol": "warn",
|
143 | "no-new-wrappers": "warn",
|
144 | "no-obj-calls": "warn",
|
145 | "no-octal": "warn",
|
146 | "no-octal-escape": "warn",
|
147 | "no-redeclare": "warn",
|
148 | "no-regex-spaces": "warn",
|
149 | "no-restricted-globals": ["warn", "addEventListener", "blur", "close", "closed", "confirm", "defaultStatus", "defaultstatus", "event", "external", "find", "focus", "frameElement", "frames", "history", "innerHeight", "innerWidth", "length", "location", "locationbar", "menubar", "moveBy", "moveTo", "name", "onblur", "onwarn", "onfocus", "onload", "onresize", "onunload", "open", "opener", "opera", "outerHeight", "outerWidth", "pageXOffset", "pageYOffset", "parent", "print", "removeEventListener", "resizeBy", "resizeTo", "screen", "screenLeft", "screenTop", "screenX", "screenY", "scroll", "scrollbars", "scrollBy", "scrollTo", "scrollX", "scrollY", "self", "status", "statusbar", "stop", "toolbar", "top"],
|
150 | "no-restricted-properties": [
|
151 | "warn",
|
152 | {
|
153 | "object": "require",
|
154 | "property": "ensure",
|
155 | "message": "Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting"
|
156 | },
|
157 | {
|
158 | "object": "System",
|
159 | "property": "import",
|
160 | "message": "Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting"
|
161 | },
|
162 | ],
|
163 | "no-restricted-syntax": ["warn", "WithStatement"],
|
164 | "no-script-url": "warn",
|
165 | "no-self-assign": "warn",
|
166 | "no-self-compare": "warn",
|
167 | "no-shadow-restricted-names": "warn",
|
168 | "no-sparse-arrays": "warn",
|
169 | "no-template-curly-in-string": "warn",
|
170 | "no-this-before-super": "warn",
|
171 | "no-throw-literal": "warn",
|
172 | "no-undef": "warn",
|
173 | "no-unexpected-multiline": "warn",
|
174 | "no-unreachable": "warn",
|
175 | "no-unused-expressions": [
|
176 | "warn",
|
177 | {
|
178 | "allowShortCircuit": true,
|
179 | "allowTernary": true,
|
180 | "allowTaggedTemplates": true
|
181 | },
|
182 | ],
|
183 | "no-unused-labels": "warn",
|
184 | "no-unused-vars": [
|
185 | "warn",
|
186 | {
|
187 | "args": "none",
|
188 | "ignoreRestSiblings": true
|
189 | },
|
190 | ],
|
191 | "no-use-before-define": [
|
192 | "warn",
|
193 | {
|
194 | "functions": false,
|
195 | "classes": false,
|
196 | "variables": false
|
197 | },
|
198 | ],
|
199 | "no-useless-computed-key": "warn",
|
200 | "no-useless-concat": "warn",
|
201 | "no-useless-constructor": "warn",
|
202 | "no-useless-escape": "warn",
|
203 | "no-whitespace-before-property": "warn",
|
204 | "no-with": "warn",
|
205 | "radix": "warn",
|
206 | "require-yield": "warn",
|
207 | "rest-spread-spacing": ["warn", "never"],
|
208 | "strict": ["warn", "never"],
|
209 | "unicode-bom": ["warn", "never"],
|
210 | "use-isnan": "warn",
|
211 | "valid-typeof": "warn",
|
212 |
|
213 | // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
|
214 | "import/first": "warn",
|
215 | "import/no-amd": "warn",
|
216 | "import/no-webpack-loader-syntax": "warn",
|
217 | "import/no-default-export": "off",
|
218 | "import/no-duplicates": ["warn", { "considerQueryString": true }],
|
219 | "import/export": "warn",
|
220 | "import/default": "warn",
|
221 | "import/no-unresolved": "warn",
|
222 | "import/named": "warn", // Needs a custom resolver to work with non-relative imports
|
223 |
|
224 | // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
|
225 | "react/jsx-boolean-value": "warn",
|
226 | // "react/jsx-closing-bracket-location": "warn", // needs better config to fit our needs
|
227 | // "react/jsx-closing-tag-location": "warn", // needs better config to fit our needs
|
228 | "react/jsx-curly-spacing": ["warn", "never"],
|
229 | "react/jsx-equals-spacing": "warn",
|
230 | "react/jsx-indent": ["warn", 2],
|
231 | "react/jsx-indent-props": ["warn", 2],
|
232 | "react/jsx-key": "warn",
|
233 | "react/jsx-no-comment-textnodes": "warn",
|
234 | "react/jsx-no-duplicate-props": ["warn", { "ignoreCase": true }],
|
235 | "react/jsx-no-target-blank": "warn",
|
236 | "react/jsx-no-undef": ["warn", { "allowGlobals": true }],
|
237 | "react/jsx-pascal-case": ["warn", { "allowAllCaps": true }],
|
238 | "react/jsx-tag-spacing": "warn",
|
239 | "react/jsx-uses-react": "warn",
|
240 | "react/jsx-uses-vars": "warn",
|
241 | // "react/jsx-wrap-multilines": "warn", // needs better config to fit our needs
|
242 | "react/no-danger-with-children": "warn",
|
243 | "react/no-deprecated": "warn",
|
244 | "react/no-direct-mutation-state": "warn",
|
245 | // "react/no-typos": "warn", // waiting for https://github.com/yannickcr/eslint-plugin-react/issues/1389
|
246 | "react/no-unused-prop-types": "warn",
|
247 | "react/prop-types": ["error", { "skipUndeclared": true }],
|
248 | "react/require-render-return": "warn",
|
249 | "react/self-closing-comp": "warn",
|
250 | "react/void-dom-elements-no-children": "warn",
|
251 |
|
252 | // https://www.npmjs.com/package/eslint-plugin-react-hooks
|
253 | "react-hooks/rules-of-hooks": "error",
|
254 | "react-hooks/exhaustive-deps": "warn",
|
255 |
|
256 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
|
257 | "jsx-a11y/accessible-emoji": "warn",
|
258 | "jsx-a11y/alt-text": "warn",
|
259 | "jsx-a11y/anchor-has-content": "warn",
|
260 | "jsx-a11y/anchor-is-valid": "warn",
|
261 | "jsx-a11y/aria-activedescendant-has-tabindex": "warn",
|
262 | "jsx-a11y/aria-props": "warn",
|
263 | "jsx-a11y/aria-proptypes": "warn",
|
264 | "jsx-a11y/aria-role": "warn",
|
265 | "jsx-a11y/aria-unsupported-elements": "warn",
|
266 | "jsx-a11y/heading-has-content": "warn",
|
267 | "jsx-a11y/html-has-lang": "warn",
|
268 | "jsx-a11y/iframe-has-title": "warn",
|
269 | "jsx-a11y/img-redundant-alt": "warn",
|
270 | "jsx-a11y/no-access-key": "warn",
|
271 | "jsx-a11y/no-distracting-elements": "warn",
|
272 | "jsx-a11y/no-redundant-roles": "warn",
|
273 | "jsx-a11y/role-has-required-aria-props": "warn",
|
274 | "jsx-a11y/role-supports-aria-props": "warn",
|
275 | "jsx-a11y/scope": "warn"
|
276 | }
|
277 | }
|