@qlik/eslint-config 1.4.29 → 2.0.0-next.1

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.
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  /**
4
- * @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
4
+ * @satisfies {import("../../../types/index.js").ESLintFlatConfig["rules"]}
5
5
  *
6
6
  * eslint-plugin-import-x package https://github.com/un-ts/eslint-plugin-import-x/blob/master/README.md
7
7
  */
@@ -12,22 +12,13 @@ const rules = {
12
12
  /* -------------------------------------------------------------------------- */
13
13
  // ensure imports point to files/modules that can be resolved
14
14
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
15
- "import-x/no-unresolved": ["error", { commonjs: true, caseSensitive: true }],
16
- // ensure named imports coupled with named exports
17
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/named.md#when-not-to-use-it
18
- "import-x/named": "error",
15
+ "import-x/no-unresolved": ["error", { commonjs: true }],
19
16
  /* -------------------------------------------------------------------------- */
20
17
  /* Helpful warnings: */
21
18
  /* -------------------------------------------------------------------------- */
22
- // disallow invalid exports, e.g. multiple defaults
23
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/export.md
24
- "import-x/export": "error",
25
19
  // do not allow a default import name to match a named export
26
20
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default.md
27
21
  "import-x/no-named-as-default": "error",
28
- // warn on accessing default export property names that are also named exports
29
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default-member.md
30
- "import-x/no-named-as-default-member": "off",
31
22
  // disallow use of jsdoc-marked-deprecated imports
32
23
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-deprecated.md
33
24
  "import-x/no-deprecated": "warn",
@@ -47,6 +38,7 @@ const rules = {
47
38
  "tests/**", // also common npm pattern
48
39
  "spec/**", // mocha, rspec-like pattern
49
40
  "**/__tests__/**", // jest pattern
41
+ "**/__test__/**", // jest pattern
50
42
  "**/__mocks__/**", // jest pattern
51
43
  "test.{js,jsx,ts,tsx}", // repos with a single test file
52
44
  "test-*.{js,jsx,ts,tsx}", // repos with multiple top-level test files
@@ -81,10 +73,6 @@ const rules = {
81
73
  // disallow AMD require/define
82
74
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-amd.md
83
75
  "import-x/no-amd": "error",
84
- // No Node.js builtin modules
85
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-nodejs-modules.md
86
- // TODO: enable?
87
- "import-x/no-nodejs-modules": "off",
88
76
  /* -------------------------------------------------------------------------- */
89
77
  /* Style guide: */
90
78
  /* -------------------------------------------------------------------------- */
@@ -110,15 +98,12 @@ const rules = {
110
98
  // Require a newline after the last import-x/require in a group
111
99
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/newline-after-import.md
112
100
  "import-x/newline-after-import": "error",
113
- // Require modules with a single export to use a default export
114
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/prefer-default-export.md
115
- "import-x/prefer-default-export": "off",
116
101
  // Forbid import of modules using absolute paths
117
102
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-absolute-path.md
118
103
  "import-x/no-absolute-path": "error",
119
104
  // Forbid require() calls with expressions
120
105
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-dynamic-require.md
121
- "import-x/no-dynamic-require": "error",
106
+ "import-x/no-dynamic-require": "warn",
122
107
  // Forbid Webpack loader syntax in imports
123
108
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-webpack-loader-syntax.md
124
109
  "import-x/no-webpack-loader-syntax": "error",
@@ -134,9 +119,6 @@ const rules = {
134
119
  // Ensures that there are no useless path segments
135
120
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
136
121
  "import-x/no-useless-path-segments": ["error", { commonjs: true }],
137
- // Reports modules without any exports, or with unused exports
138
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unused-modules.md
139
- "import-x/no-unused-modules": "error",
140
122
  // Reports the use of import declarations with CommonJS exports in any module except for the main module.
141
123
  // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-import-module-exports.md
142
124
  "import-x/no-import-module-exports": [
@@ -146,16 +128,8 @@ const rules = {
146
128
  },
147
129
  ],
148
130
  // Use this rule to prevent importing packages through relative paths.
149
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages-exports.md
131
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages.md
150
132
  "import-x/no-relative-packages": "error",
151
- // This seems conflicting with @typescript-eslint/no-import-type-side-effects
152
- // enforce a consistent style for type specifiers (inline or top-level)
153
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/consistent-type-specifier-style.md
154
- "import-x/consistent-type-specifier-style": "off",
155
- // Makes importing runtime (`import type {} from ...`) types annoying
156
- // Reports the use of empty named import blocks.
157
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-empty-named-blocks.md
158
- "import-x/no-empty-named-blocks": "off",
159
133
  };
160
134
 
161
135
  export default rules;
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  /**
4
- * @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
4
+ * @satisfies {import("../../../types/index.js").ESLintFlatConfig["rules"]}
5
5
  */
6
6
  const rules = {
7
7
  // TODO use eslint-plugin-n https://github.com/eslint-community/eslint-plugin-n
@@ -0,0 +1,22 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * This file contains rules related to react. It is meant to be extended by react specific configs,
5
+ * it is not meant to be used directly.
6
+ * We are using @eslint-react/eslint-plugin for react specific rules, but we are not extending their
7
+ * recommended config as it includes some rules that we do not want to enforce, and it does not include
8
+ * some rules that we do want to enforce. We are only using the rules that we find useful and relevant
9
+ * for our projects.
10
+ * For more information on the available rules and their options, please refer to the documentation of
11
+ * @eslint-react/eslint-plugin and @eslint-react/eslint-plugin-hooks:
12
+ * https://beta.eslint-react.xyz/docs/rules/overview
13
+ */
14
+
15
+ /**
16
+ * @satisfies {import("../../../types/index.js").ESLintFlatConfig["rules"]}
17
+ */
18
+ const rules = {
19
+ // Add or modify react specific rules here if needed - use https://beta.eslint-react.xyz/docs/rules/overview for reference
20
+ };
21
+
22
+ export default rules;
@@ -2,17 +2,15 @@
2
2
  import eslintCoreRules from "./eslint-core.js";
3
3
 
4
4
  /**
5
- * @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
5
+ * @satisfies {import("../../../types/index.js").ESLintFlatConfig["rules"]}
6
6
  *
7
- * typescript-eslint package https://typescript-eslint.io/rules/
7
+ * typesscript-eslint core recommended config https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/recommended-type-checked.ts
8
8
  */
9
9
  const rules = {
10
- // note some eslint core rules are disabled by tsconfig https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended-raw.ts
10
+ // modify/add rules from typescript-eslint package here additionally to the recommended rules
11
11
 
12
- // class methods don't have to use this, but should maybe be turned into static methods
13
- // https://typescript-eslint.io/rules/class-methods-use-this
14
- "class-methods-use-this": "off",
15
- "@typescript-eslint/class-methods-use-this": eslintCoreRules["class-methods-use-this"],
12
+ // note some eslint core rules are disabled by tsconfig https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended-raw.ts
13
+ // turn off core rules superseded by @typescript-eslint equivalents
16
14
 
17
15
  // enforce consistent type imports
18
16
  // https://typescript-eslint.io/rules/consistent-type-imports
@@ -23,10 +21,6 @@ const rules = {
23
21
  "default-param-last": "off",
24
22
  "@typescript-eslint/default-param-last": eslintCoreRules["default-param-last"],
25
23
 
26
- // enforce exported functions to have return types
27
- // https://typescript-eslint.io/rules/explicit-module-boundary-types
28
- "@typescript-eslint/explicit-module-boundary-types": "off",
29
-
30
24
  // enforce method signatures has the same style
31
25
  // https://typescript-eslint.io/rules/method-signature-style
32
26
  "@typescript-eslint/method-signature-style": "error",
@@ -35,10 +29,6 @@ const rules = {
35
29
  // https://typescript-eslint.io/rules/no-dynamic-delete
36
30
  "@typescript-eslint/no-dynamic-delete": "error",
37
31
 
38
- // don't have classes with only static members
39
- // https://typescript-eslint.io/rules/no-extraneous-class
40
- "@typescript-eslint/no-extraneous-class": "error",
41
-
42
32
  // use top-level type imports
43
33
  // https://typescript-eslint.io/rules/no-import-type-side-effects
44
34
  "@typescript-eslint/no-import-type-side-effects": "error",
@@ -52,11 +42,6 @@ const rules = {
52
42
  "no-loop-func": "off",
53
43
  "@typescript-eslint/no-loop-func": eslintCoreRules["no-loop-func"],
54
44
 
55
- // no magic numbers please
56
- // https://typescript-eslint.io/rules/no-magic-numbers
57
- "no-magic-numbers": "off",
58
- "@typescript-eslint/no-magic-numbers": eslintCoreRules["no-magic-numbers"],
59
-
60
45
  // disallow non-null assertions in the left operand of a nullish coalescing operator.
61
46
  // https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing
62
47
  "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
@@ -92,18 +77,10 @@ const rules = {
92
77
  "no-useless-constructor": "off",
93
78
  "@typescript-eslint/no-useless-constructor": eslintCoreRules["no-useless-constructor"],
94
79
 
95
- // useless exports can be removed
96
- // https://typescript-eslint.io/rules/no-useless-empty-export
97
- "@typescript-eslint/no-useless-empty-export": "error",
98
-
99
80
  // yes, please initialize your enums
100
81
  // https://typescript-eslint.io/rules/prefer-enum-initializers
101
82
  "@typescript-eslint/prefer-enum-initializers": "error",
102
83
 
103
- // allow classic for loops
104
- // https://typescript-eslint.io/rules/prefer-for-of
105
- "@typescript-eslint/prefer-for-of": "off",
106
-
107
84
  // enums are not based on dynamic values
108
85
  // https://typescript-eslint.io/rules/prefer-literal-enum-member
109
86
  "@typescript-eslint/prefer-literal-enum-member": "error",
@@ -148,15 +125,13 @@ const rules = {
148
125
  // https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
149
126
  "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
150
127
 
151
- // Lots of false/iffy positives
152
- // watch out for always truthy conditions
153
- // https://typescript-eslint.io/rules/no-unnecessary-condition
154
- "@typescript-eslint/no-unnecessary-condition": "off",
155
-
156
128
  // no unnecessary namespace qualifiers.
157
129
  // https://typescript-eslint.io/rules/no-unnecessary-qualifier
158
130
  "@typescript-eslint/no-unnecessary-qualifier": "error",
159
131
 
132
+ // Disallow conditionals where the type is always truthy or always falsy - https://typescript-eslint.io/rules/no-unnecessary-condition
133
+ "@typescript-eslint/no-unnecessary-condition": "error",
134
+
160
135
  // no need for template literals if they just refer to a string
161
136
  // https://typescript-eslint.io/rules/no-unnecessary-template-expression
162
137
  "@typescript-eslint/no-unnecessary-template-expression": "error",
@@ -165,11 +140,6 @@ const rules = {
165
140
  // https://typescript-eslint.io/rules/no-unnecessary-type-arguments
166
141
  "@typescript-eslint/no-unnecessary-type-arguments": "error",
167
142
 
168
- // Not working 100%
169
- // don't use type parameters when they're not needed
170
- // https://typescript-eslint.io/rules/no-unnecessary-type-parameters
171
- "@typescript-eslint/no-unnecessary-type-parameters": "off",
172
-
173
143
  // reducers should be typed correctly
174
144
  // https://typescript-eslint.io/rules/prefer-reduce-type-parameter
175
145
  "@typescript-eslint/prefer-reduce-type-parameter": "error",
@@ -177,24 +147,7 @@ const rules = {
177
147
  // https://typescript-eslint.io/rules/prefer-return-this-type
178
148
  "@typescript-eslint/prefer-return-this-type": "error",
179
149
 
180
- // https://typescript-eslint.io/rules/ban-ts-comment
181
- "@typescript-eslint/ban-ts-comment": "error",
182
-
183
- // https://typescript-eslint.io/rules/require-array-sort-compare
184
- "@typescript-eslint/require-array-sort-compare": "error",
185
-
186
- // not sure about this one
187
- // https://typescript-eslint.io/rules/return-await
188
- "no-return-await": "off",
189
- "@typescript-eslint/return-await": "error",
190
-
191
- // Not sure about this one
192
- // disallow certain types in boolean expressions.
193
- // https://typescript-eslint.io/rules/strict-boolean-expressions
194
- "@typescript-eslint/strict-boolean-expressions": "off",
195
-
196
- // make sure switch statements are exhaustive
197
- // https://typescript-eslint.io/rules/switch-exhaustiveness-check
150
+ // Require switch-case statements to be exhaustive - https://typescript-eslint.io/rules/switch-exhaustiveness-check
198
151
  "@typescript-eslint/switch-exhaustiveness-check": "error",
199
152
 
200
153
  // enforce typing arguments in Promise rejection callbacks as unknown
@@ -202,7 +155,7 @@ const rules = {
202
155
  "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
203
156
 
204
157
  // Replace camelcase' rule with '@typescript-eslint/naming-convention'
205
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
158
+ // https://typescript-eslint.io/rules/naming-convention/
206
159
  camelcase: "off",
207
160
  // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
208
161
  "@typescript-eslint/naming-convention": [
@@ -223,6 +176,9 @@ const rules = {
223
176
  format: ["PascalCase"],
224
177
  },
225
178
  ],
179
+
180
+ // use tsconfig's noImplicitReturns option rather than this rule
181
+ "consistent-return": "off",
226
182
  };
227
183
 
228
184
  export default rules;
@@ -1,20 +1,35 @@
1
1
  // @ts-check
2
2
  import globals from "globals";
3
3
  import { mergeConfigs } from "../../utils/config.js";
4
- import nodeRules from "../rules/node.js";
5
4
  import { baseConfigJS, baseConfigTS } from "./base.js";
5
+ import nodeRules from "./default-rules/node.js";
6
+
7
+ // TODO use eslint-plugin-n https://github.com/eslint-community/eslint-plugin-n
6
8
 
7
9
  /**
8
- * @satisfies {import("../../types/index.js").ESLintFlatConfig['rules']}
10
+ * @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
9
11
  */
10
- const cjsRules = {
12
+ const nodeEsmRules = {
11
13
  ...nodeRules,
12
- // modify rules for node commonjs here
14
+ // modify rules for node esm here
15
+
16
+ // Ensure consistent use of file extension within the import path
17
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
18
+ "import-x/extensions": [
19
+ "error",
20
+ "ignorePackages",
21
+ {
22
+ ts: "never",
23
+ mts: "never",
24
+ tsx: "never",
25
+ },
26
+ ],
13
27
  };
14
28
 
15
29
  /**
16
30
  * CJS config for javascript in node
17
31
  * @type {import("../../types/index.js").ESLintFlatConfig}
32
+ * This config is meant to be extended by javascript specific configs, it is not meant to be used directly.
18
33
  */
19
34
  const baseCjsJS = mergeConfigs(
20
35
  // base it on the recommended javascript config
@@ -25,12 +40,16 @@ const baseCjsJS = mergeConfigs(
25
40
  globals: globals.node,
26
41
  sourceType: "commonjs",
27
42
  },
28
- rules: cjsRules,
43
+ rules: {
44
+ ...nodeRules,
45
+ // modify javascript specific rules for node cjs here if needed
46
+ },
29
47
  },
30
48
  );
31
49
 
32
50
  /**
33
51
  * CJS config for typescript in node
52
+ * This config is meant to be extended by typescript specific configs, it is not meant to be used directly.
34
53
  * @type {import("../../types/index.js").ESLintFlatConfig}
35
54
  */
36
55
  const baseCjsTS = mergeConfigs(
@@ -43,32 +62,12 @@ const baseCjsTS = mergeConfigs(
43
62
  sourceType: "commonjs",
44
63
  },
45
64
  rules: {
46
- ...cjsRules,
47
- // modify ts specific rules for node here
65
+ ...nodeRules,
66
+ // modify typescript specific rules for node cjs here if needed
48
67
  },
49
68
  },
50
69
  );
51
70
 
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
71
  /**
73
72
  * ESM config for javascript in node
74
73
  * @type {import("../../types/index.js").ESLintFlatConfig}
@@ -82,7 +81,11 @@ const baseEsmJS = mergeConfigs(
82
81
  globals: globals.node,
83
82
  sourceType: "module",
84
83
  },
85
- rules: nodeEsmRules,
84
+ rules: {
85
+ ...nodeRules,
86
+ ...nodeEsmRules,
87
+ // modify javascript specific rules for node esm here if needed
88
+ },
86
89
  },
87
90
  );
88
91
 
@@ -100,6 +103,7 @@ const baseEsmTS = mergeConfigs(
100
103
  sourceType: "module",
101
104
  },
102
105
  rules: {
106
+ ...nodeRules,
103
107
  ...nodeEsmRules,
104
108
  // modify typescript specific rules for node esm here if needed
105
109
  },
@@ -5,7 +5,7 @@ import { mergeConfigs } from "../utils/config.js";
5
5
 
6
6
  /**
7
7
  * @type {import("../types/index.js").ESLintFlatConfig}
8
- * config for jest https://github.com/jest-community/eslint-plugin-jest
8
+ * config for vitest https://github.com/vitest/eslint-plugin-vitest
9
9
  */
10
10
  const vitest = mergeConfigs(
11
11
  // base it on the recommended vitest config
@@ -23,4 +23,3 @@ const vitest = mergeConfigs(
23
23
  );
24
24
 
25
25
  export default [vitest];
26
- export { vitest };
package/src/index.d.ts CHANGED
@@ -1,40 +1,20 @@
1
1
  import cjs, { cjsJS, cjsTS } from "./configs/cjs.js";
2
2
  import esbrowser, { esbrowserJS, esbrowserTS } from "./configs/esbrowser.js";
3
3
  import esm, { esmJS, esmTS } from "./configs/esm.js";
4
- import jest from "./configs/jest.js";
5
- import playwright from "./configs/playwright.js";
6
4
  import react, { reactJS, reactTS } from "./configs/react.js";
7
5
  import recommended, { recommendedJS, recommendedTS } from "./configs/recommended.js";
8
- import svelte, { svelteJS } from "./configs/svelte.js";
9
6
  import vitest from "./configs/vitest.js";
10
- import compose from "./utils/compose.js";
11
7
 
12
8
  declare namespace qlikEslintConfig {
13
9
  export namespace configs {
14
10
  export { cjs };
15
11
  export { esbrowser };
16
12
  export { esm };
17
- export { playwright };
18
- export { jest };
19
13
  export { react };
20
14
  export { recommended };
21
- export { svelte };
22
15
  export { vitest };
23
16
  }
24
- export { compose };
25
17
  }
26
18
 
27
19
  export default qlikEslintConfig;
28
- export {
29
- cjsJS,
30
- cjsTS,
31
- esbrowserJS,
32
- esbrowserTS,
33
- esmJS,
34
- esmTS,
35
- reactJS,
36
- reactTS,
37
- recommendedJS,
38
- recommendedTS,
39
- svelteJS,
40
- };
20
+ export { cjsJS, cjsTS, esbrowserJS, esbrowserTS, esmJS, esmTS, reactJS, reactTS, recommendedJS, recommendedTS };
package/src/index.js CHANGED
@@ -2,13 +2,9 @@
2
2
  import cjs, { cjsJS, cjsTS } from "./configs/cjs.js";
3
3
  import esbrowser, { esbrowserJS, esbrowserTS } from "./configs/esbrowser.js";
4
4
  import esm, { esmJS, esmTS } from "./configs/esm.js";
5
- import jest from "./configs/jest.js";
6
- import playwright from "./configs/playwright.js";
7
5
  import react, { reactJS, reactTS } from "./configs/react.js";
8
6
  import recommended, { recommendedJS, recommendedTS } from "./configs/recommended.js";
9
- import svelte, { svelteJS } from "./configs/svelte.js";
10
7
  import vitest from "./configs/vitest.js";
11
- import compose from "./utils/compose.js";
12
8
 
13
9
  /**
14
10
  * @satisfies {import("./types/index.js").QlikEslintConfig}
@@ -18,28 +14,12 @@ const qlikEslintConfig = {
18
14
  cjs,
19
15
  esbrowser,
20
16
  esm,
21
- jest,
22
- playwright,
23
17
  react,
24
18
  recommended,
25
- svelte,
26
19
  vitest,
27
20
  },
28
- compose,
29
21
  };
30
22
 
31
23
  export default qlikEslintConfig;
32
24
 
33
- export {
34
- cjsJS,
35
- cjsTS,
36
- esbrowserJS,
37
- esbrowserTS,
38
- esmJS,
39
- esmTS,
40
- reactJS,
41
- reactTS,
42
- recommendedJS,
43
- recommendedTS,
44
- svelteJS,
45
- };
25
+ export { cjsJS, cjsTS, esbrowserJS, esbrowserTS, esmJS, esmTS, reactJS, reactTS, recommendedJS, recommendedTS };
@@ -1,52 +1,11 @@
1
- /* eslint-disable @typescript-eslint/no-empty-object-type */
2
- import { TSESLint } from "@typescript-eslint/utils";
1
+ import type { Linter } from "eslint";
3
2
 
4
- interface ESLintFlatConfig extends TSESLint.FlatConfig.Config {}
5
- interface ESLintPlugin extends TSESLint.FlatConfig.Plugin {}
6
- interface ESLintLanguageOptions extends TSESLint.FlatConfig.LanguageOptions {}
7
-
8
- interface ESLintFlatConfigWithExtend extends ESLintFlatConfig {
9
- /**
10
- * Allows you to "extend" a set of configs similar to `extends` from the
11
- * classic configs.
12
- *
13
- * This is just a convenience short-hand to help reduce duplication.
14
- *
15
- * ```js
16
- * export default qlikEslint.compose({
17
- * files: ['** /*.ts'],
18
- * extend: [
19
- * ...qlikEslint.configs.ts,
20
- * ],
21
- * rules: {
22
- * '@typescript-eslint/array-type': 'error',
23
- * '@typescript-eslint/consistent-type-imports': 'error',
24
- * },
25
- * })
26
- *
27
- * // expands to
28
- *
29
- * export default [
30
- * ...qlikEslint.configs.ts.map(conf => ({
31
- * ...conf,
32
- * files: ['** /*.ts'],
33
- * })),
34
- * {
35
- * files: ['** /*.ts'],
36
- * rules: {
37
- * '@typescript-eslint/array-type': 'error',
38
- * '@typescript-eslint/consistent-type-imports': 'error',
39
- * },
40
- * },
41
- * ]
42
- * ```
43
- */
44
- extend?: ESLintFlatConfig[];
45
- }
3
+ type ESLintFlatConfig = Linter.Config;
4
+ type ESLintPlugin = NonNullable<Linter.Config["plugins"]>[string];
5
+ type ESLintLanguageOptions = NonNullable<Linter.Config["languageOptions"]>;
46
6
 
47
7
  type QlikEslintConfig = {
48
8
  configs: Record<string, ESLintFlatConfig[]>;
49
- compose: (...configs: ESLintFlatConfigWithExtend[]) => ESLintFlatConfig[];
50
9
  };
51
10
 
52
- export type { ESLintFlatConfig, ESLintFlatConfigWithExtend, ESLintLanguageOptions, ESLintPlugin, QlikEslintConfig };
11
+ export type { ESLintFlatConfig, ESLintLanguageOptions, ESLintPlugin, QlikEslintConfig };
@@ -1,4 +1,3 @@
1
- import tsEslint from "typescript-eslint";
2
1
  import { merge } from "./merge.js";
3
2
 
4
3
  /**
@@ -18,5 +17,3 @@ export function mergeConfigs(...configs) {
18
17
  }
19
18
  return mergedConfig;
20
19
  }
21
-
22
- export const config = tsEslint.config;
@@ -3,10 +3,10 @@ const noNeedToDeepMerge = ["plugins", "rules", "parser"];
3
3
  const overWrite = ["files", "globals", "ignores"];
4
4
 
5
5
  /**
6
- *
6
+ * Deep merge two objects, with special handling for certain keys
7
7
  * @param {any} obj1
8
8
  * @param {any} obj2
9
- * @returns
9
+ * @returns {object}
10
10
  */
11
11
  export const merge = (obj1, obj2) => {
12
12
  // add error handling
@@ -1,27 +0,0 @@
1
- // @ts-check
2
- import jestPlugin from "eslint-plugin-jest";
3
- import testingLibraryPlugin from "eslint-plugin-testing-library";
4
- import { mergeConfigs } from "../utils/config.js";
5
-
6
- /**
7
- * @type {import("../types/index.js").ESLintFlatConfig}
8
- * config for jest https://github.com/jest-community/eslint-plugin-jest
9
- */
10
- const jest = mergeConfigs(
11
- // base it on the recommended jest config
12
- jestPlugin.configs["flat/recommended"],
13
- // add testing-library plugin recommended config for react
14
- testingLibraryPlugin.configs["flat/react"],
15
- // add qlik's recommended jest config
16
- {
17
- name: "jest",
18
- files: ["**/__test__/**/*.{js,jsx,ts,tsx}", "**/__tests__/**/*.{js,jsx,ts,tsx}"],
19
- rules: {
20
- // ...testingLibraryRules,
21
- // modify rules from eslint-plugin-jest here
22
- },
23
- },
24
- );
25
-
26
- export default [jest];
27
- export { jest };
@@ -1,24 +0,0 @@
1
- // @ts-check
2
- import playwrightEslint from "eslint-plugin-playwright";
3
- import { mergeConfigs } from "../utils/config.js";
4
-
5
- /**
6
- * @type {import("../types/index.js").ESLintFlatConfig}
7
- * config for Playwright https://github.com/playwright-community/eslint-plugin-playwright
8
- */
9
- const playwright = mergeConfigs(
10
- // base it on the recommended config
11
- playwrightEslint.configs["flat/recommended"],
12
- // add qlik's recommended playwright config
13
- {
14
- name: "playwright",
15
- files: ["tests/**", "test/**"],
16
- rules: {
17
- ...playwrightEslint.configs["flat/recommended"].rules,
18
- // modify rules from eslint-plugin-playwright here
19
- },
20
- },
21
- );
22
-
23
- export default [playwright];
24
- export { playwright };