@qlik/eslint-config 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -8
- package/package.json +3 -1
- package/src/configs/cjs.js +3 -0
- package/src/configs/esm.js +3 -0
- package/src/configs/react.js +35 -25
- package/src/configs/recommended.js +3 -0
- package/src/configs/rules/eslint-core.js +1 -5
- package/src/configs/rules/import-x.js +1 -1
- package/src/configs/rules/react.js +3 -56
- package/src/configs/svelte.js +2 -0
- package/src/utils/compose.js +5 -7
- package/src/utils/merge.js +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ export default qlik.compose(
|
|
|
63
63
|
...qlik.configs.recommended, // adds linting on .js, .jsx, .mjs, .cjs, .ts, .tsx, .cts, .mts files. use for pure browser environment
|
|
64
64
|
{
|
|
65
65
|
ignores: ["dist", "npm", "node_modules"],
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
67
|
);
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -91,7 +91,7 @@ export default qlik.compose(
|
|
|
91
91
|
...qlik.configs.svelte, // based on the recommended config and adds svelte linting on .svelte files
|
|
92
92
|
{
|
|
93
93
|
ignores: ["dist", "node_modules"],
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
95
|
);
|
|
96
96
|
```
|
|
97
97
|
|
|
@@ -106,7 +106,7 @@ export default qlik.compose(
|
|
|
106
106
|
...qlik.configs.svelte,
|
|
107
107
|
{
|
|
108
108
|
ignores: ["dist", "node_modules"],
|
|
109
|
-
}
|
|
109
|
+
},
|
|
110
110
|
);
|
|
111
111
|
```
|
|
112
112
|
|
|
@@ -152,7 +152,7 @@ Example only use javascript rules with react
|
|
|
152
152
|
import qlik, { recommendedJS, reactJS } from "@qlik/eslint-config";
|
|
153
153
|
|
|
154
154
|
export default qlik.compose(
|
|
155
|
-
reactJS
|
|
155
|
+
reactJS,
|
|
156
156
|
)
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -163,7 +163,7 @@ import qlik, { recommendedJS, reactJS } from "@qlik/eslint-config";
|
|
|
163
163
|
|
|
164
164
|
export default qlik.compose(
|
|
165
165
|
reactJS,
|
|
166
|
-
reactTS
|
|
166
|
+
reactTS,
|
|
167
167
|
)
|
|
168
168
|
```
|
|
169
169
|
|
|
@@ -173,7 +173,7 @@ This is equal to:
|
|
|
173
173
|
import qlik from "@qlik/eslint-config";
|
|
174
174
|
|
|
175
175
|
export default qlik.compose(
|
|
176
|
-
...qlik.configs.react
|
|
176
|
+
...qlik.configs.react,
|
|
177
177
|
)
|
|
178
178
|
```
|
|
179
179
|
|
|
@@ -195,6 +195,86 @@ export default qlik.compose(
|
|
|
195
195
|
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
+
This will take the configs in the `extend` array and perform a deep merge of whatever is defined in the object containing
|
|
199
|
+
the `extend` property with the configs in the `extend` array and return them as separate configs. The deep merge has three
|
|
200
|
+
exceptions. `files`, `ignores` and `globals` are always overwritten by the later config.
|
|
201
|
+
|
|
202
|
+
```js
|
|
203
|
+
import qlik, { esmJS } from "@qlik/eslint-config";
|
|
204
|
+
|
|
205
|
+
export default qlik.compose(
|
|
206
|
+
{
|
|
207
|
+
extend: [...qlik.configs.recommended], // contains two configs (recommendedJS and recommendedTS)
|
|
208
|
+
files: ["only_want_lint_here/**/*.js"],
|
|
209
|
+
},
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
This will result in two configs, each with the given file pattern like this:
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
export default [
|
|
217
|
+
{
|
|
218
|
+
...recommendedJS config
|
|
219
|
+
files: ["only_want_lint_here/**/*.js"],
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
...recommendedTS config
|
|
223
|
+
files: ["only_want_lint_here/**/*.js"],
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### More examples with export
|
|
229
|
+
|
|
230
|
+
One GOTCHA about the flat configs. If there's no `files` property in one of the configs in the config array it is applied
|
|
231
|
+
to every file. So in the case of turning off a rule that belongs to specific config e.g. jest or vitest. The following
|
|
232
|
+
approach does NOT work.
|
|
233
|
+
|
|
234
|
+
```js
|
|
235
|
+
// @ts-check
|
|
236
|
+
import qlik from "@qlik/eslint-config";
|
|
237
|
+
|
|
238
|
+
export default qlik.compose(
|
|
239
|
+
...qlik.configs.recommended,
|
|
240
|
+
qlik.configs.vitest, // <-- this is applied to files inside __test(s)__ folders by default for our convenience
|
|
241
|
+
{
|
|
242
|
+
rules: {
|
|
243
|
+
// I want to change this rule, but it doesn't work because it is applied to all files
|
|
244
|
+
"vitest/max-nested-describe": [
|
|
245
|
+
"error",
|
|
246
|
+
{
|
|
247
|
+
"max": 3
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Here the `extend` feature becomes helpful
|
|
256
|
+
|
|
257
|
+
```js
|
|
258
|
+
// @ts-check
|
|
259
|
+
import qlik from "@qlik/eslint-config";
|
|
260
|
+
|
|
261
|
+
export default qlik.compose(
|
|
262
|
+
...qlik.configs.recommended,
|
|
263
|
+
{
|
|
264
|
+
extend: [qlik.configs.vitest],
|
|
265
|
+
rules: {
|
|
266
|
+
// This will add or overwrite the rule in the default config
|
|
267
|
+
"vitest/max-nested-describe": [
|
|
268
|
+
"error",
|
|
269
|
+
{
|
|
270
|
+
"max": 3
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
);
|
|
276
|
+
```
|
|
277
|
+
|
|
198
278
|
Example of changing the default file patterns on the vitest config.
|
|
199
279
|
|
|
200
280
|
```js
|
|
@@ -216,10 +296,33 @@ export default qlik.compose(
|
|
|
216
296
|
]
|
|
217
297
|
}
|
|
218
298
|
},
|
|
299
|
+
);
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
This will result in a final config looking like this:
|
|
303
|
+
|
|
304
|
+
```js
|
|
305
|
+
export default [
|
|
306
|
+
{
|
|
307
|
+
...recommendedJS config
|
|
308
|
+
},
|
|
219
309
|
{
|
|
220
|
-
|
|
310
|
+
...recommendedTS config
|
|
221
311
|
},
|
|
222
|
-
|
|
312
|
+
{
|
|
313
|
+
files: ['**/my_tests_are_here/*.spec.ts'],
|
|
314
|
+
...vitest config
|
|
315
|
+
rules: {
|
|
316
|
+
... vitest config rules,
|
|
317
|
+
"vitest/max-nested-describe": [
|
|
318
|
+
"error",
|
|
319
|
+
{
|
|
320
|
+
"max": 3
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
]
|
|
223
326
|
```
|
|
224
327
|
|
|
225
328
|
<!-- prettier-ignore-end -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlik/eslint-config",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Qlik's ESLint configs",
|
|
5
5
|
"repository": "git@github.com:qlik-oss/dev-tools-js.git",
|
|
6
6
|
"license": "ISC",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"@typescript-eslint/utils": "^8.16.0",
|
|
22
22
|
"@vitest/eslint-plugin": "^1.1.11",
|
|
23
23
|
"confusing-browser-globals": "^1.0.11",
|
|
24
|
+
"eslint-config-prettier": "^9.1.0",
|
|
24
25
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
25
26
|
"eslint-plugin-import-x": "^4.4.3",
|
|
26
27
|
"eslint-plugin-jest": "^28.9.0",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
40
|
+
"@types/eslint-config-prettier": "^6.11.3",
|
|
39
41
|
"@types/eslint-plugin-jsx-a11y": "^6.10.0",
|
|
40
42
|
"@types/eslint__js": "^8.42.3",
|
|
41
43
|
"eslint": "^9.15.0",
|
package/src/configs/cjs.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import prettier from "eslint-config-prettier";
|
|
2
3
|
import globals from "globals";
|
|
3
4
|
import { mergeConfigs } from "../utils/config.js";
|
|
4
5
|
import { recommendedJS, recommendedTS } from "./recommended.js";
|
|
@@ -28,6 +29,7 @@ const cjsJS = mergeConfigs(
|
|
|
28
29
|
},
|
|
29
30
|
rules: cjsRules,
|
|
30
31
|
},
|
|
32
|
+
prettier,
|
|
31
33
|
);
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -49,6 +51,7 @@ const cjsTS = mergeConfigs(
|
|
|
49
51
|
// modify ts specific rules for node here
|
|
50
52
|
},
|
|
51
53
|
},
|
|
54
|
+
prettier,
|
|
52
55
|
);
|
|
53
56
|
|
|
54
57
|
export default [cjsJS, cjsTS];
|
package/src/configs/esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import prettier from "eslint-config-prettier";
|
|
2
3
|
import globals from "globals";
|
|
3
4
|
import { mergeConfigs } from "../utils/config.js";
|
|
4
5
|
import { recommendedJS, recommendedTS } from "./recommended.js";
|
|
@@ -29,6 +30,7 @@ const esmJS = mergeConfigs(
|
|
|
29
30
|
},
|
|
30
31
|
rules: nodeEsmRules,
|
|
31
32
|
},
|
|
33
|
+
prettier,
|
|
32
34
|
);
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -50,6 +52,7 @@ const esmTS = mergeConfigs(
|
|
|
50
52
|
// modify typescript specific rules for node esm here if needed
|
|
51
53
|
},
|
|
52
54
|
},
|
|
55
|
+
prettier,
|
|
53
56
|
);
|
|
54
57
|
|
|
55
58
|
export default [esmJS, esmTS];
|
package/src/configs/react.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import react from "@eslint-react/eslint-plugin";
|
|
3
|
+
import prettier from "eslint-config-prettier";
|
|
3
4
|
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
4
5
|
import eslintPluginReact from "eslint-plugin-react";
|
|
5
6
|
// @ts-expect-error no types for this plugin yet
|
|
@@ -16,38 +17,45 @@ const reactPlugin = eslintPluginReact;
|
|
|
16
17
|
/**
|
|
17
18
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
18
19
|
*/
|
|
19
|
-
const reactBaseConfig =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const reactBaseConfig = mergeConfigs(
|
|
21
|
+
// base it on the recommended react plugins config
|
|
22
|
+
react.configs.recommended,
|
|
23
|
+
reactPlugin.configs.flat.recommended,
|
|
24
|
+
jsxA11y.flatConfigs.recommended,
|
|
25
|
+
// add react-hooks plugin config (no recommended flat config YET!)
|
|
26
|
+
{
|
|
27
|
+
plugins: {
|
|
28
|
+
"react-hooks": reactHooks,
|
|
29
|
+
},
|
|
30
|
+
rules: {
|
|
31
|
+
...reactHooks.configs.recommended.rules,
|
|
26
32
|
},
|
|
27
33
|
},
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
// add qlik's recommended react config
|
|
36
|
+
{
|
|
37
|
+
languageOptions: {
|
|
38
|
+
parserOptions: {
|
|
39
|
+
ecmaFeatures: {
|
|
40
|
+
jsx: true,
|
|
41
|
+
},
|
|
42
|
+
jsxPragma: null, // for @typescript/eslint-parser
|
|
43
|
+
},
|
|
44
|
+
},
|
|
30
45
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
settings: {
|
|
47
|
+
react: {
|
|
48
|
+
version: "detect",
|
|
49
|
+
},
|
|
35
50
|
},
|
|
36
|
-
},
|
|
37
51
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
...jsxA11y.flatConfigs.recommended.rules,
|
|
44
|
-
...reactA11yRules,
|
|
45
|
-
...react.configs.recommended.rules,
|
|
46
|
-
// react-hooks plugin
|
|
47
|
-
...reactHooks.configs.recommended.rules,
|
|
48
|
-
...reactHooksRules,
|
|
52
|
+
rules: {
|
|
53
|
+
...reactRules,
|
|
54
|
+
...reactA11yRules,
|
|
55
|
+
...reactHooksRules,
|
|
56
|
+
},
|
|
49
57
|
},
|
|
50
|
-
|
|
58
|
+
);
|
|
51
59
|
|
|
52
60
|
/**
|
|
53
61
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
@@ -66,6 +74,7 @@ const reactJS = mergeConfigs(
|
|
|
66
74
|
"react/jsx-filename-extension": [2, { extensions: [".js", ".jsx"] }],
|
|
67
75
|
},
|
|
68
76
|
},
|
|
77
|
+
prettier,
|
|
69
78
|
);
|
|
70
79
|
|
|
71
80
|
/**
|
|
@@ -85,6 +94,7 @@ const reactTS = mergeConfigs(
|
|
|
85
94
|
"react/jsx-filename-extension": [2, { extensions: [".js", ".jsx", ".ts", ".tsx"] }],
|
|
86
95
|
},
|
|
87
96
|
},
|
|
97
|
+
prettier,
|
|
88
98
|
);
|
|
89
99
|
|
|
90
100
|
export default [reactJS, reactTS];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import js from "@eslint/js";
|
|
3
3
|
import tsParser from "@typescript-eslint/parser";
|
|
4
|
+
import prettier from "eslint-config-prettier";
|
|
4
5
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
5
6
|
import globals from "globals";
|
|
6
7
|
import tsconfig from "typescript-eslint";
|
|
@@ -43,6 +44,7 @@ const recommendedJS = mergeConfigs(
|
|
|
43
44
|
name: "recommended-js",
|
|
44
45
|
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
|
|
45
46
|
},
|
|
47
|
+
prettier,
|
|
46
48
|
);
|
|
47
49
|
|
|
48
50
|
/**
|
|
@@ -67,6 +69,7 @@ const recommendedTS = mergeConfigs(
|
|
|
67
69
|
},
|
|
68
70
|
rules: typescriptRules,
|
|
69
71
|
},
|
|
72
|
+
prettier,
|
|
70
73
|
);
|
|
71
74
|
|
|
72
75
|
export default [recommendedJS, recommendedTS];
|
|
@@ -30,10 +30,6 @@ const rules = {
|
|
|
30
30
|
// https://eslint.org/docs/rules/consistent-return
|
|
31
31
|
"consistent-return": "error",
|
|
32
32
|
|
|
33
|
-
// specify curly brace conventions for all control statements
|
|
34
|
-
// https://eslint.org/docs/rules/curly
|
|
35
|
-
curly: ["error", "multi-line"], // multiline
|
|
36
|
-
|
|
37
33
|
// require default case in switch statements
|
|
38
34
|
// https://eslint.org/docs/rules/default-case
|
|
39
35
|
"default-case": ["error", { commentPattern: "^no default$" }],
|
|
@@ -502,7 +498,7 @@ const rules = {
|
|
|
502
498
|
|
|
503
499
|
// Avoid code that looks like two expressions but is actually one
|
|
504
500
|
// https://eslint.org/docs/rules/no-unexpected-multiline
|
|
505
|
-
"no-unexpected-multiline": "
|
|
501
|
+
"no-unexpected-multiline": "off",
|
|
506
502
|
|
|
507
503
|
// disallow unreachable statements after a return, throw, continue, or break statement
|
|
508
504
|
"no-unreachable": "error",
|
|
@@ -128,7 +128,7 @@ const rules = {
|
|
|
128
128
|
"import-x/no-self-import": "error",
|
|
129
129
|
// Forbid cyclical dependencies between modules
|
|
130
130
|
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-cycle.md
|
|
131
|
-
"import-x/no-cycle": ["error", {
|
|
131
|
+
"import-x/no-cycle": ["error", { ignoreExternal: true }],
|
|
132
132
|
// Ensures that there are no useless path segments
|
|
133
133
|
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
|
|
134
134
|
"import-x/no-useless-path-segments": ["error", { commonjs: true }],
|
|
@@ -43,26 +43,6 @@ const rules = {
|
|
|
43
43
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
44
44
|
"react/jsx-boolean-value": ["error", "never", { always: [] }],
|
|
45
45
|
|
|
46
|
-
// Validate closing bracket location in JSX
|
|
47
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
|
|
48
|
-
"react/jsx-closing-bracket-location": ["error", "line-aligned"],
|
|
49
|
-
|
|
50
|
-
// Validate closing tag location in JSX
|
|
51
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
52
|
-
"react/jsx-closing-tag-location": "error",
|
|
53
|
-
|
|
54
|
-
// Enforce or disallow spaces inside of curly braces in JSX attributes
|
|
55
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
|
|
56
|
-
"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
|
|
57
|
-
|
|
58
|
-
// Validate props indentation in JSX
|
|
59
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
|
|
60
|
-
"react/jsx-indent-props": ["error", 2],
|
|
61
|
-
|
|
62
|
-
// Limit maximum of props on a single line in JSX
|
|
63
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
|
|
64
|
-
"react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
|
|
65
|
-
|
|
66
46
|
// Prevent usage of .bind() in JSX props
|
|
67
47
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
|
|
68
48
|
"react/jsx-no-bind": [
|
|
@@ -215,22 +195,7 @@ const rules = {
|
|
|
215
195
|
|
|
216
196
|
// Prevent missing parentheses around multilines JSX
|
|
217
197
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
|
|
218
|
-
"react/jsx-wrap-multilines":
|
|
219
|
-
"error",
|
|
220
|
-
{
|
|
221
|
-
declaration: "parens-new-line",
|
|
222
|
-
assignment: "parens-new-line",
|
|
223
|
-
return: "parens-new-line",
|
|
224
|
-
arrow: "parens-new-line",
|
|
225
|
-
condition: "parens-new-line",
|
|
226
|
-
logical: "parens-new-line",
|
|
227
|
-
prop: "ignore",
|
|
228
|
-
},
|
|
229
|
-
],
|
|
230
|
-
|
|
231
|
-
// Require that the first prop in a JSX element be on a new line when the element is multiline
|
|
232
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
|
233
|
-
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
198
|
+
"react/jsx-wrap-multilines": "off",
|
|
234
199
|
|
|
235
200
|
// Stylistic, Prettier handles this.
|
|
236
201
|
// Enforce spacing around jsx equals signs
|
|
@@ -290,15 +255,7 @@ const rules = {
|
|
|
290
255
|
|
|
291
256
|
// Validate whitespace in and around the JSX opening and closing brackets
|
|
292
257
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
|
|
293
|
-
"react/jsx-tag-spacing":
|
|
294
|
-
"error",
|
|
295
|
-
{
|
|
296
|
-
closingSlash: "never",
|
|
297
|
-
beforeSelfClosing: "always",
|
|
298
|
-
afterOpening: "never",
|
|
299
|
-
beforeClosing: "never",
|
|
300
|
-
},
|
|
301
|
-
],
|
|
258
|
+
"react/jsx-tag-spacing": "off",
|
|
302
259
|
|
|
303
260
|
// Prevent usage of Array index in keys
|
|
304
261
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
@@ -369,22 +326,12 @@ const rules = {
|
|
|
369
326
|
|
|
370
327
|
// Disallow multiple spaces between inline JSX props
|
|
371
328
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
|
|
372
|
-
"react/jsx-props-no-multi-spaces": "
|
|
329
|
+
"react/jsx-props-no-multi-spaces": "off",
|
|
373
330
|
|
|
374
331
|
// Enforce shorthand or standard form for React fragments
|
|
375
332
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
376
333
|
"react/jsx-fragments": ["error", "syntax"],
|
|
377
334
|
|
|
378
|
-
// Enforce linebreaks in curly braces in JSX attributes and expressions.
|
|
379
|
-
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
|
|
380
|
-
"react/jsx-curly-newline": [
|
|
381
|
-
"error",
|
|
382
|
-
{
|
|
383
|
-
multiline: "consistent",
|
|
384
|
-
singleline: "consistent",
|
|
385
|
-
},
|
|
386
|
-
],
|
|
387
|
-
|
|
388
335
|
// Enforce state initialization style
|
|
389
336
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
|
|
390
337
|
"react/state-in-constructor": ["error", "never"],
|
package/src/configs/svelte.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import prettier from "eslint-config-prettier";
|
|
2
3
|
import eslintPluginSvelte from "eslint-plugin-svelte";
|
|
3
4
|
import svelteParser from "svelte-eslint-parser";
|
|
4
5
|
import tsEslint from "typescript-eslint";
|
|
@@ -48,6 +49,7 @@ const svelteSvelte = mergeConfigs(
|
|
|
48
49
|
"no-unused-vars": "off",
|
|
49
50
|
},
|
|
50
51
|
},
|
|
52
|
+
prettier,
|
|
51
53
|
);
|
|
52
54
|
|
|
53
55
|
export default [recommendedJS, recommendedTS, svelteSvelte];
|
package/src/utils/compose.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { mergeConfigs } from "./config.js";
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Utility function to make it easy to strictly type your "Flat" config file
|
|
4
7
|
*
|
|
@@ -33,6 +36,7 @@ export default function compose(...configs) {
|
|
|
33
36
|
if (extendArr == null || extendArr.length === 0) {
|
|
34
37
|
return config;
|
|
35
38
|
}
|
|
39
|
+
|
|
36
40
|
const undefinedExtensions = extendArr.reduce((acc, extension, extensionIndex) => {
|
|
37
41
|
const maybeExtension = extension;
|
|
38
42
|
if (maybeExtension == null) {
|
|
@@ -52,14 +56,8 @@ export default function compose(...configs) {
|
|
|
52
56
|
return [
|
|
53
57
|
...extendArr.map((extension) => {
|
|
54
58
|
const name = [config.name, extension.name].filter(Boolean).join("__");
|
|
55
|
-
return {
|
|
56
|
-
...extension,
|
|
57
|
-
...(config.files && { files: config.files }),
|
|
58
|
-
...(config.ignores && { ignores: config.ignores }),
|
|
59
|
-
...(name && { name }),
|
|
60
|
-
};
|
|
59
|
+
return mergeConfigs(extension, config, name ? { name } : {});
|
|
61
60
|
}),
|
|
62
|
-
config,
|
|
63
61
|
];
|
|
64
62
|
});
|
|
65
63
|
}
|
package/src/utils/merge.js
CHANGED