@qlik/eslint-config 1.0.3 → 1.1.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/README.md CHANGED
@@ -37,13 +37,17 @@ export default qlik.compose(
37
37
 
38
38
  ### v1 notable changes
39
39
 
40
- - Updates [`@typescript-eslint/typescript-eslint`](https://github.com/typescript-eslint/typescript-eslint) to v8, this brings a few new rules. See article for v8 <https://typescript-eslint.io/blog/announcing-typescript-eslint-v8>
41
- - Moves from [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) to [`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x). If you reference any of the `import/` rules you'll need to replace `import/` with `import-x/`.
40
+ - Updates [`@typescript-eslint/typescript-eslint`](https://github.com/typescript-eslint/typescript-eslint) to v8, this brings
41
+ a few new rules. See article for v8 <https://typescript-eslint.io/blog/announcing-typescript-eslint-v8>
42
+ - Moves from [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) to [`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x).
43
+ If you reference any of the `import/` rules you'll need to replace `import/` with `import-x/`.
42
44
  - Some stylistic rules have been disabled (for example `function` vs arrow functions)
43
45
 
44
46
  ## Usage
45
47
 
46
- These configs works on both TypeScript and JavaSript out of the box. (as long as the file endings are any of `.js, .jsx, .mjs, .cjs, .ts, .tsx, .cts, .mts`)
48
+ The default exports configs works on both TypeScript and JavaSript out of the box. (as long as the file endings are any of `.js, .jsx, .mjs, .cjs, .ts, .tsx, .cts, .mts`).
49
+ The configs are eslint flat config arrays populated with configs that has appropriate file endings attached to them. Designed
50
+ to diminish the amount of configuration needed in an `eslint.config.js` file.
47
51
 
48
52
  To get started, create `eslint.config.js` (if your package json has `"type": "module"`), otherwise create `eslint.config.mjs`.
49
53
  If you are not building your project with TypeScript (using Webpack or Vite for example), then tell TypeScript to include
@@ -137,7 +141,61 @@ export default qlik.compose(
137
141
  );
138
142
  ```
139
143
 
140
- A config can be extended if needed. For example if the default file patterns needs to be altered.
144
+ ## Using the named exports configs
145
+
146
+ The different configs are also accessible through named imports. These configs can be used in specific scenarios where more
147
+ control of the configs are needed. The `extend` property can be used to apply a config on certain file patterns.
148
+
149
+ Example only use javascript rules with react
150
+
151
+ ```js
152
+ import qlik, { recommendedJS, reactJS } from "@qlik/eslint-config";
153
+
154
+ export default qlik.compose(
155
+ reactJS
156
+ )
157
+ ```
158
+
159
+ with typescript support
160
+
161
+ ```js
162
+ import qlik, { recommendedJS, reactJS } from "@qlik/eslint-config";
163
+
164
+ export default qlik.compose(
165
+ reactJS,
166
+ reactTS
167
+ )
168
+ ```
169
+
170
+ This is equal to:
171
+
172
+ ```js
173
+ import qlik from "@qlik/eslint-config";
174
+
175
+ export default qlik.compose(
176
+ ...qlik.configs.react
177
+ )
178
+ ```
179
+
180
+ The single configs can be useful together with the `extend` property. Below shows an example of a config
181
+ that wants to use lint rules for node environment on a part of the code base.
182
+
183
+ ```js
184
+ import qlik, { esmJS } from "@qlik/eslint-config";
185
+
186
+ export default qlik.compose(
187
+ // apply recommended config to all files
188
+ ...qlik.configs.recommended,
189
+ // set node esm config on .js files inside the tools folder
190
+ {
191
+ files: ["tools/**/*.js"],
192
+ extend: [esmJS],
193
+ },
194
+ )
195
+
196
+ ```
197
+
198
+ Example of changing the default file patterns on the vitest config.
141
199
 
142
200
  ```js
143
201
  // @ts-check
@@ -148,7 +206,7 @@ export default qlik.compose(
148
206
  {
149
207
  // adds vitest lint rules on the specified files with an altered rule
150
208
  files: ['**/my_tests_are_here/*.spec.ts']
151
- extends [qlik.configs.vitest],
209
+ extend: [qlik.configs.vitest],
152
210
  rules: {
153
211
  "vitest/max-nested-describe": [
154
212
  "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qlik/eslint-config",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Qlik's ESLint configs",
5
5
  "repository": "git@github.com:qlik-oss/dev-tools-js.git",
6
6
  "license": "ISC",
@@ -58,6 +58,7 @@
58
58
  "check-types": "tsc --noEmit",
59
59
  "format:check": "prettier --check '**' --ignore-unknown",
60
60
  "format:write": "prettier --write '**' --ignore-unknown",
61
- "lint": "eslint ."
61
+ "lint": "eslint .",
62
+ "test": "vitest run && ./test/verify-configs.sh"
62
63
  }
63
64
  }
@@ -2,47 +2,54 @@
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
+ import nodeRules from "./rules/node.js";
6
6
 
7
7
  /**
8
8
  * @satisfies {import("../types/index.js").ESLintFlatConfig['rules']}
9
9
  */
10
10
  const cjsRules = {
11
+ ...nodeRules,
11
12
  // modify rules for node commonjs here
12
13
  };
13
14
 
14
15
  /**
15
16
  * @type {import("../types/index.js").ESLintFlatConfig}
16
17
  */
17
- const cjsJS = mergeConfigs(recommendedJS, {
18
- name: "node-cjs-js",
19
- files: ["**/*.{js,cjs}"],
20
- languageOptions: {
21
- globals: globals.node,
22
- sourceType: "commonjs",
18
+ const cjsJS = mergeConfigs(
19
+ // base it on the recommended javascript config
20
+ recommendedJS,
21
+ // add qlik's recommended node commonjs config for javascript
22
+ {
23
+ name: "node-cjs-js",
24
+ files: ["**/*.{js,cjs}"],
25
+ languageOptions: {
26
+ globals: globals.node,
27
+ sourceType: "commonjs",
28
+ },
29
+ rules: cjsRules,
23
30
  },
24
- rules: {
25
- ...rules.nodeRules,
26
- ...cjsRules,
27
- },
28
- });
31
+ );
29
32
 
30
33
  /**
31
34
  * @type {import("../types/index.js").ESLintFlatConfig}
32
35
  */
33
- const cjsTS = mergeConfigs(recommendedTS, {
34
- name: "node-cjs-ts",
35
- files: ["**/*.{ts,cts}"],
36
- languageOptions: {
37
- globals: globals.node,
38
- sourceType: "commonjs",
39
- },
40
- rules: {
41
- ...rules.nodeRules,
42
- ...cjsRules,
43
- // modify ts specific rules for node here
36
+ const cjsTS = mergeConfigs(
37
+ // base it on the recommended typescript config
38
+ recommendedTS,
39
+ // add qlik's recommended node commonjs config for typescript
40
+ {
41
+ name: "node-cjs-ts",
42
+ files: ["**/*.{ts,cts}"],
43
+ languageOptions: {
44
+ globals: globals.node,
45
+ sourceType: "commonjs",
46
+ },
47
+ rules: {
48
+ ...cjsRules,
49
+ // modify ts specific rules for node here
50
+ },
44
51
  },
45
- });
52
+ );
46
53
 
47
54
  export default [cjsJS, cjsTS];
48
55
  export { cjsJS, cjsTS };
@@ -2,45 +2,55 @@
2
2
  import globals from "globals";
3
3
  import { mergeConfigs } from "../utils/config.js";
4
4
  import { recommendedJS, recommendedTS } from "./recommended.js";
5
+ import nodeRules from "./rules/node.js";
5
6
 
6
7
  /**
7
8
  * @satisfies {import("../types/index.js").ESLintFlatConfig["rules"]}
8
9
  */
9
10
  const nodeEsmRules = {
10
- // modify rules for node esm here
11
+ ...nodeRules,
11
12
  "import-x/extensions": ["error", "ignorePackages"],
13
+ // modify rules for node esm here
12
14
  };
13
15
 
14
16
  /**
15
17
  * @type {import("../types/index.js").ESLintFlatConfig}
16
18
  */
17
- const esmJS = mergeConfigs(recommendedJS, {
18
- name: "node-esm-js",
19
- files: ["**/*.{js,mjs}"],
20
- languageOptions: {
21
- globals: globals.node,
22
- sourceType: "module",
19
+ const esmJS = mergeConfigs(
20
+ // base it on the recommended javascript config
21
+ recommendedJS,
22
+ // add qlik's recommended node esm config for javascript
23
+ {
24
+ name: "node-esm-js",
25
+ files: ["**/*.{js,mjs}"],
26
+ languageOptions: {
27
+ globals: globals.node,
28
+ sourceType: "module",
29
+ },
30
+ rules: nodeEsmRules,
23
31
  },
24
- rules: {
25
- ...nodeEsmRules,
26
- },
27
- });
32
+ );
28
33
 
29
34
  /**
30
35
  * @type {import("../types/index.js").ESLintFlatConfig}
31
36
  */
32
- const esmTS = mergeConfigs(recommendedTS, {
33
- name: "node-esm-ts",
34
- files: ["**/*.{ts,mts}"],
35
- languageOptions: {
36
- globals: globals.node,
37
- sourceType: "module",
38
- },
39
- rules: {
40
- ...nodeEsmRules,
41
- // modify ts specific rules for node esm here
37
+ const esmTS = mergeConfigs(
38
+ // base it on the recommended typescript config
39
+ recommendedTS,
40
+ // add qlik's recommended node esm config for typescript
41
+ {
42
+ name: "node-esm-ts",
43
+ files: ["**/*.{ts,mts}"],
44
+ languageOptions: {
45
+ globals: globals.node,
46
+ sourceType: "module",
47
+ },
48
+ rules: {
49
+ ...nodeEsmRules,
50
+ // modify typescript specific rules for node esm here if needed
51
+ },
42
52
  },
43
- });
53
+ );
44
54
 
45
55
  export default [esmJS, esmTS];
46
56
  export { esmJS, esmTS };
@@ -2,23 +2,26 @@
2
2
  import jestPlugin from "eslint-plugin-jest";
3
3
  import testingLibraryPlugin from "eslint-plugin-testing-library";
4
4
  import { mergeConfigs } from "../utils/config.js";
5
- import rules from "./rules/index.js";
6
5
 
7
6
  /**
8
7
  * @type {import("../types/index.js").ESLintFlatConfig}
9
8
  * config for jest https://github.com/jest-community/eslint-plugin-jest
10
9
  */
11
- const jest = mergeConfigs(jestPlugin.configs["flat/recommended"], {
12
- name: "jest-js",
13
- files: ["**/__test__/**/*.{js,jsx,ts,tsx}", "**/__tests__/**/*.{js,jsx,ts,tsx}"],
14
- plugins: {
15
- "testing-library": testingLibraryPlugin,
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
+ },
16
23
  },
17
- rules: {
18
- ...rules.testingLibraryRules,
19
- // modify rules from eslint-plugin-jest here
20
- },
21
- });
24
+ );
22
25
 
23
26
  export default [jest];
24
27
  export { jest };
@@ -6,14 +6,19 @@ import { mergeConfigs } from "../utils/config.js";
6
6
  * @type {import("../types/index.js").ESLintFlatConfig}
7
7
  * config for Playwright https://github.com/playwright-community/eslint-plugin-playwright
8
8
  */
9
- const playwright = mergeConfigs(playwrightEslint.configs["flat/recommended"], {
10
- name: "playwright",
11
- files: ["tests/**", "test/**"],
12
- rules: {
13
- ...playwrightEslint.configs["flat/recommended"].rules,
14
- // modify rules from eslint-plugin-playwright here
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
+ },
15
20
  },
16
- });
21
+ );
17
22
 
18
23
  export default [playwright];
19
24
  export { playwright };
@@ -6,7 +6,9 @@ import eslintPluginReact from "eslint-plugin-react";
6
6
  import reactHooks from "eslint-plugin-react-hooks";
7
7
  import { mergeConfigs } from "../utils/config.js";
8
8
  import { recommendedJS, recommendedTS } from "./recommended.js";
9
- import rules from "./rules/index.js";
9
+ import reactA11yRules from "./rules/react-a11y.js";
10
+ import reactHooksRules from "./rules/react-hooks.js";
11
+ import reactRules from "./rules/react.js";
10
12
 
11
13
  /** @type {any} */
12
14
  const reactPlugin = eslintPluginReact;
@@ -14,7 +16,7 @@ const reactPlugin = eslintPluginReact;
14
16
  /**
15
17
  * @type {import("../types/index.js").ESLintFlatConfig}
16
18
  */
17
- const reactConfig = {
19
+ const reactBaseConfig = {
18
20
  languageOptions: {
19
21
  parserOptions: {
20
22
  ecmaFeatures: {
@@ -36,40 +38,54 @@ const reactConfig = {
36
38
  rules: {
37
39
  // react plugin
38
40
  ...reactPlugin.configs.flat.recommended.rules,
39
- ...rules.reactRules,
41
+ ...reactRules,
40
42
  // jsx-a11y plugin
41
43
  ...jsxA11y.flatConfigs.recommended.rules,
42
- ...rules.reactA11yRules,
44
+ ...reactA11yRules,
43
45
  ...react.configs.recommended.rules,
44
46
  // react-hooks plugin
45
47
  ...reactHooks.configs.recommended.rules,
46
- ...rules.reactHooksRules,
48
+ ...reactHooksRules,
47
49
  },
48
50
  };
49
51
 
50
52
  /**
51
53
  * @type {import("../types/index.js").ESLintFlatConfig}
52
54
  */
53
- const reactJS = mergeConfigs(reactConfig, {
54
- name: "react-js",
55
- files: ["**/*.js", "**/*.jsx"],
56
- rules: {
57
- // turn on/off or modify js rules necessary for react
58
- "react/jsx-filename-extension": [2, { extensions: [".js", ".jsx"] }],
55
+ const reactJS = mergeConfigs(
56
+ // base it on the recommended javascript config
57
+ recommendedJS,
58
+ // add the base react config
59
+ reactBaseConfig,
60
+ // add qlik's recommended react config for javascript
61
+ {
62
+ name: "react-js",
63
+ files: ["**/*.js", "**/*.jsx"],
64
+ rules: {
65
+ // turn on/off or modify js rules necessary for react
66
+ "react/jsx-filename-extension": [2, { extensions: [".js", ".jsx"] }],
67
+ },
59
68
  },
60
- });
69
+ );
61
70
 
62
71
  /**
63
72
  * @type {import("../types/index.js").ESLintFlatConfig}
64
73
  */
65
- const reactTS = mergeConfigs(reactConfig, {
66
- name: "react-ts",
67
- files: ["**/*.ts", "**/*.tsx"],
68
- rules: {
69
- // turn on/off or modify js/ts rules necessary for react
70
- "react/jsx-filename-extension": [2, { extensions: [".js", ".jsx", ".ts", ".tsx"] }],
74
+ const reactTS = mergeConfigs(
75
+ // base it on the recommended typescript config
76
+ recommendedTS,
77
+ // add the base react config
78
+ reactBaseConfig,
79
+ // add qlik's recommended react config for typescript
80
+ {
81
+ name: "react-ts",
82
+ files: ["**/*.ts", "**/*.tsx"],
83
+ rules: {
84
+ // turn on/off or modify js/ts rules necessary for react
85
+ "react/jsx-filename-extension": [2, { extensions: [".js", ".jsx", ".ts", ".tsx"] }],
86
+ },
71
87
  },
72
- });
88
+ );
73
89
 
74
- export default [recommendedJS, reactTS, recommendedTS, reactTS];
90
+ export default [reactJS, reactTS];
75
91
  export { reactJS, reactTS };
@@ -5,9 +5,15 @@ import eslintPluginImportX from "eslint-plugin-import-x";
5
5
  import globals from "globals";
6
6
  import tsconfig from "typescript-eslint";
7
7
  import { mergeConfigs } from "../utils/config.js";
8
- import rules from "./rules/index.js";
8
+ import eslintCoreRules from "./rules/eslint-core.js";
9
+ import importXRules from "./rules/import-x.js";
10
+ import typescriptRules from "./rules/typescript.js";
9
11
 
10
12
  const baseConfig = mergeConfigs(
13
+ // basic js config
14
+ js.configs.recommended,
15
+ // import-x plugin config
16
+ eslintPluginImportX.flatConfigs.recommended,
11
17
  {
12
18
  languageOptions: {
13
19
  globals: globals.browser,
@@ -17,13 +23,10 @@ const baseConfig = mergeConfigs(
17
23
  ecmaVersion: "latest",
18
24
  sourceType: "module",
19
25
  },
20
- },
21
- js.configs.recommended,
22
- eslintPluginImportX.flatConfigs.recommended,
23
- {
24
26
  rules: {
25
- ...rules.importXRules,
26
- ...rules.eslintCoreRules,
27
+ // add our recommended rules
28
+ ...eslintCoreRules,
29
+ ...importXRules,
27
30
  },
28
31
  },
29
32
  );
@@ -35,6 +38,7 @@ const recommendedJS = mergeConfigs(
35
38
  baseConfig,
36
39
  // tsconfig.configs.base sets eslint parser to use the typescript parser to parse .js files - handles all modern syntax
37
40
  tsconfig.configs.base,
41
+ // add qlik's recommended javascript config
38
42
  {
39
43
  name: "recommended-js",
40
44
  files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
@@ -45,8 +49,15 @@ const recommendedJS = mergeConfigs(
45
49
  * @type {import("../types/index.js").ESLintFlatConfig}
46
50
  */
47
51
  const recommendedTS = mergeConfigs(
52
+ // base it on base config
48
53
  baseConfig,
54
+ // add recommended typescript config
55
+ ...tsconfig.configs.recommended,
56
+ // add import-x recommended typescript config
57
+ eslintPluginImportX.flatConfigs.typescript,
58
+ // add qlik's recommended typescript config
49
59
  {
60
+ name: "recommended-ts",
50
61
  files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts", "**/*.d.ts"],
51
62
  languageOptions: {
52
63
  parserOptions: {
@@ -54,13 +65,7 @@ const recommendedTS = mergeConfigs(
54
65
  projectService: true,
55
66
  },
56
67
  },
57
- },
58
- ...tsconfig.configs.recommended,
59
- eslintPluginImportX.flatConfigs.recommended,
60
- eslintPluginImportX.flatConfigs.typescript,
61
- {
62
- name: "recommended-ts",
63
- rules: rules.typescriptRules,
68
+ rules: typescriptRules,
64
69
  },
65
70
  );
66
71
 
@@ -4,45 +4,51 @@ import svelteParser from "svelte-eslint-parser";
4
4
  import tsEslint from "typescript-eslint";
5
5
  import { mergeConfigs } from "../utils/config.js";
6
6
  import { recommendedJS, recommendedTS } from "./recommended.js";
7
- import rules from "./rules/svelte.js";
7
+ import svelteRules from "./rules/svelte.js";
8
8
 
9
9
  /**
10
10
  * @type {import("../types/index.js").ESLintFlatConfig}
11
11
  * config for Svelte https://github.com/sveltejs/eslint-plugin-svelte
12
12
  */
13
- const svelte = mergeConfigs(...eslintPluginSvelte.configs["flat/recommended"], {
14
- name: "svelte",
15
- files: ["**/*.svelte"],
16
- languageOptions: {
17
- parser: svelteParser,
18
- parserOptions: {
19
- parser: tsEslint.parser,
20
- extraFileExtensions: [".svelte"],
13
+ const svelteSvelte = mergeConfigs(
14
+ // base it on svelte plugin recommended config
15
+ ...eslintPluginSvelte.configs["flat/recommended"],
16
+ // add qlik's recommended svelte config
17
+ {
18
+ name: "svelte",
19
+ files: ["**/*.svelte"],
20
+ languageOptions: {
21
+ parser: svelteParser,
22
+ parserOptions: {
23
+ parser: tsEslint.parser,
24
+ extraFileExtensions: [".svelte"],
25
+ },
21
26
  },
22
- },
23
- rules: {
24
- ...rules,
25
- // modify rules from eslint-plugin-svelte here
27
+ rules: {
28
+ ...svelteRules,
29
+ // modify rules from eslint-plugin-svelte here
26
30
 
27
- // Conflicting rules
28
- // https://github.com/sveltejs/eslint-plugin-svelte3/blob/master/OTHER_PLUGINS.md
29
- "import-x/first": "off",
30
- "import-x/no-duplicates": "off",
31
- "import-x/no-mutable-exports": "off",
32
- "import-x/no-unresolved": "off",
33
- "import-x/prefer-default-export": "off",
34
- "import-x/extensions": "off",
31
+ // Conflicting rules
32
+ // https://github.com/sveltejs/eslint-plugin-svelte3/blob/master/OTHER_PLUGINS.md
33
+ "import-x/first": "off",
34
+ "import-x/no-duplicates": "off",
35
+ "import-x/no-mutable-exports": "off",
36
+ "import-x/no-unresolved": "off",
37
+ "import-x/prefer-default-export": "off",
38
+ "import-x/extensions": "off",
35
39
 
36
- "@typescript-eslint/no-unsafe-call": "off",
37
- "@typescript-eslint/no-unsafe-return": "off",
38
- "@typescript-eslint/no-unsafe-argument": "off",
39
- "@typescript-eslint/no-unsafe-assignment": "off",
40
- "@typescript-eslint/no-unsafe-member-access": "off",
40
+ // Issues with TypeScript rules
41
+ "@typescript-eslint/no-unsafe-call": "off",
42
+ "@typescript-eslint/no-unsafe-return": "off",
43
+ "@typescript-eslint/no-unsafe-argument": "off",
44
+ "@typescript-eslint/no-unsafe-assignment": "off",
45
+ "@typescript-eslint/no-unsafe-member-access": "off",
41
46
 
42
- // Issues with function types that define parameters
43
- "no-unused-vars": "off",
47
+ // Issues with function types that define parameters
48
+ "no-unused-vars": "off",
49
+ },
44
50
  },
45
- });
51
+ );
46
52
 
47
- export default [recommendedJS, recommendedTS, svelte];
48
- export { svelte };
53
+ export default [recommendedJS, recommendedTS, svelteSvelte];
54
+ export { svelteSvelte as svelte };
@@ -1,36 +1,26 @@
1
1
  // @ts-check
2
2
  import vitestPlugin from "@vitest/eslint-plugin";
3
- // @ts-expect-error no types yet
4
3
  import testingLibraryPlugin from "eslint-plugin-testing-library";
5
4
  import { mergeConfigs } from "../utils/config.js";
6
- import rules from "./rules/index.js";
7
-
8
- /**
9
- * @satisfies {import("../types/index.js").ESLintFlatConfig["rules"]}
10
- */
11
- const vitestCommon = {};
12
5
 
13
6
  /**
14
7
  * @type {import("../types/index.js").ESLintFlatConfig}
15
8
  * config for jest https://github.com/jest-community/eslint-plugin-jest
16
9
  */
17
- const vitest = mergeConfigs(vitestCommon, {
18
- name: "vitest-js",
19
- plugins: {
20
- vitest: vitestPlugin,
21
- "testing-library": testingLibraryPlugin,
22
- },
23
-
24
- files: ["**/__test__/**/*.{js,jsx,ts,tsx}", "**/__tests__/**/*.{js,jsx,ts,tsx}"],
25
-
26
- rules: {
27
- // modify rules from eslint-plugin-vitest here
28
- ...vitestPlugin.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
29
- ...rules.testingLibraryRules,
30
- "no-magic-numbers": "off",
31
- "@typescript-eslint/no-magic-numbers": "off",
10
+ const vitest = mergeConfigs(
11
+ // base it on the recommended vitest config
12
+ vitestPlugin.configs.recommended,
13
+ // add testing-library plugin recommended config for react
14
+ testingLibraryPlugin.configs["flat/react"],
15
+ // add qlik's recommended vitest config
16
+ {
17
+ name: "vitest",
18
+ files: ["**/__test__/**/*.{js,jsx,ts,tsx}", "**/__tests__/**/*.{js,jsx,ts,tsx}"],
19
+ rules: {
20
+ // modify rules from eslint-plugin-vitest here
21
+ },
32
22
  },
33
- });
23
+ );
34
24
 
35
25
  export default [vitest];
36
26
  export { vitest };
package/src/index.d.ts CHANGED
@@ -1,4 +1,12 @@
1
- export default qlikEslintConfig;
1
+ import cjs, { cjsJS, cjsTS } from "./configs/cjs.js";
2
+ import esm, { esmJS, esmTS } from "./configs/esm.js";
3
+ import jest from "./configs/jest.js";
4
+ import playwright from "./configs/playwright.js";
5
+ import react, { reactJS, reactTS } from "./configs/react.js";
6
+ import recommended, { recommendedJS, recommendedTS } from "./configs/recommended.js";
7
+ import svelte from "./configs/svelte.js";
8
+ import vitest from "./configs/vitest.js";
9
+ import compose from "./utils/compose.js";
2
10
 
3
11
  declare namespace qlikEslintConfig {
4
12
  export namespace configs {
@@ -13,12 +21,6 @@ declare namespace qlikEslintConfig {
13
21
  }
14
22
  export { compose };
15
23
  }
16
- import cjs from "./configs/cjs.js";
17
- import esm from "./configs/esm.js";
18
- import jest from "./configs/jest.js";
19
- import playwright from "./configs/playwright.js";
20
- import react from "./configs/react.js";
21
- import recommended from "./configs/recommended.js";
22
- import svelte from "./configs/svelte.js";
23
- import vitest from "./configs/vitest.js";
24
- import compose from "./utils/compose.js";
24
+
25
+ export default qlikEslintConfig;
26
+ export { cjsJS, cjsTS, esmJS, esmTS, reactJS, reactTS, recommendedJS, recommendedTS };
package/src/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // Import ESLint configuration modules
2
- import cjs from "./configs/cjs.js";
3
- import esm from "./configs/esm.js";
2
+ import cjs, { cjsJS, cjsTS } from "./configs/cjs.js";
3
+ import esm, { esmJS, esmTS } from "./configs/esm.js";
4
4
  import jest from "./configs/jest.js";
5
5
  import playwright from "./configs/playwright.js";
6
- import react from "./configs/react.js";
7
- import recommended from "./configs/recommended.js";
6
+ import react, { reactJS, reactTS } from "./configs/react.js";
7
+ import recommended, { recommendedJS, recommendedTS } from "./configs/recommended.js";
8
8
  import svelte from "./configs/svelte.js";
9
9
  import vitest from "./configs/vitest.js";
10
10
  import compose from "./utils/compose.js";
@@ -27,3 +27,5 @@ const qlikEslintConfig = {
27
27
  };
28
28
 
29
29
  export default qlikEslintConfig;
30
+
31
+ export { cjsJS, cjsTS, esmJS, esmTS, reactJS, reactTS, recommendedJS, recommendedTS };
@@ -44,9 +44,9 @@ interface ESLintFlatConfigWithExtend extends ESLintFlatConfig {
44
44
  extend?: ESLintFlatConfig[];
45
45
  }
46
46
 
47
- export type QlikEslintConfig = {
47
+ type QlikEslintConfig = {
48
48
  configs: Record<string, ESLintFlatConfig[]>;
49
49
  compose: (...configs: ESLintFlatConfigWithExtend[]) => ESLintFlatConfig[];
50
50
  };
51
51
 
52
- export type { ESLintFlatConfig, ESLintFlatConfigWithExtend, ESLintLanguageOptions, ESLintPlugin };
52
+ export type { ESLintFlatConfig, ESLintFlatConfigWithExtend, ESLintLanguageOptions, ESLintPlugin, QlikEslintConfig };
@@ -7,17 +7,20 @@
7
7
  *
8
8
  * @example
9
9
  * ```js
10
- * import eslint from '@eslint/js';
11
- * import tseslint from 'typescript-eslint';
10
+ * import qlik from "@qlik/eslint-config";
12
11
  *
13
12
  * export default qlik.compose(
14
- * eslint.configs.recommended,
15
- * ...tseslint.configs.recommended,
13
+ * ...qlik.configs.react,
14
+ * ...qlik.configs.vitest,
16
15
  * {
17
16
  * rules: {
18
- * '@typescript-eslint/array-type': 'error',
17
+ * // Override rules if needed
19
18
  * },
20
19
  * },
20
+ * // In its own object so it's global
21
+ * {
22
+ * ignores: ["dist", "node_modules", "script"],
23
+ * },
21
24
  * );
22
25
  * ```
23
26
  */
@@ -1,5 +1,6 @@
1
1
  // these ones will only do shallow merge, but the merge function will do deep merge
2
2
  const noNeedToDeepMerge = ["plugins", "rules", "parser"];
3
+ const overWrite = ["files", "globals"];
3
4
 
4
5
  /**
5
6
  *
@@ -14,7 +15,9 @@ export const merge = (obj1, obj2) => {
14
15
  }
15
16
  const merged = { ...obj1 };
16
17
  Object.keys(obj2).forEach((key) => {
17
- if (Array.isArray(obj1[key]) && Array.isArray(obj2[key])) {
18
+ if (overWrite.includes(key)) {
19
+ merged[key] = obj2[key];
20
+ } else if (Array.isArray(obj1[key]) && Array.isArray(obj2[key])) {
18
21
  merged[key] = [...new Set([...obj1[key], ...obj2[key]])];
19
22
  } else if (noNeedToDeepMerge.includes(key)) {
20
23
  merged[key] = { ...obj1[key], ...obj2[key] };
@@ -1,19 +0,0 @@
1
- import eslintCoreRules from "./eslint-core.js";
2
- import importXRules from "./import-x.js";
3
- import nodeRules from "./node.js";
4
- import reactA11yRules from "./react-a11y.js";
5
- import reactHooksRules from "./react-hooks.js";
6
- import reactRules from "./react.js";
7
- import testingLibraryRules from "./testing-library.js";
8
- import typescriptRules from "./typescript.js";
9
-
10
- export default {
11
- eslintCoreRules,
12
- importXRules,
13
- nodeRules,
14
- reactRules,
15
- reactA11yRules,
16
- reactHooksRules,
17
- testingLibraryRules,
18
- typescriptRules,
19
- };
@@ -1,74 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * @satisfies {import("../../types/index.js").ESLintFlatConfig["rules"]}
5
- */
6
- const rules = {
7
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-events.md
8
- "testing-library/await-async-events": ["error", { eventModule: "userEvent" }],
9
-
10
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-queries.md
11
- "testing-library/await-async-queries": "error",
12
-
13
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-utils.md
14
- "testing-library/await-async-utils": "error",
15
-
16
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-events.md
17
- "testing-library/no-await-sync-events": ["error", { eventModules: ["fire-event"] }],
18
-
19
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-queries.md
20
- "testing-library/no-await-sync-queries": "error",
21
-
22
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-container.md
23
- "testing-library/no-container": "error",
24
-
25
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-debugging-utils.md
26
- "testing-library/no-debugging-utils": "warn",
27
-
28
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-dom-import.md
29
- "testing-library/no-dom-import": ["error", "react"],
30
-
31
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-global-regexp-flag-in-query.md
32
- "testing-library/no-global-regexp-flag-in-query": "error",
33
-
34
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-manual-cleanup.md
35
- "testing-library/no-manual-cleanup": "error",
36
-
37
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-node-access.md
38
- "testing-library/no-node-access": "error",
39
-
40
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-promise-in-fire-event.md
41
- "testing-library/no-promise-in-fire-event": "error",
42
-
43
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-render-in-lifecycle.md
44
- "testing-library/no-render-in-lifecycle": "error",
45
-
46
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-unnecessary-act.md
47
- "testing-library/no-unnecessary-act": "error",
48
-
49
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-multiple-assertions.md
50
- "testing-library/no-wait-for-multiple-assertions": "error",
51
-
52
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-side-effects.md
53
- "testing-library/no-wait-for-side-effects": "error",
54
-
55
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-snapshot.md
56
- "testing-library/no-wait-for-snapshot": "error",
57
-
58
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-find-by.md
59
- "testing-library/prefer-find-by": "error",
60
-
61
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-presence-queries.md
62
- "testing-library/prefer-presence-queries": "error",
63
-
64
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-by-disappearance.md
65
- "testing-library/prefer-query-by-disappearance": "error",
66
-
67
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md
68
- "testing-library/prefer-screen-queries": "error",
69
-
70
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/render-result-naming-convention.md
71
- "testing-library/render-result-naming-convention": "error",
72
- };
73
-
74
- export default rules;