@pob/eslint-config 57.2.0 → 57.3.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 +11 -0
- package/lib/_base.js +8 -1
- package/lib/index.js +105 -21
- package/lib/overrides/test.js +8 -0
- package/lib/plugins/import/import-base.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## [57.3.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v57.2.0...v57.3.0) (2024-08-11)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* config improvements ([8d35116](https://github.com/christophehurpeau/eslint-config-pob/commit/8d35116760d86390738430c8d5bc1ac7fcb53668))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* disable import/order for rollup.config to build in proper order ([dec8d16](https://github.com/christophehurpeau/eslint-config-pob/commit/dec8d161b6322a251f10772913d51c4ec6289fa8))
|
|
15
|
+
* ignore .d.ts ([4cb7b0d](https://github.com/christophehurpeau/eslint-config-pob/commit/4cb7b0d76c1daa27f17d52c0ee2c910eda0816f9))
|
|
16
|
+
|
|
6
17
|
## [57.2.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v57.1.0...v57.2.0) (2024-08-11)
|
|
7
18
|
|
|
8
19
|
### Features
|
package/lib/_base.js
CHANGED
|
@@ -18,7 +18,14 @@ export default [
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
ignores: [
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
49
|
-
...baseCommonjsConfig,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
128
|
+
|
|
129
|
+
...apply({
|
|
52
130
|
files: ["**/*.cjs"],
|
|
53
|
-
|
|
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
|
-
|
|
61
|
-
|
|
143
|
+
|
|
144
|
+
...apply({
|
|
62
145
|
files: ["**/*.cjs"],
|
|
63
|
-
|
|
146
|
+
configs: [...nodePluginCommonjsConfigs],
|
|
147
|
+
}),
|
|
64
148
|
];
|
|
65
149
|
|
|
66
150
|
return {
|
|
@@ -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
|
];
|