@asd14/eslint-config 11.0.0 → 13.0.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.
@@ -1,11 +1,11 @@
1
+ import jestPlugin from "eslint-plugin-jest"
1
2
  import prettierConfig from "eslint-plugin-prettier/recommended"
2
3
  import globals from "globals"
3
4
 
4
5
  import baseConfig from "../rules/base.js"
6
+ import importConfig from "../rules/import.js"
5
7
  import jsdocConfig from "../rules/jsdoc.js"
6
8
  import unicornConfig from "../rules/unicorn.js"
7
- import importConfig from "../rules/import.js"
8
- import nxConfig from "../rules/nx.js"
9
9
 
10
10
  /** @type {import("eslint").Linter.RulesRecord} */
11
11
  const nodeSpecificRules = {
@@ -31,7 +31,7 @@ const nodeSpecificRules = {
31
31
  }
32
32
 
33
33
  /** @satisfies {import("eslint").Linter.Config} */
34
- export const nodeConfig = /** @type {const} */ ({
34
+ const nodeConfig = /** @type {const} */ ({
35
35
  name: "ASD14 config for Node.js source files",
36
36
  ignores: ["node_modules", "dist", "coverage", "build"],
37
37
  languageOptions: {
@@ -48,7 +48,6 @@ export const nodeConfig = /** @type {const} */ ({
48
48
  plugins: {
49
49
  ...importConfig.plugins,
50
50
  ...jsdocConfig.plugins,
51
- ...nxConfig.plugins,
52
51
  ...unicornConfig.plugins,
53
52
  ...prettierConfig.plugins,
54
53
  },
@@ -56,7 +55,6 @@ export const nodeConfig = /** @type {const} */ ({
56
55
  ...baseConfig.rules,
57
56
  ...importConfig.rules,
58
57
  ...jsdocConfig.rules,
59
- ...nxConfig.rules,
60
58
  ...unicornConfig.rules,
61
59
  ...nodeSpecificRules,
62
60
  ...prettierConfig.rules,
@@ -66,3 +64,33 @@ export const nodeConfig = /** @type {const} */ ({
66
64
  ...importConfig.settings,
67
65
  },
68
66
  })
67
+
68
+ const jestConfig = jestPlugin.configs["flat/recommended"]
69
+
70
+ /** @satisfies {import("eslint").Linter.Config} */
71
+ const nodeJestConfig = /** @type {const} */ ({
72
+ name: "ASD14's config for Node.js test files",
73
+ languageOptions: jestConfig.languageOptions,
74
+ plugins: jestConfig.plugins,
75
+ rules: {
76
+ ...jestConfig.rules,
77
+ "jest/require-top-level-describe": "error",
78
+ "jest/consistent-test-it": [
79
+ "error",
80
+ {
81
+ fn: "test",
82
+ withinDescribe: "test",
83
+ },
84
+ ],
85
+ "jest/valid-title": [
86
+ "error",
87
+ {
88
+ mustMatch: {
89
+ test: "^given \\[.*\\] should \\[.*\\]$",
90
+ },
91
+ },
92
+ ],
93
+ },
94
+ })
95
+
96
+ export { nodeConfig, nodeJestConfig }
@@ -1,5 +1,8 @@
1
+ import path from "node:path"
1
2
  import nxPlugin from "@nx/eslint-plugin"
2
3
 
4
+ import { findUpSync } from "../utils/find-up-sync.js"
5
+
3
6
  const RULES = {
4
7
  // Visibility and publishing rules
5
8
  publicCanOnlyImportPublic: {
@@ -53,7 +56,8 @@ const RULES = {
53
56
  }
54
57
 
55
58
  /** @satisfies {import("eslint").Linter.Config} */
56
- export default /** @type {const} */ ({
59
+ const nxConfig = /** @type {const} */ ({
60
+ name: "ASD14 config for source files inside an NX monorepo",
57
61
  plugins: {
58
62
  "@nx": nxPlugin,
59
63
  },
@@ -79,3 +83,39 @@ export default /** @type {const} */ ({
79
83
  ],
80
84
  },
81
85
  })
86
+
87
+ const MONOREPO_ROOT = path.dirname(findUpSync("nx.json"))
88
+
89
+ /** @satisfies {import("eslint").Linter.Config} */
90
+ const nxDevConfig = /** @type {const} */ ({
91
+ name: "ASD14 config for dev files inside an NX monorepo",
92
+ plugins: {
93
+ "@nx": nxPlugin,
94
+ },
95
+ rules: {
96
+ /*
97
+ * Point to the monorepo root folder since ~all~ most devDependencies
98
+ * used in test, story and config files reside in the root package.json.
99
+ */
100
+ "import/no-extraneous-dependencies": [
101
+ "error",
102
+ {
103
+ packageDir: ["./", MONOREPO_ROOT],
104
+ },
105
+ ],
106
+ "@nx/enforce-module-boundaries": [
107
+ "error",
108
+ {
109
+ allow: [],
110
+ depConstraints: [
111
+ {
112
+ sourceTag: "*",
113
+ onlyDependOnLibsWithTags: ["type:lib"],
114
+ },
115
+ ],
116
+ },
117
+ ],
118
+ },
119
+ })
120
+
121
+ export { nxConfig, nxDevConfig }
@@ -1,13 +1,14 @@
1
1
  import prettierConfig from "eslint-plugin-prettier/recommended"
2
2
  import globals from "globals"
3
3
 
4
+ import { nodeJestConfig } from "./node.js"
4
5
  import baseConfig from "../rules/base.js"
5
- import jsdocConfig from "../rules/jsdoc.js"
6
- import unicornConfig from "../rules/unicorn.js"
7
6
  import importConfig from "../rules/import.js"
8
- import tsConfig from "../rules/typescript.js"
9
- import nxConfig from "../rules/nx.js"
7
+ import jsdocConfig from "../rules/jsdoc.js"
10
8
  import reactHooksConfig from "../rules/react.js"
9
+ import rtlConfig from "../rules/rtl.js"
10
+ import tsConfig from "../rules/typescript.js"
11
+ import unicornConfig from "../rules/unicorn.js"
11
12
 
12
13
  /** @type {import("eslint").Linter.RulesRecord} */
13
14
  const reactSpecificRules = {
@@ -37,7 +38,7 @@ const reactSpecificRules = {
37
38
  }
38
39
 
39
40
  /** @satisfies {import("eslint").Linter.Config} */
40
- export const reactConfig = /** @type {const} */ ({
41
+ const reactConfig = /** @type {const} */ ({
41
42
  name: "ASD14 config for React source files",
42
43
  ignores: ["node_modules", "dist", "coverage", "build"],
43
44
  languageOptions: {
@@ -59,7 +60,6 @@ export const reactConfig = /** @type {const} */ ({
59
60
  plugins: {
60
61
  ...importConfig.plugins,
61
62
  ...jsdocConfig.plugins,
62
- ...nxConfig.plugins,
63
63
  ...reactHooksConfig.plugins,
64
64
  ...tsConfig.plugins,
65
65
  ...unicornConfig.plugins,
@@ -69,7 +69,6 @@ export const reactConfig = /** @type {const} */ ({
69
69
  ...baseConfig.rules,
70
70
  ...importConfig.rules,
71
71
  ...jsdocConfig.rules,
72
- ...nxConfig.rules,
73
72
  ...reactHooksConfig.rules,
74
73
  ...reactSpecificRules,
75
74
  ...tsConfig.rules,
@@ -87,3 +86,19 @@ export const reactConfig = /** @type {const} */ ({
87
86
  "import/ignore": [".(sass|scss|less|css)$"],
88
87
  },
89
88
  })
89
+
90
+ /** @satisfies {import("eslint").Linter.Config} */
91
+ const reactJestConfig = /** @type {const} */ ({
92
+ ...nodeJestConfig,
93
+ name: "ASD14 config for React test files",
94
+ plugins: {
95
+ ...nodeJestConfig.plugins,
96
+ ...rtlConfig.plugins,
97
+ },
98
+ rules: {
99
+ ...nodeJestConfig.rules,
100
+ ...rtlConfig.rules,
101
+ },
102
+ })
103
+
104
+ export { reactConfig, reactJestConfig }
@@ -1,5 +1,5 @@
1
- import tsParser from "@typescript-eslint/parser"
2
1
  import tsPlugin from "@typescript-eslint/eslint-plugin"
2
+ import tsParser from "@typescript-eslint/parser"
3
3
 
4
4
  /** @satisfies {import("eslint").Linter.Config} */
5
5
  export default /** @type {const} */ ({
@@ -1,14 +0,0 @@
1
- export namespace devFilesConfig {
2
- let rules: {
3
- readonly "@nx/enforce-module-boundaries": ["error", {
4
- readonly allow: readonly [];
5
- readonly depConstraints: readonly [{
6
- readonly sourceTag: "*";
7
- readonly onlyDependOnLibsWithTags: readonly ["type:lib"];
8
- }];
9
- }];
10
- readonly "import/no-extraneous-dependencies": ["error", {
11
- readonly packageDir: readonly ["./", string];
12
- }];
13
- };
14
- }
@@ -1,17 +0,0 @@
1
- export namespace nodeJestConfig {
2
- let name: "ASD14's config for Node.js test files";
3
- let languageOptions: import("eslint").Linter.LanguageOptions | undefined;
4
- let plugins: Record<string, import("eslint").ESLint.Plugin> | undefined;
5
- let rules: {
6
- readonly "jest/require-top-level-describe": "error";
7
- readonly "jest/consistent-test-it": ["error", {
8
- readonly fn: "test";
9
- readonly withinDescribe: "test";
10
- }];
11
- readonly "jest/valid-title": ["error", {
12
- readonly mustMatch: {
13
- readonly test: "^given \\[.*\\] should \\[.*\\]$";
14
- };
15
- }];
16
- };
17
- }
@@ -1,20 +0,0 @@
1
- /** @satisfies {import("eslint").Linter.Config} */
2
- export const reactJestConfig: {
3
- readonly name: "ASD14 config for React test files";
4
- readonly plugins: {
5
- readonly [x: string]: import("eslint").ESLint.Plugin;
6
- };
7
- readonly rules: {
8
- readonly "jest/require-top-level-describe": "error";
9
- readonly "jest/consistent-test-it": ["error", {
10
- readonly fn: "test";
11
- readonly withinDescribe: "test";
12
- }];
13
- readonly "jest/valid-title": ["error", {
14
- readonly mustMatch: {
15
- readonly test: "^given \\[.*\\] should \\[.*\\]$";
16
- };
17
- }];
18
- };
19
- readonly languageOptions: import("eslint").Linter.LanguageOptions | undefined;
20
- };
@@ -1,6 +0,0 @@
1
- export * from "./configs/node.js";
2
- export * from "./configs/ts-node.js";
3
- export * from "./configs/node-jest.js";
4
- export * from "./configs/react.js";
5
- export * from "./configs/react-jest.js";
6
- export * from "./configs/dev-files.js";
@@ -1,9 +0,0 @@
1
- declare namespace _default {
2
- let files: ["type-tests/**/*.{js,jsx,ts,tsx}", "*.tt.{js,jsx,ts,tsx}", "tests/**/*.{js,jsx,ts,tsx}", "*.test.{js,jsx,ts,tsx}", "stories/**/*.{js,jsx,ts,tsx}", "*.stories.{js,jsx,ts,tsx}", "eslint.config.js", "jest.setup.js", "jest.config.js"];
3
- let rules: {
4
- readonly "import/no-extraneous-dependencies": ["error", {
5
- readonly packageDir: readonly ["./", string];
6
- }];
7
- };
8
- }
9
- export default _default;
@@ -1,13 +0,0 @@
1
- declare namespace _default {
2
- let files: ["jest.setup.{ts,js}", "jest.config.{ts,js}", "eslint.config.js"];
3
- let rules: {
4
- readonly "@nx/enforce-module-boundaries": ["error", {
5
- readonly allow: readonly [];
6
- readonly depConstraints: readonly [{
7
- readonly sourceTag: "*";
8
- readonly onlyDependOnLibsWithTags: readonly ["type:lib"];
9
- }];
10
- }];
11
- };
12
- }
13
- export default _default;
@@ -1,17 +0,0 @@
1
- import nxDev from "../rules/nx-dev.js"
2
- import importDev from "../rules/import-dev.js"
3
-
4
- /**
5
- * ESLint configuration for development files (configs, tests etc)
6
- *
7
- * - Configure "import/no-extraneous-dependencies" to allow importing of
8
- * packages from the root monorepo "node_modules" folder.
9
- *
10
- * @satisfies {import("eslint").Linter.Config}
11
- */
12
- export const devFilesConfig = /** @type {const} */ ({
13
- rules: {
14
- ...importDev.rules,
15
- ...nxDev.rules,
16
- },
17
- })
@@ -1,29 +0,0 @@
1
- import jestPlugin from "eslint-plugin-jest"
2
-
3
- const jestConfig = jestPlugin.configs["flat/recommended"]
4
-
5
- /** @satisfies {import("eslint").Linter.Config} */
6
- export const nodeJestConfig = /** @type {const} */ ({
7
- name: "ASD14's config for Node.js test files",
8
- languageOptions: jestConfig.languageOptions,
9
- plugins: jestConfig.plugins,
10
- rules: {
11
- ...jestConfig.rules,
12
- "jest/require-top-level-describe": "error",
13
- "jest/consistent-test-it": [
14
- "error",
15
- {
16
- fn: "test",
17
- withinDescribe: "test",
18
- },
19
- ],
20
- "jest/valid-title": [
21
- "error",
22
- {
23
- mustMatch: {
24
- test: "^given \\[.*\\] should \\[.*\\]$",
25
- },
26
- },
27
- ],
28
- },
29
- })
@@ -1,16 +0,0 @@
1
- import { nodeJestConfig } from "./node-jest.js"
2
- import rtlConfig from "../rules/rtl.js"
3
-
4
- /** @satisfies {import("eslint").Linter.Config} */
5
- export const reactJestConfig = /** @type {const} */ ({
6
- ...nodeJestConfig,
7
- name: "ASD14 config for React test files",
8
- plugins: {
9
- ...nodeJestConfig.plugins,
10
- ...rtlConfig.plugins,
11
- },
12
- rules: {
13
- ...nodeJestConfig.rules,
14
- ...rtlConfig.rules,
15
- },
16
- })
package/src/index.js DELETED
@@ -1,6 +0,0 @@
1
- export * from "./configs/node.js"
2
- export * from "./configs/ts-node.js"
3
- export * from "./configs/node-jest.js"
4
- export * from "./configs/react.js"
5
- export * from "./configs/react-jest.js"
6
- export * from "./configs/dev-files.js"
@@ -1,31 +0,0 @@
1
- import path from "node:path"
2
- import { findUpSync } from "../utils/find-up-sync.js"
3
-
4
- const MONOREPO_ROOT = path.dirname(findUpSync("nx.json"))
5
-
6
- /** @satisfies {import("eslint").Linter.Config} */
7
- export default /** @type {const} */ ({
8
- files: [
9
- "type-tests/**/*.{js,jsx,ts,tsx}",
10
- "*.tt.{js,jsx,ts,tsx}",
11
- "tests/**/*.{js,jsx,ts,tsx}",
12
- "*.test.{js,jsx,ts,tsx}",
13
- "stories/**/*.{js,jsx,ts,tsx}",
14
- "*.stories.{js,jsx,ts,tsx}",
15
- "eslint.config.js",
16
- "jest.setup.js",
17
- "jest.config.js",
18
- ],
19
- rules: {
20
- /*
21
- * Point to the monorepo root folder since ~all~ most devDependencies
22
- * used in test, story and config files reside in the root package.json.
23
- */
24
- "import/no-extraneous-dependencies": [
25
- "error",
26
- {
27
- packageDir: ["./", MONOREPO_ROOT],
28
- },
29
- ],
30
- },
31
- })
@@ -1,23 +0,0 @@
1
- /** @satisfies {import("eslint").Linter.Config} */
2
- export default /** @type {const} */ ({
3
- /*
4
- * Configuration files dont need any visibility restrictions since
5
- * they are only for development and build purposes and are not
6
- * emited in the final bundle/public artifacts.
7
- */
8
- files: ["jest.setup.{ts,js}", "jest.config.{ts,js}", "eslint.config.js"],
9
- rules: {
10
- "@nx/enforce-module-boundaries": [
11
- "error",
12
- {
13
- allow: [],
14
- depConstraints: [
15
- {
16
- sourceTag: "*",
17
- onlyDependOnLibsWithTags: ["type:lib"],
18
- },
19
- ],
20
- },
21
- ],
22
- },
23
- })
File without changes