@pob/eslint-config 57.2.0 → 58.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [58.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v57.3.1...v58.0.0) (2024-08-14)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * update eslint v9
11
+
12
+ ### Features
13
+
14
+ * update eslint v9 ([6f8647f](https://github.com/christophehurpeau/eslint-config-pob/commit/6f8647f45589e9a9387bd38b9881fd2035ab32ad))
15
+
16
+ Version bump for dependency: @pob/eslint-plugin
17
+
18
+
19
+ ## [57.3.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v57.2.0...v57.3.0) (2024-08-11)
20
+
21
+ ### Features
22
+
23
+ * config improvements ([8d35116](https://github.com/christophehurpeau/eslint-config-pob/commit/8d35116760d86390738430c8d5bc1ac7fcb53668))
24
+
25
+ ### Bug Fixes
26
+
27
+ * disable import/order for rollup.config to build in proper order ([dec8d16](https://github.com/christophehurpeau/eslint-config-pob/commit/dec8d161b6322a251f10772913d51c4ec6289fa8))
28
+ * ignore .d.ts ([4cb7b0d](https://github.com/christophehurpeau/eslint-config-pob/commit/4cb7b0d76c1daa27f17d52c0ee2c910eda0816f9))
29
+
6
30
  ## [57.2.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v57.1.0...v57.2.0) (2024-08-11)
7
31
 
8
32
  ### Features
package/lib/_base.js CHANGED
@@ -18,7 +18,14 @@ export default [
18
18
  },
19
19
  },
20
20
  {
21
- ignores: [".yarn", "**/dist/", "**/build/", "**/coverage/", "**/.next/"],
21
+ ignores: [
22
+ ".yarn",
23
+ "**/dist/",
24
+ "**/build/",
25
+ "**/coverage/",
26
+ "**/.next/",
27
+ "**/*.d.ts",
28
+ ],
22
29
  },
23
30
  js.configs.recommended,
24
31
  pobPlugin.configs.base,
package/lib/index.js CHANGED
@@ -1,18 +1,98 @@
1
+ /* eslint-disable complexity */
1
2
  import path from "node:path";
2
3
  import { fileURLToPath } from "node:url";
4
+ import { isDeepStrictEqual } from "node:util";
3
5
  import { FlatCompat } from "@eslint/eslintrc";
4
6
  import baseConfigs from "./_base.js";
5
7
  import baseCommonjsConfig from "./base/commonjs.js";
6
8
  import baseModuleConfig from "./base/module.js";
7
9
  import nodePluginCommonjsConfigs from "./node/commonjs.js";
8
10
  import nodePluginModuleConfigs from "./node/module.js";
11
+ import testConfig from "./overrides/test.js";
9
12
  import importPluginBaseConfigs from "./plugins/import/import-base.js";
10
13
  import importPluginCommonjsConfig from "./plugins/import/import-commonjs.js";
11
14
  import importPluginModuleConfig from "./plugins/import/import-module.js";
12
15
 
16
+ export const apply = ({
17
+ files,
18
+ filesOverridesIf = [],
19
+ extensions = "{js,cjs,mjs}",
20
+ configs,
21
+ mode = "throw-if-files-exists",
22
+ }) => {
23
+ return configs.map((config) => {
24
+ switch (mode) {
25
+ case "throw-if-files-exists": {
26
+ if (config.files) {
27
+ if (
28
+ !filesOverridesIf.some((filesOverrides) =>
29
+ isDeepStrictEqual(filesOverrides, config.files),
30
+ )
31
+ ) {
32
+ console.log({ filesOverridesIf });
33
+ throw new Error(
34
+ `"files" already exists: ${JSON.stringify(config.files)} for ${config.name ? `"${config.name}"` : JSON.stringify(config)}`,
35
+ );
36
+ }
37
+ }
38
+
39
+ return {
40
+ ...config,
41
+ files,
42
+ };
43
+ }
44
+ case "keep-extension": {
45
+ if (files.length !== 1) {
46
+ throw new Error(
47
+ `apply: "files" should have only one element: ${files}`,
48
+ );
49
+ }
50
+ if (!files[0].startsWith("**/")) {
51
+ throw new Error(`apply: "files" should start with "**/": ${files}`);
52
+ }
53
+
54
+ return {
55
+ ...config,
56
+ files: config.files.map((filesGlob) => {
57
+ if (!filesGlob.startsWith("**/")) {
58
+ throw new Error(
59
+ `"files" should start with "**/": ${config.files} for ${config.name ? `"${config.name}"` : JSON.stringify(config)}`,
60
+ );
61
+ }
62
+ return files[0] + filesGlob.slice(3);
63
+ }),
64
+ };
65
+ }
66
+ case "directory": {
67
+ if (files.length !== 1) {
68
+ throw new Error(
69
+ `apply: "files" should have only one element: ${files}`,
70
+ );
71
+ }
72
+ return {
73
+ ...config,
74
+ files: config.files
75
+ ? config.files.map((fileGlob) => files[0] + fileGlob)
76
+ : [`${files[0]}**/*.${extensions}`],
77
+ };
78
+ }
79
+
80
+ default:
81
+ throw new Error('apply: "mode" is invalid');
82
+ }
83
+ });
84
+ };
85
+
13
86
  export default (url) => {
14
87
  const __filename = fileURLToPath(url);
15
88
  const __dirname = path.dirname(__filename);
89
+ const extensions = "{js,cjs,mjs}";
90
+
91
+ const testFiles = [
92
+ `**/*.test${extensions}`,
93
+ `**/__tests__/**/*.${extensions}`,
94
+ `**/__mocks__/**/*.${extensions}`,
95
+ ];
16
96
 
17
97
  const compat = new FlatCompat({
18
98
  baseDirectory: __dirname,
@@ -25,18 +105,19 @@ export default (url) => {
25
105
  importPluginCommonjsConfig,
26
106
  ...nodePluginCommonjsConfigs,
27
107
 
28
- {
29
- files: ["**/*.mjs"],
30
- ...baseModuleConfig,
31
- },
32
- {
108
+ ...apply({
33
109
  files: ["**/*.mjs"],
34
- ...importPluginModuleConfig,
35
- },
36
- ...nodePluginModuleConfigs.map((config) => ({
37
- ...config,
38
- files: ["**/*.mjs"],
39
- })),
110
+ configs: [
111
+ baseModuleConfig,
112
+ importPluginModuleConfig,
113
+ ...nodePluginModuleConfigs,
114
+ ],
115
+ }),
116
+
117
+ ...apply({
118
+ files: testFiles,
119
+ configs: [testConfig],
120
+ }),
40
121
  ];
41
122
 
42
123
  const baseModule = [
@@ -44,23 +125,26 @@ export default (url) => {
44
125
  baseModuleConfig,
45
126
  ...importPluginBaseConfigs(compat),
46
127
  importPluginModuleConfig,
47
- {
48
- files: ["**/*.cjs"],
49
- ...baseCommonjsConfig,
50
- },
51
- {
128
+
129
+ ...apply({
52
130
  files: ["**/*.cjs"],
53
- ...importPluginCommonjsConfig,
54
- },
131
+ configs: [baseCommonjsConfig, importPluginCommonjsConfig],
132
+ }),
133
+
134
+ ...apply({
135
+ files: testFiles,
136
+ configs: [testConfig],
137
+ }),
55
138
  ];
56
139
 
57
140
  const nodeModule = [
58
141
  ...baseModule,
59
142
  ...nodePluginModuleConfigs,
60
- ...nodePluginCommonjsConfigs.map((config) => ({
61
- ...config,
143
+
144
+ ...apply({
62
145
  files: ["**/*.cjs"],
63
- })),
146
+ configs: [...nodePluginCommonjsConfigs],
147
+ }),
64
148
  ];
65
149
 
66
150
  return {
@@ -0,0 +1,8 @@
1
+ export default {
2
+ name: "@pob/eslint-config/test",
3
+
4
+ rules: {
5
+ // allow dev dependencies
6
+ "import/no-extraneous-dependencies": ["error", { devDependencies: true }],
7
+ },
8
+ };
@@ -130,9 +130,11 @@ export default (compat) => [
130
130
  },
131
131
  }),
132
132
  {
133
+ name: "@pob/eslint-config/import/rollup-config",
133
134
  files: ["rollup.config.mjs", "rollup.config.mjs"],
134
135
  rules: {
135
136
  "import/no-relative-packages": "off",
137
+ "import/order": "off",
136
138
  },
137
139
  },
138
140
  ];
@@ -1,5 +1,6 @@
1
1
  export default {
2
2
  name: "@pob/eslint-config/errors",
3
+
3
4
  rules: {
4
5
  // https://eslint.org/docs/rules/for-direction
5
6
  "for-direction": "error",
@@ -19,6 +20,9 @@ export default {
19
20
  // https://eslint.org/docs/rules/no-console
20
21
  "no-console": "warn",
21
22
 
23
+ // https://eslint.org/docs/rules/no-constant-condition
24
+ "no-constant-condition": "error",
25
+
22
26
  // https://eslint.org/docs/rules/no-control-regex
23
27
  "no-control-regex": "error",
24
28
 
@@ -55,9 +59,6 @@ export default {
55
59
  // https://eslint.org/docs/rules/no-import-assign
56
60
  "no-import-assign": "error",
57
61
 
58
- // https://eslint.org/docs/rules/no-inner-declarations
59
- "no-inner-declarations": "error",
60
-
61
62
  // https://eslint.org/docs/rules/no-invalid-regexp
62
63
  "no-invalid-regexp": "error",
63
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pob/eslint-config",
3
- "version": "57.2.0",
3
+ "version": "58.0.0",
4
4
  "description": "eslint config files",
5
5
  "keywords": [],
6
6
  "author": "Christophe Hurpeau <christophe@hurpeau.com> (http://christophe.hurpeau.com/)",
@@ -13,7 +13,7 @@
13
13
  "homepage": "https://github.com/christophehurpeau/eslint-config-pob",
14
14
  "type": "module",
15
15
  "engines": {
16
- "node": ">=18.12.0"
16
+ "node": ">=18.18.0"
17
17
  },
18
18
  "sideEffects": false,
19
19
  "main": "./lib/index.js",
@@ -40,23 +40,23 @@
40
40
  "pob": {},
41
41
  "prettier": "@pob/root/prettier-config",
42
42
  "peerDependencies": {
43
- "eslint": "^8.56.0"
43
+ "eslint": "^9.9.0"
44
44
  },
45
45
  "dependencies": {
46
46
  "@eslint/compat": "^1.1.1",
47
- "@eslint/eslintrc": "2.1.4",
48
- "@eslint/js": "^8.56.0",
49
- "@pob/eslint-plugin": "57.0.0",
47
+ "@eslint/eslintrc": "3.1.0",
48
+ "@eslint/js": "^9.9.0",
49
+ "@pob/eslint-plugin": "58.0.0",
50
50
  "confusing-browser-globals": "^1.0.11",
51
51
  "eslint-plugin-import": "^2.29.1",
52
52
  "eslint-plugin-n": "^17.4.0",
53
- "eslint-plugin-unicorn": "^52.0.0"
53
+ "eslint-plugin-unicorn": "^55.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "eslint": "8.57.0",
56
+ "eslint": "9.9.0",
57
57
  "eslint-plugin-import": "2.29.1",
58
58
  "eslint-plugin-n": "17.4.0",
59
- "eslint-plugin-unicorn": "52.0.0",
59
+ "eslint-plugin-unicorn": "55.0.0",
60
60
  "typescript": "5.5.4"
61
61
  }
62
62
  }