@qlik/eslint-config 1.2.3 → 1.3.0
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/package.json +6 -6
- package/src/configs/cjs.js +32 -27
- package/src/configs/esbrowser.js +33 -4
- package/src/configs/esm.js +33 -4
- package/src/configs/react.js +31 -5
- package/src/configs/recommended.js +33 -51
- package/src/configs/shared/base.js +68 -0
- package/src/configs/shared/node.js +109 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlik/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Qlik's ESLint configs",
|
|
5
5
|
"repository": "git@github.com:qlik-oss/dev-tools-js.git",
|
|
6
6
|
"license": "ISC",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"!**/__tests__"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
18
|
+
"@eslint-react/eslint-plugin": "^1.38.0",
|
|
19
19
|
"@eslint/js": "^9.23.0",
|
|
20
|
-
"@typescript-eslint/parser": "^8.
|
|
21
|
-
"@typescript-eslint/utils": "^8.
|
|
20
|
+
"@typescript-eslint/parser": "^8.28.0",
|
|
21
|
+
"@typescript-eslint/utils": "^8.28.0",
|
|
22
22
|
"@vitest/eslint-plugin": "^1.1.38",
|
|
23
23
|
"confusing-browser-globals": "^1.0.11",
|
|
24
24
|
"eslint-config-prettier": "^10.1.1",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"eslint-plugin-testing-library": "^7.1.1",
|
|
34
34
|
"globals": "^16.0.0",
|
|
35
35
|
"svelte-eslint-parser": "^1.1.0",
|
|
36
|
-
"typescript-eslint": "^8.
|
|
36
|
+
"typescript-eslint": "^8.28.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
40
40
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
41
41
|
"@types/eslint-plugin-jsx-a11y": "^6.10.0",
|
|
42
42
|
"@types/eslint__js": "^9.14.0",
|
|
43
|
-
"@types/node": "^22.13.
|
|
43
|
+
"@types/node": "^22.13.13",
|
|
44
44
|
"eslint": "^9.23.0",
|
|
45
45
|
"prettier": "^3.5.3",
|
|
46
46
|
"vitest": "^3.0.9",
|
package/src/configs/cjs.js
CHANGED
|
@@ -1,58 +1,63 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import prettier from "eslint-config-prettier";
|
|
3
|
-
import globals from "globals";
|
|
4
3
|
import { mergeConfigs } from "../utils/config.js";
|
|
5
|
-
import {
|
|
6
|
-
import nodeRules from "./rules/node.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @satisfies {import("../types/index.js").ESLintFlatConfig['rules']}
|
|
10
|
-
*/
|
|
11
|
-
const cjsRules = {
|
|
12
|
-
...nodeRules,
|
|
13
|
-
// modify rules for node commonjs here
|
|
14
|
-
};
|
|
4
|
+
import { baseCjsJS, baseCjsTS, baseEsmJS, baseEsmTS } from "./shared/node.js";
|
|
15
5
|
|
|
16
6
|
/**
|
|
7
|
+
* CJS config for javascript in node
|
|
17
8
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
18
9
|
*/
|
|
19
10
|
const cjsJS = mergeConfigs(
|
|
20
11
|
// base it on the recommended javascript config
|
|
21
|
-
|
|
12
|
+
baseCjsJS,
|
|
22
13
|
// add qlik's recommended node commonjs config for javascript
|
|
23
14
|
{
|
|
24
15
|
name: "node-cjs-js",
|
|
25
16
|
files: ["**/*.{js,cjs}"],
|
|
26
|
-
languageOptions: {
|
|
27
|
-
globals: globals.node,
|
|
28
|
-
sourceType: "commonjs",
|
|
29
|
-
},
|
|
30
|
-
rules: cjsRules,
|
|
31
17
|
},
|
|
32
18
|
prettier,
|
|
33
19
|
);
|
|
34
20
|
|
|
35
21
|
/**
|
|
22
|
+
* CJS config for typescript in node
|
|
36
23
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
37
24
|
*/
|
|
38
25
|
const cjsTS = mergeConfigs(
|
|
39
26
|
// base it on the recommended typescript config
|
|
40
|
-
|
|
27
|
+
baseCjsTS,
|
|
41
28
|
// add qlik's recommended node commonjs config for typescript
|
|
42
29
|
{
|
|
43
30
|
name: "node-cjs-ts",
|
|
44
31
|
files: ["**/*.{ts,cts}"],
|
|
45
|
-
languageOptions: {
|
|
46
|
-
globals: globals.node,
|
|
47
|
-
sourceType: "commonjs",
|
|
48
|
-
},
|
|
49
|
-
rules: {
|
|
50
|
-
...cjsRules,
|
|
51
|
-
// modify ts specific rules for node here
|
|
52
|
-
},
|
|
53
32
|
},
|
|
54
33
|
prettier,
|
|
55
34
|
);
|
|
56
35
|
|
|
57
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Adding esm config for .mjs files
|
|
38
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
39
|
+
*/
|
|
40
|
+
const cjsMJS = mergeConfigs(
|
|
41
|
+
baseEsmJS,
|
|
42
|
+
{
|
|
43
|
+
name: "node-cjs-mjs",
|
|
44
|
+
files: ["**/*.mjs"],
|
|
45
|
+
},
|
|
46
|
+
prettier,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Adding esm config for .mts files
|
|
51
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
52
|
+
*/
|
|
53
|
+
const cjsMTS = mergeConfigs(
|
|
54
|
+
baseEsmTS,
|
|
55
|
+
{
|
|
56
|
+
name: "node-cjs-mts",
|
|
57
|
+
files: ["**/*.mts"],
|
|
58
|
+
},
|
|
59
|
+
prettier,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export default [cjsJS, cjsTS, cjsMJS, cjsMTS];
|
|
58
63
|
export { cjsJS, cjsTS };
|
package/src/configs/esbrowser.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import prettier from "eslint-config-prettier";
|
|
3
3
|
import globals from "globals";
|
|
4
4
|
import { mergeConfigs } from "../utils/config.js";
|
|
5
|
-
import {
|
|
5
|
+
import { baseConfigJS, baseConfigTS } from "./shared/base.js";
|
|
6
|
+
import { baseCjsJS, baseCjsTS } from "./shared/node.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @satisfies {import("../types/index.js").ESLintFlatConfig["rules"]}
|
|
@@ -24,11 +25,12 @@ const browserEsmRules = {
|
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
/**
|
|
28
|
+
* ESM config for javascript in browsers
|
|
27
29
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
28
30
|
*/
|
|
29
31
|
const esbrowserJS = mergeConfigs(
|
|
30
32
|
// base it on the recommended javascript config
|
|
31
|
-
|
|
33
|
+
baseConfigJS,
|
|
32
34
|
// add qlik's recommended node esm config for javascript
|
|
33
35
|
{
|
|
34
36
|
name: "esbrowser-js",
|
|
@@ -46,11 +48,12 @@ const esbrowserJS = mergeConfigs(
|
|
|
46
48
|
);
|
|
47
49
|
|
|
48
50
|
/**
|
|
51
|
+
* ESM config for typescript in browsers
|
|
49
52
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
50
53
|
*/
|
|
51
54
|
const esbrowserTS = mergeConfigs(
|
|
52
55
|
// base it on the recommended typescript config
|
|
53
|
-
|
|
56
|
+
baseConfigTS,
|
|
54
57
|
// add qlik's recommended node esm config for typescript
|
|
55
58
|
{
|
|
56
59
|
name: "esbrowser-ts",
|
|
@@ -67,5 +70,31 @@ const esbrowserTS = mergeConfigs(
|
|
|
67
70
|
prettier,
|
|
68
71
|
);
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Adding commonjs config for .cjs files
|
|
75
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
76
|
+
*/
|
|
77
|
+
const esbrowserCJS = mergeConfigs(
|
|
78
|
+
baseCjsJS,
|
|
79
|
+
{
|
|
80
|
+
name: "browser-esm-cjs",
|
|
81
|
+
files: ["**/*.cjs"],
|
|
82
|
+
},
|
|
83
|
+
prettier,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Adding commonjs config for .cts files
|
|
88
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
89
|
+
*/
|
|
90
|
+
const esbrowserCTS = mergeConfigs(
|
|
91
|
+
baseCjsTS,
|
|
92
|
+
{
|
|
93
|
+
name: "browser-esm-cts",
|
|
94
|
+
files: ["**/*.cts"],
|
|
95
|
+
},
|
|
96
|
+
prettier,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
export default [esbrowserJS, esbrowserTS, esbrowserCJS, esbrowserCTS];
|
|
71
100
|
export { esbrowserJS, esbrowserTS };
|
package/src/configs/esm.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import prettier from "eslint-config-prettier";
|
|
3
3
|
import globals from "globals";
|
|
4
4
|
import { mergeConfigs } from "../utils/config.js";
|
|
5
|
-
import { recommendedJS, recommendedTS } from "./recommended.js";
|
|
6
5
|
import nodeRules from "./rules/node.js";
|
|
6
|
+
import { baseConfigJS, baseConfigTS } from "./shared/base.js";
|
|
7
|
+
import { baseCjsJS, baseCjsTS } from "./shared/node.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @satisfies {import("../types/index.js").ESLintFlatConfig["rules"]}
|
|
@@ -26,11 +27,12 @@ const nodeEsmRules = {
|
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
/**
|
|
30
|
+
* ESM config for javascript in node
|
|
29
31
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
30
32
|
*/
|
|
31
33
|
const esmJS = mergeConfigs(
|
|
32
34
|
// base it on the recommended javascript config
|
|
33
|
-
|
|
35
|
+
baseConfigJS,
|
|
34
36
|
// add qlik's recommended node esm config for javascript
|
|
35
37
|
{
|
|
36
38
|
name: "node-esm-js",
|
|
@@ -45,11 +47,12 @@ const esmJS = mergeConfigs(
|
|
|
45
47
|
);
|
|
46
48
|
|
|
47
49
|
/**
|
|
50
|
+
* ESM config for typescript in node
|
|
48
51
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
49
52
|
*/
|
|
50
53
|
const esmTS = mergeConfigs(
|
|
51
54
|
// base it on the recommended typescript config
|
|
52
|
-
|
|
55
|
+
baseConfigTS,
|
|
53
56
|
// add qlik's recommended node esm config for typescript
|
|
54
57
|
{
|
|
55
58
|
name: "node-esm-ts",
|
|
@@ -66,5 +69,31 @@ const esmTS = mergeConfigs(
|
|
|
66
69
|
prettier,
|
|
67
70
|
);
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Adding commonjs config for .cjs files
|
|
74
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
75
|
+
*/
|
|
76
|
+
const esmCJS = mergeConfigs(
|
|
77
|
+
baseCjsJS,
|
|
78
|
+
{
|
|
79
|
+
name: "node-esm-cjs",
|
|
80
|
+
files: ["**/*.cjs"],
|
|
81
|
+
},
|
|
82
|
+
prettier,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Adding commonjs config for .cts files
|
|
87
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
88
|
+
*/
|
|
89
|
+
const esmCTS = mergeConfigs(
|
|
90
|
+
baseCjsTS,
|
|
91
|
+
{
|
|
92
|
+
name: "node-esm-cts",
|
|
93
|
+
files: ["**/*.cts"],
|
|
94
|
+
},
|
|
95
|
+
prettier,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export default [esmJS, esmTS, esmCJS, esmCTS];
|
|
70
99
|
export { esmJS, esmTS };
|
package/src/configs/react.js
CHANGED
|
@@ -3,13 +3,13 @@ import react from "@eslint-react/eslint-plugin";
|
|
|
3
3
|
import prettier from "eslint-config-prettier";
|
|
4
4
|
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
5
5
|
import eslintPluginReact from "eslint-plugin-react";
|
|
6
|
-
// @ts-expect-error no types for this plugin yet
|
|
7
6
|
import reactHooks from "eslint-plugin-react-hooks";
|
|
8
7
|
import { mergeConfigs } from "../utils/config.js";
|
|
9
|
-
import { recommendedJS, recommendedTS } from "./recommended.js";
|
|
10
8
|
import reactA11yRules from "./rules/react-a11y.js";
|
|
11
9
|
import reactHooksRules from "./rules/react-hooks.js";
|
|
12
10
|
import reactRules from "./rules/react.js";
|
|
11
|
+
import { baseConfigJS, baseConfigTS } from "./shared/base.js";
|
|
12
|
+
import { baseCjsJS, baseCjsTS } from "./shared/node.js";
|
|
13
13
|
|
|
14
14
|
/** @type {any} */
|
|
15
15
|
const reactPlugin = eslintPluginReact;
|
|
@@ -62,7 +62,7 @@ const reactBaseConfig = mergeConfigs(
|
|
|
62
62
|
*/
|
|
63
63
|
const reactJS = mergeConfigs(
|
|
64
64
|
// base it on the recommended javascript config
|
|
65
|
-
|
|
65
|
+
baseConfigJS,
|
|
66
66
|
// add the base react config
|
|
67
67
|
reactBaseConfig,
|
|
68
68
|
// add qlik's recommended react config for javascript
|
|
@@ -82,7 +82,7 @@ const reactJS = mergeConfigs(
|
|
|
82
82
|
*/
|
|
83
83
|
const reactTS = mergeConfigs(
|
|
84
84
|
// base it on the recommended typescript config
|
|
85
|
-
|
|
85
|
+
baseConfigTS,
|
|
86
86
|
// add the base react config
|
|
87
87
|
reactBaseConfig,
|
|
88
88
|
// add qlik's recommended react config for typescript
|
|
@@ -100,5 +100,31 @@ const reactTS = mergeConfigs(
|
|
|
100
100
|
prettier,
|
|
101
101
|
);
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Adding commonjs config for .cjs files
|
|
105
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
106
|
+
*/
|
|
107
|
+
const reactCJS = mergeConfigs(
|
|
108
|
+
baseCjsJS,
|
|
109
|
+
{
|
|
110
|
+
name: "react-cjs",
|
|
111
|
+
files: ["**/*.cjs"],
|
|
112
|
+
},
|
|
113
|
+
prettier,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Adding commonjs config for .cts files
|
|
118
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
119
|
+
*/
|
|
120
|
+
const reactCTS = mergeConfigs(
|
|
121
|
+
baseCjsTS,
|
|
122
|
+
{
|
|
123
|
+
name: "react-cts",
|
|
124
|
+
files: ["**/*.cts"],
|
|
125
|
+
},
|
|
126
|
+
prettier,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
export default [reactJS, reactTS, reactCJS, reactCTS];
|
|
104
130
|
export { reactJS, reactTS };
|
|
@@ -1,48 +1,17 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import js from "@eslint/js";
|
|
3
|
-
import tsParser from "@typescript-eslint/parser";
|
|
4
2
|
import prettier from "eslint-config-prettier";
|
|
5
|
-
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
6
|
-
import globals from "globals";
|
|
7
|
-
import tsconfig from "typescript-eslint";
|
|
8
3
|
import { mergeConfigs } from "../utils/config.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import typescriptRules from "./rules/typescript.js";
|
|
12
|
-
|
|
13
|
-
const baseConfig = mergeConfigs(
|
|
14
|
-
// basic js config
|
|
15
|
-
js.configs.recommended,
|
|
16
|
-
// import-x plugin config
|
|
17
|
-
eslintPluginImportX.flatConfigs.recommended,
|
|
18
|
-
{
|
|
19
|
-
languageOptions: {
|
|
20
|
-
globals: globals.browser,
|
|
21
|
-
parserOptions: {
|
|
22
|
-
warnOnUnsupportedTypeScriptVersion: false,
|
|
23
|
-
},
|
|
24
|
-
ecmaVersion: "latest",
|
|
25
|
-
sourceType: "module",
|
|
26
|
-
},
|
|
27
|
-
rules: {
|
|
28
|
-
// add our recommended rules
|
|
29
|
-
...eslintCoreRules,
|
|
30
|
-
...importXRules,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
);
|
|
4
|
+
import { baseConfigJS, baseConfigTS } from "./shared/base.js";
|
|
5
|
+
import { baseCjsJS, baseCjsTS } from "./shared/node.js";
|
|
34
6
|
|
|
35
7
|
/**
|
|
36
8
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
37
9
|
*/
|
|
38
10
|
const recommendedJS = mergeConfigs(
|
|
39
|
-
|
|
40
|
-
// tsconfig.configs.base sets eslint parser to use the typescript parser to parse .js files - handles all modern syntax
|
|
41
|
-
tsconfig.configs.base,
|
|
42
|
-
// add qlik's recommended javascript config
|
|
11
|
+
baseConfigJS,
|
|
43
12
|
{
|
|
44
13
|
name: "recommended-js",
|
|
45
|
-
files: ["**/*.js", "**/*.mjs"
|
|
14
|
+
files: ["**/*.js", "**/*.mjs"],
|
|
46
15
|
},
|
|
47
16
|
prettier,
|
|
48
17
|
);
|
|
@@ -51,26 +20,39 @@ const recommendedJS = mergeConfigs(
|
|
|
51
20
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
52
21
|
*/
|
|
53
22
|
const recommendedTS = mergeConfigs(
|
|
54
|
-
|
|
55
|
-
baseConfig,
|
|
56
|
-
// add recommended typescript config
|
|
57
|
-
...tsconfig.configs.recommended,
|
|
58
|
-
// add import-x recommended typescript config
|
|
59
|
-
eslintPluginImportX.flatConfigs.typescript,
|
|
60
|
-
// add qlik's recommended typescript config
|
|
23
|
+
baseConfigTS,
|
|
61
24
|
{
|
|
62
25
|
name: "recommended-ts",
|
|
63
|
-
files: ["**/*.ts", "**/*.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
26
|
+
files: ["**/*.ts", "**/*.mts", "**/*.d.ts"],
|
|
27
|
+
},
|
|
28
|
+
prettier,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A .cjs file is a CommonJS file, which is a module format used in Node.js.
|
|
33
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
34
|
+
*/
|
|
35
|
+
const recommendedCJS = mergeConfigs(
|
|
36
|
+
baseCjsJS,
|
|
37
|
+
{
|
|
38
|
+
name: "recommended-cjs",
|
|
39
|
+
files: ["**/*.cjs"],
|
|
40
|
+
},
|
|
41
|
+
prettier,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A .cts file is a CommonJS file, which is a module format used in Node.js.
|
|
46
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
47
|
+
*/
|
|
48
|
+
const recommendedCTS = mergeConfigs(
|
|
49
|
+
baseCjsTS,
|
|
50
|
+
{
|
|
51
|
+
name: "recommended-cts",
|
|
52
|
+
files: ["**/*.cts"],
|
|
71
53
|
},
|
|
72
54
|
prettier,
|
|
73
55
|
);
|
|
74
56
|
|
|
75
|
-
export default [recommendedJS, recommendedTS];
|
|
57
|
+
export default [recommendedJS, recommendedTS, recommendedCJS, recommendedCTS];
|
|
76
58
|
export { recommendedJS, recommendedTS };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import tsParser from "@typescript-eslint/parser";
|
|
3
|
+
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
4
|
+
import globals from "globals";
|
|
5
|
+
import tsconfig from "typescript-eslint";
|
|
6
|
+
import { mergeConfigs } from "../../utils/config.js";
|
|
7
|
+
import eslintCoreRules from "../rules/eslint-core.js";
|
|
8
|
+
import importXRules from "../rules/import-x.js";
|
|
9
|
+
import typescriptRules from "../rules/typescript.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type {import("../../types/index.js").ESLintFlatConfig}
|
|
13
|
+
*/
|
|
14
|
+
const baseConfig = mergeConfigs(
|
|
15
|
+
// basic js config
|
|
16
|
+
js.configs.recommended,
|
|
17
|
+
// import-x plugin config
|
|
18
|
+
eslintPluginImportX.flatConfigs.recommended,
|
|
19
|
+
{
|
|
20
|
+
languageOptions: {
|
|
21
|
+
globals: globals.browser,
|
|
22
|
+
parserOptions: {
|
|
23
|
+
warnOnUnsupportedTypeScriptVersion: false,
|
|
24
|
+
},
|
|
25
|
+
ecmaVersion: "latest",
|
|
26
|
+
sourceType: "module",
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
// add our recommended rules
|
|
30
|
+
...eslintCoreRules,
|
|
31
|
+
...importXRules,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @type {import("../../types/index.js").ESLintFlatConfig}
|
|
38
|
+
*/
|
|
39
|
+
const baseConfigJS = mergeConfigs(
|
|
40
|
+
baseConfig,
|
|
41
|
+
// tsconfig.configs.base sets eslint parser to use the typescript parser to parse .js files - handles all modern syntax
|
|
42
|
+
tsconfig.configs.base,
|
|
43
|
+
// add qlik's recommended javascript config
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @type {import("../../types/index.js").ESLintFlatConfig}
|
|
48
|
+
*/
|
|
49
|
+
const baseConfigTS = mergeConfigs(
|
|
50
|
+
// base it on base config
|
|
51
|
+
baseConfig,
|
|
52
|
+
// add recommended typescript config
|
|
53
|
+
...tsconfig.configs.recommended,
|
|
54
|
+
// add import-x recommended typescript config
|
|
55
|
+
eslintPluginImportX.flatConfigs.typescript,
|
|
56
|
+
// add qlik's recommended typescript config
|
|
57
|
+
{
|
|
58
|
+
languageOptions: {
|
|
59
|
+
parserOptions: {
|
|
60
|
+
parser: tsParser,
|
|
61
|
+
projectService: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
rules: typescriptRules,
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
export { baseConfigJS, baseConfigTS };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import { mergeConfigs } from "../../utils/config.js";
|
|
4
|
+
import nodeRules from "../rules/node.js";
|
|
5
|
+
import { baseConfigJS, baseConfigTS } from "./base.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @satisfies {import("../../types/index.js").ESLintFlatConfig['rules']}
|
|
9
|
+
*/
|
|
10
|
+
const cjsRules = {
|
|
11
|
+
...nodeRules,
|
|
12
|
+
// modify rules for node commonjs here
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* CJS config for javascript in node
|
|
17
|
+
* @type {import("../../types/index.js").ESLintFlatConfig}
|
|
18
|
+
*/
|
|
19
|
+
const baseCjsJS = mergeConfigs(
|
|
20
|
+
// base it on the recommended javascript config
|
|
21
|
+
baseConfigJS,
|
|
22
|
+
// add qlik's recommended node commonjs config for javascript
|
|
23
|
+
{
|
|
24
|
+
languageOptions: {
|
|
25
|
+
globals: globals.node,
|
|
26
|
+
sourceType: "commonjs",
|
|
27
|
+
},
|
|
28
|
+
rules: cjsRules,
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* CJS config for typescript in node
|
|
34
|
+
* @type {import("../../types/index.js").ESLintFlatConfig}
|
|
35
|
+
*/
|
|
36
|
+
const baseCjsTS = mergeConfigs(
|
|
37
|
+
// base it on the recommended typescript config
|
|
38
|
+
baseConfigTS,
|
|
39
|
+
// add qlik's recommended node commonjs config for typescript
|
|
40
|
+
{
|
|
41
|
+
languageOptions: {
|
|
42
|
+
globals: globals.node,
|
|
43
|
+
sourceType: "commonjs",
|
|
44
|
+
},
|
|
45
|
+
rules: {
|
|
46
|
+
...cjsRules,
|
|
47
|
+
// modify ts specific rules for node here
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
|
|
54
|
+
*/
|
|
55
|
+
const nodeEsmRules = {
|
|
56
|
+
...nodeRules,
|
|
57
|
+
// modify rules for node esm here
|
|
58
|
+
|
|
59
|
+
// Ensure consistent use of file extension within the import path
|
|
60
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
|
|
61
|
+
"import-x/extensions": [
|
|
62
|
+
"error",
|
|
63
|
+
"ignorePackages",
|
|
64
|
+
{
|
|
65
|
+
ts: "never",
|
|
66
|
+
mts: "never",
|
|
67
|
+
tsx: "never",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* ESM config for javascript in node
|
|
74
|
+
* @type {import("../../types/index.js").ESLintFlatConfig}
|
|
75
|
+
*/
|
|
76
|
+
const baseEsmJS = mergeConfigs(
|
|
77
|
+
// base it on the recommended javascript config
|
|
78
|
+
baseConfigJS,
|
|
79
|
+
// add qlik's recommended node esm config for javascript
|
|
80
|
+
{
|
|
81
|
+
languageOptions: {
|
|
82
|
+
globals: globals.node,
|
|
83
|
+
sourceType: "module",
|
|
84
|
+
},
|
|
85
|
+
rules: nodeEsmRules,
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ESM config for typescript in node
|
|
91
|
+
* @type {import("../../types/index.js").ESLintFlatConfig}
|
|
92
|
+
*/
|
|
93
|
+
const baseEsmTS = mergeConfigs(
|
|
94
|
+
// base it on the recommended typescript config
|
|
95
|
+
baseConfigTS,
|
|
96
|
+
// add qlik's recommended node esm config for typescript
|
|
97
|
+
{
|
|
98
|
+
languageOptions: {
|
|
99
|
+
globals: globals.node,
|
|
100
|
+
sourceType: "module",
|
|
101
|
+
},
|
|
102
|
+
rules: {
|
|
103
|
+
...nodeEsmRules,
|
|
104
|
+
// modify typescript specific rules for node esm here if needed
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
export { baseCjsJS, baseCjsTS, baseEsmJS, baseEsmTS };
|