@qlik/eslint-config 1.0.0 → 1.0.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/package.json +3 -3
- package/src/configs/cjs.js +4 -1
- package/src/configs/esm.js +6 -3
- package/src/configs/react.js +4 -4
- package/src/configs/recommended.js +16 -12
- package/src/configs/rules/eslint-core.js +6 -12
- package/src/configs/rules/index.js +4 -2
- package/src/configs/rules/node.js +1 -0
- package/src/configs/rules/react.js +2 -4
- package/src/configs/rules/typescript.js +3 -3
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlik/eslint-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Qlik's ESLint configs",
|
|
5
5
|
"repository": "git@github.com:qlik-oss/dev-tools-js.git",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
|
-
".": "./
|
|
9
|
+
".": "./src/index.js"
|
|
10
10
|
},
|
|
11
11
|
"module": "./src/index.js",
|
|
12
12
|
"types": "./src/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@eslint-react/eslint-plugin": "1.17.1",
|
|
20
20
|
"@eslint/js": "^9.15.0",
|
|
21
21
|
"@typescript-eslint/utils": "^8.16.0",
|
|
22
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
22
|
+
"@vitest/eslint-plugin": "^1.1.11",
|
|
23
23
|
"confusing-browser-globals": "^1.0.11",
|
|
24
24
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
25
25
|
"eslint-plugin-import-x": "^4.4.3",
|
package/src/configs/cjs.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import globals from "globals";
|
|
3
3
|
import { mergeConfigs } from "../utils/config.js";
|
|
4
4
|
import { recommendedJS, recommendedTS } from "./recommended.js";
|
|
5
|
+
import rules from "./rules/index.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @satisfies {import("../types/index.js").ESLintFlatConfig['rules']}
|
|
8
9
|
*/
|
|
9
10
|
const cjsRules = {
|
|
10
|
-
// modify rules for node here
|
|
11
|
+
// modify rules for node commonjs here
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -21,6 +22,7 @@ const cjsJS = mergeConfigs(recommendedJS, {
|
|
|
21
22
|
sourceType: "commonjs",
|
|
22
23
|
},
|
|
23
24
|
rules: {
|
|
25
|
+
...rules.nodeRules,
|
|
24
26
|
...cjsRules,
|
|
25
27
|
},
|
|
26
28
|
});
|
|
@@ -36,6 +38,7 @@ const cjsTS = mergeConfigs(recommendedTS, {
|
|
|
36
38
|
sourceType: "commonjs",
|
|
37
39
|
},
|
|
38
40
|
rules: {
|
|
41
|
+
...rules.nodeRules,
|
|
39
42
|
...cjsRules,
|
|
40
43
|
// modify ts specific rules for node here
|
|
41
44
|
},
|
package/src/configs/esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import globals from "globals";
|
|
2
3
|
import { mergeConfigs } from "../utils/config.js";
|
|
3
|
-
import {
|
|
4
|
+
import { recommendedJS, recommendedTS } from "./recommended.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @satisfies {import("../types/index.js").ESLintFlatConfig["rules"]}
|
|
@@ -13,10 +14,11 @@ const nodeEsmRules = {
|
|
|
13
14
|
/**
|
|
14
15
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
15
16
|
*/
|
|
16
|
-
const esmJS = mergeConfigs(
|
|
17
|
+
const esmJS = mergeConfigs(recommendedJS, {
|
|
17
18
|
name: "node-esm-js",
|
|
18
19
|
files: ["**/*.{js,mjs}"],
|
|
19
20
|
languageOptions: {
|
|
21
|
+
globals: globals.node,
|
|
20
22
|
sourceType: "module",
|
|
21
23
|
},
|
|
22
24
|
rules: {
|
|
@@ -27,10 +29,11 @@ const esmJS = mergeConfigs(cjsJS, {
|
|
|
27
29
|
/**
|
|
28
30
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
29
31
|
*/
|
|
30
|
-
const esmTS = mergeConfigs(
|
|
32
|
+
const esmTS = mergeConfigs(recommendedTS, {
|
|
31
33
|
name: "node-esm-ts",
|
|
32
34
|
files: ["**/*.{ts,mts}"],
|
|
33
35
|
languageOptions: {
|
|
36
|
+
globals: globals.node,
|
|
34
37
|
sourceType: "module",
|
|
35
38
|
},
|
|
36
39
|
rules: {
|
package/src/configs/react.js
CHANGED
|
@@ -14,7 +14,7 @@ const reactPlugin = eslintPluginReact;
|
|
|
14
14
|
/**
|
|
15
15
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
16
16
|
*/
|
|
17
|
-
const reactConfig =
|
|
17
|
+
const reactConfig = {
|
|
18
18
|
languageOptions: {
|
|
19
19
|
parserOptions: {
|
|
20
20
|
ecmaFeatures: {
|
|
@@ -45,12 +45,12 @@ const reactConfig = mergeConfigs({
|
|
|
45
45
|
...reactHooks.configs.recommended.rules,
|
|
46
46
|
...rules.reactHooksRules,
|
|
47
47
|
},
|
|
48
|
-
}
|
|
48
|
+
};
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
52
52
|
*/
|
|
53
|
-
const reactJS = mergeConfigs(reactConfig,
|
|
53
|
+
const reactJS = mergeConfigs(reactConfig, {
|
|
54
54
|
name: "react-js",
|
|
55
55
|
files: ["**/*.jsx"],
|
|
56
56
|
rules: {
|
|
@@ -62,7 +62,7 @@ const reactJS = mergeConfigs(reactConfig, recommendedJS, {
|
|
|
62
62
|
/**
|
|
63
63
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
64
64
|
*/
|
|
65
|
-
const reactTS = mergeConfigs(reactConfig,
|
|
65
|
+
const reactTS = mergeConfigs(reactConfig, {
|
|
66
66
|
name: "react-ts",
|
|
67
67
|
files: ["**/*.tsx"],
|
|
68
68
|
rules: {
|
|
@@ -7,27 +7,20 @@ import tsconfig from "typescript-eslint";
|
|
|
7
7
|
import { mergeConfigs } from "../utils/config.js";
|
|
8
8
|
import rules from "./rules/index.js";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
12
|
-
*/
|
|
13
|
-
const recommendedJS = mergeConfigs(
|
|
10
|
+
const baseConfig = mergeConfigs(
|
|
14
11
|
{
|
|
15
|
-
files: ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs"],
|
|
16
12
|
languageOptions: {
|
|
17
13
|
globals: globals.browser,
|
|
18
14
|
parserOptions: {
|
|
19
15
|
warnOnUnsupportedTypeScriptVersion: false,
|
|
20
16
|
},
|
|
21
|
-
ecmaVersion:
|
|
17
|
+
ecmaVersion: "latest",
|
|
22
18
|
sourceType: "module",
|
|
23
19
|
},
|
|
24
20
|
},
|
|
25
|
-
// tsconfig.configs.base sets eslint parser to use the typescript parser to parse .js files - handles all modern syntax
|
|
26
|
-
tsconfig.configs.base,
|
|
27
21
|
js.configs.recommended,
|
|
28
22
|
eslintPluginImportX.flatConfigs.recommended,
|
|
29
23
|
{
|
|
30
|
-
name: "recommended-js",
|
|
31
24
|
rules: {
|
|
32
25
|
...rules.importXRules,
|
|
33
26
|
...rules.eslintCoreRules,
|
|
@@ -35,19 +28,30 @@ const recommendedJS = mergeConfigs(
|
|
|
35
28
|
},
|
|
36
29
|
);
|
|
37
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
33
|
+
*/
|
|
34
|
+
const recommendedJS = mergeConfigs(
|
|
35
|
+
baseConfig,
|
|
36
|
+
// tsconfig.configs.base sets eslint parser to use the typescript parser to parse .js files - handles all modern syntax
|
|
37
|
+
tsconfig.configs.base,
|
|
38
|
+
{
|
|
39
|
+
name: "recommended-js",
|
|
40
|
+
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
38
44
|
/**
|
|
39
45
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
40
46
|
*/
|
|
41
47
|
const recommendedTS = mergeConfigs(
|
|
42
|
-
|
|
48
|
+
baseConfig,
|
|
43
49
|
{
|
|
44
50
|
files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts", "**/*.d.ts"],
|
|
45
51
|
languageOptions: {
|
|
46
52
|
parserOptions: {
|
|
47
53
|
parser: tsParser,
|
|
48
54
|
projectService: true,
|
|
49
|
-
ecmaVersion: "latest",
|
|
50
|
-
sourceType: "module",
|
|
51
55
|
},
|
|
52
56
|
},
|
|
53
57
|
},
|
|
@@ -208,6 +208,8 @@ const rules = {
|
|
|
208
208
|
"response", // for Express responses
|
|
209
209
|
"$scope", // for Angular 1 scopes
|
|
210
210
|
"staticContext", // for ReactRouter context
|
|
211
|
+
"sharedState", // for shared state in reducers
|
|
212
|
+
"state", // for shared state in reducers
|
|
211
213
|
],
|
|
212
214
|
},
|
|
213
215
|
],
|
|
@@ -706,15 +708,15 @@ const rules = {
|
|
|
706
708
|
"error",
|
|
707
709
|
{
|
|
708
710
|
name: "isFinite",
|
|
709
|
-
message: "Use Number.isFinite instead
|
|
711
|
+
message: "Use Number.isFinite instead",
|
|
710
712
|
},
|
|
711
713
|
{
|
|
712
714
|
name: "isNaN",
|
|
713
|
-
message: "Use Number.isNaN instead
|
|
715
|
+
message: "Use Number.isNaN instead",
|
|
714
716
|
},
|
|
715
717
|
...confusingBrowserGlobals.map((g) => ({
|
|
716
718
|
name: g,
|
|
717
|
-
message: `Use window.${g} instead
|
|
719
|
+
message: `Use window.${g} instead`,
|
|
718
720
|
})),
|
|
719
721
|
],
|
|
720
722
|
|
|
@@ -866,15 +868,7 @@ const rules = {
|
|
|
866
868
|
|
|
867
869
|
// disallow dangling underscores in identifiers
|
|
868
870
|
// https://eslint.org/docs/rules/no-underscore-dangle
|
|
869
|
-
"no-underscore-dangle":
|
|
870
|
-
"error",
|
|
871
|
-
{
|
|
872
|
-
allow: [],
|
|
873
|
-
allowAfterThis: false,
|
|
874
|
-
allowAfterSuper: false,
|
|
875
|
-
enforceInMethodNames: true,
|
|
876
|
-
},
|
|
877
|
-
],
|
|
871
|
+
"no-underscore-dangle": "off",
|
|
878
872
|
|
|
879
873
|
// disallow the use of Boolean literals in conditional expressions
|
|
880
874
|
// also, prefer `a || b` over `a ? a : b`
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import eslintCoreRules from "./eslint-core.js";
|
|
2
2
|
import importXRules from "./import-x.js";
|
|
3
|
+
import nodeRules from "./node.js";
|
|
3
4
|
import reactA11yRules from "./react-a11y.js";
|
|
4
5
|
import reactHooksRules from "./react-hooks.js";
|
|
5
6
|
import reactRules from "./react.js";
|
|
@@ -7,11 +8,12 @@ import testingLibraryRules from "./testing-library.js";
|
|
|
7
8
|
import typescriptRules from "./typescript.js";
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
|
-
importXRules,
|
|
11
11
|
eslintCoreRules,
|
|
12
|
-
|
|
12
|
+
importXRules,
|
|
13
|
+
nodeRules,
|
|
13
14
|
reactRules,
|
|
14
15
|
reactA11yRules,
|
|
15
16
|
reactHooksRules,
|
|
16
17
|
testingLibraryRules,
|
|
18
|
+
typescriptRules,
|
|
17
19
|
};
|
|
@@ -387,13 +387,11 @@ const rules = {
|
|
|
387
387
|
|
|
388
388
|
// Enforce state initialization style
|
|
389
389
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
|
|
390
|
-
|
|
391
|
-
"react/state-in-constructor": ["error", "always"],
|
|
390
|
+
"react/state-in-constructor": ["error", "never"],
|
|
392
391
|
|
|
393
392
|
// Enforces where React component static properties should be positioned
|
|
394
393
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
|
|
395
|
-
|
|
396
|
-
"react/static-property-placement": ["error", "property assignment"],
|
|
394
|
+
"react/static-property-placement": "error",
|
|
397
395
|
|
|
398
396
|
// This has valid cases but best practice to be explicit about the props
|
|
399
397
|
// Disallow JSX props spreading
|
|
@@ -151,7 +151,7 @@ const rules = {
|
|
|
151
151
|
// Lots of false/iffy positives
|
|
152
152
|
// watch out for always truthy conditions
|
|
153
153
|
// https://typescript-eslint.io/rules/no-unnecessary-condition
|
|
154
|
-
"@typescript-eslint/no-unnecessary-condition": "
|
|
154
|
+
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
155
155
|
|
|
156
156
|
// no unnecessary namespace qualifiers.
|
|
157
157
|
// https://typescript-eslint.io/rules/no-unnecessary-qualifier
|
|
@@ -201,7 +201,7 @@ const rules = {
|
|
|
201
201
|
// https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
|
|
202
202
|
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
203
203
|
|
|
204
|
-
// Replace
|
|
204
|
+
// Replace camelcase' rule with '@typescript-eslint/naming-convention'
|
|
205
205
|
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
|
|
206
206
|
camelcase: "off",
|
|
207
207
|
// The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
|
|
@@ -217,7 +217,7 @@ const rules = {
|
|
|
217
217
|
selector: "function",
|
|
218
218
|
format: ["camelCase", "PascalCase"],
|
|
219
219
|
},
|
|
220
|
-
//
|
|
220
|
+
// Qlik recommends PascalCase for classes (23.3),
|
|
221
221
|
{
|
|
222
222
|
selector: "typeLike",
|
|
223
223
|
format: ["PascalCase"],
|