@pob/eslint-config 59.3.1 → 59.4.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 +16 -0
- package/lib/_base.js +22 -17
- package/lib/index.js +46 -84
- package/lib/languages/json.js +38 -0
- package/lib/plugins/import/import-base.js +1 -1
- package/lib/plugins/regexp.js +6 -3
- package/lib/utils/apply.js +95 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
## [59.4.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v59.3.2...v59.4.0) (2025-01-17)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **deps:** update dependency @eslint/json to ^0.9.0 ([#726](https://github.com/christophehurpeau/eslint-config-pob/issues/726)) ([a893179](https://github.com/christophehurpeau/eslint-config-pob/commit/a893179bde090c6af7a8cc10a40698943c52efc3))
|
|
11
|
+
* json ([bae42fa](https://github.com/christophehurpeau/eslint-config-pob/commit/bae42fa92ed5ee37a0f98aeaea0e6a74f2f0c608))
|
|
12
|
+
|
|
13
|
+
Version bump for dependency: @pob/eslint-plugin
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [59.3.2](https://github.com/christophehurpeau/eslint-config-pob/compare/v59.3.1...v59.3.2) (2024-12-28)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* properly apply scripts override ([40c0217](https://github.com/christophehurpeau/eslint-config-pob/commit/40c021797caf45b2a3ce15b590f27db00f0a4b5d))
|
|
21
|
+
|
|
6
22
|
## [59.3.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v59.3.0...v59.3.1) (2024-12-28)
|
|
7
23
|
|
|
8
24
|
### Bug Fixes
|
package/lib/_base.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import js from "@eslint/js";
|
|
2
2
|
import pobPlugin from "@pob/eslint-plugin";
|
|
3
|
+
import jsonConfigs from "./languages/json.js";
|
|
3
4
|
import regexpPluginConfigs from "./plugins/regexp.js";
|
|
4
5
|
import unicornPluginConfigs from "./plugins/unicorn.js";
|
|
5
6
|
import bestPracticesConfig from "./rules/best-practices.js";
|
|
@@ -7,18 +8,24 @@ import codeQualityConfig from "./rules/code-quality.js";
|
|
|
7
8
|
import devOnlyConfig from "./rules/dev-only.js";
|
|
8
9
|
import errorsConfig from "./rules/errors.js";
|
|
9
10
|
import styleConfig from "./rules/style.js";
|
|
11
|
+
import { apply } from "./utils/apply.js";
|
|
10
12
|
|
|
11
13
|
export default [
|
|
12
14
|
{
|
|
15
|
+
name: "@pob/eslint-config/base/linterOptions",
|
|
13
16
|
linterOptions: {
|
|
14
17
|
// todo noInlineConfig: true,
|
|
15
18
|
reportUnusedDisableDirectives: "error",
|
|
16
19
|
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "@pob/eslint-config/base/pob-plugin",
|
|
17
23
|
plugins: {
|
|
18
24
|
"@pob": pobPlugin,
|
|
19
25
|
},
|
|
20
26
|
},
|
|
21
27
|
{
|
|
28
|
+
name: "@pob/eslint-config/base/ignores",
|
|
22
29
|
ignores: [
|
|
23
30
|
".yarn",
|
|
24
31
|
"**/dist/",
|
|
@@ -29,22 +36,20 @@ export default [
|
|
|
29
36
|
"**/*.d.ts",
|
|
30
37
|
],
|
|
31
38
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
...jsonConfigs,
|
|
40
|
+
...apply({
|
|
41
|
+
extensions: "{js,mjs,cjs,ts,tsx}",
|
|
42
|
+
mode: "add-extensions",
|
|
43
|
+
configs: [
|
|
44
|
+
{ name: "js.configs.recommended", ...js.configs.recommended },
|
|
45
|
+
pobPlugin.configs.base,
|
|
46
|
+
...unicornPluginConfigs,
|
|
47
|
+
...regexpPluginConfigs,
|
|
48
|
+
bestPracticesConfig,
|
|
49
|
+
codeQualityConfig,
|
|
50
|
+
errorsConfig,
|
|
51
|
+
styleConfig,
|
|
52
|
+
],
|
|
53
|
+
}),
|
|
40
54
|
devOnlyConfig,
|
|
41
|
-
|
|
42
|
-
// TODO
|
|
43
|
-
// {
|
|
44
|
-
// files: ["*.json"],
|
|
45
|
-
// languageOptions: {
|
|
46
|
-
// parser: jsoncParser,
|
|
47
|
-
// },
|
|
48
|
-
// rules: {},
|
|
49
|
-
// },
|
|
50
55
|
];
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
|
-
import { isDeepStrictEqual } from "node:util";
|
|
3
1
|
import baseConfigs from "./_base.js";
|
|
4
2
|
import baseCommonjsConfig from "./base/commonjs.js";
|
|
5
3
|
import baseModuleConfig from "./base/module.js";
|
|
@@ -10,76 +8,9 @@ import testOverrideConfig from "./overrides/test.js";
|
|
|
10
8
|
import importPluginBaseConfigs from "./plugins/import/import-base.js";
|
|
11
9
|
import importPluginCommonjsConfig from "./plugins/import/import-commonjs.js";
|
|
12
10
|
import importPluginModuleConfig from "./plugins/import/import-module.js";
|
|
11
|
+
import { apply } from "./utils/apply.js";
|
|
13
12
|
|
|
14
|
-
export
|
|
15
|
-
filesOverridesIf = [],
|
|
16
|
-
extensions = "{js,cjs,mjs}",
|
|
17
|
-
files = [`**/*.${extensions}`],
|
|
18
|
-
configs,
|
|
19
|
-
mode = "throw-if-files-exists",
|
|
20
|
-
}) => {
|
|
21
|
-
return configs.map((config) => {
|
|
22
|
-
switch (mode) {
|
|
23
|
-
case "throw-if-files-exists": {
|
|
24
|
-
if (config.files) {
|
|
25
|
-
if (
|
|
26
|
-
!filesOverridesIf.some((filesOverrides) =>
|
|
27
|
-
isDeepStrictEqual(filesOverrides, config.files),
|
|
28
|
-
)
|
|
29
|
-
) {
|
|
30
|
-
console.log({ filesOverridesIf });
|
|
31
|
-
throw new Error(
|
|
32
|
-
`"files" already exists: ${JSON.stringify(config.files)} for ${config.name ? `"${config.name}"` : JSON.stringify(config)}`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
...config,
|
|
39
|
-
files,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
case "keep-extension": {
|
|
43
|
-
if (files.length !== 1) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`apply: "files" should have only one element: ${files}`,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
if (!files[0].startsWith("**/")) {
|
|
49
|
-
throw new Error(`apply: "files" should start with "**/": ${files}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
...config,
|
|
54
|
-
files: config.files.map((filesGlob) => {
|
|
55
|
-
if (!filesGlob.startsWith("**/")) {
|
|
56
|
-
throw new Error(
|
|
57
|
-
`"files" should start with "**/": ${config.files} for ${config.name ? `"${config.name}"` : JSON.stringify(config)}`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return files[0] + filesGlob.slice(3);
|
|
61
|
-
}),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
case "directory": {
|
|
65
|
-
if (files.length !== 1) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
`apply: "files" should have only one element: ${files}`,
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
...config,
|
|
72
|
-
files: config.files
|
|
73
|
-
? config.files.map((fileGlob) => files[0] + fileGlob)
|
|
74
|
-
: [`${files[0]}**/*.${extensions}`],
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
default:
|
|
79
|
-
throw new Error('apply: "mode" is invalid');
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
};
|
|
13
|
+
export { apply } from "./utils/apply.js";
|
|
83
14
|
|
|
84
15
|
export default () => {
|
|
85
16
|
const extensions = "{js,cjs,mjs}";
|
|
@@ -92,14 +23,27 @@ export default () => {
|
|
|
92
23
|
|
|
93
24
|
const nodeCommonjs = [
|
|
94
25
|
...baseConfigs,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
26
|
+
...apply({
|
|
27
|
+
mode: "keep-files-if-exists",
|
|
28
|
+
files: ["**/*.{js,cjs,mjs,mts,ts,tsx,cts}"],
|
|
29
|
+
configs: [
|
|
30
|
+
baseCommonjsConfig,
|
|
31
|
+
...importPluginBaseConfigs,
|
|
32
|
+
importPluginCommonjsConfig,
|
|
33
|
+
...nodePluginCommonjsConfigs,
|
|
34
|
+
],
|
|
35
|
+
}),
|
|
36
|
+
|
|
37
|
+
...apply({
|
|
38
|
+
extensions,
|
|
39
|
+
mode: "directory",
|
|
40
|
+
files: ["scripts/"],
|
|
41
|
+
configs: [scriptsOverrideConfig],
|
|
42
|
+
}),
|
|
100
43
|
|
|
101
44
|
...apply({
|
|
102
|
-
files: ["**/*.mjs"],
|
|
45
|
+
files: ["**/*.{mjs,mts}"],
|
|
46
|
+
mode: "keep-files-if-exists",
|
|
103
47
|
configs: [
|
|
104
48
|
baseModuleConfig,
|
|
105
49
|
importPluginModuleConfig,
|
|
@@ -115,12 +59,19 @@ export default () => {
|
|
|
115
59
|
|
|
116
60
|
const baseModule = [
|
|
117
61
|
...baseConfigs,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
62
|
+
...apply({
|
|
63
|
+
mode: "keep-files-if-exists",
|
|
64
|
+
files: ["**/*.{js,mjs,cjs,mts,ts,tsx,cts}"],
|
|
65
|
+
configs: [
|
|
66
|
+
baseModuleConfig,
|
|
67
|
+
...importPluginBaseConfigs,
|
|
68
|
+
importPluginModuleConfig,
|
|
69
|
+
],
|
|
70
|
+
}),
|
|
121
71
|
|
|
122
72
|
...apply({
|
|
123
|
-
|
|
73
|
+
mode: "keep-files-if-exists",
|
|
74
|
+
files: ["**/*.{cjs,cts}"],
|
|
124
75
|
configs: [baseCommonjsConfig, importPluginCommonjsConfig],
|
|
125
76
|
}),
|
|
126
77
|
|
|
@@ -132,11 +83,22 @@ export default () => {
|
|
|
132
83
|
|
|
133
84
|
const nodeModule = [
|
|
134
85
|
...baseModule,
|
|
135
|
-
...
|
|
136
|
-
|
|
86
|
+
...apply({
|
|
87
|
+
mode: "keep-files-if-exists",
|
|
88
|
+
files: ["**/*.{js,mjs,mts,ts,tsx}"],
|
|
89
|
+
configs: [...nodePluginModuleConfigs],
|
|
90
|
+
}),
|
|
91
|
+
|
|
92
|
+
...apply({
|
|
93
|
+
extensions,
|
|
94
|
+
mode: "directory",
|
|
95
|
+
files: ["scripts/"],
|
|
96
|
+
configs: [scriptsOverrideConfig],
|
|
97
|
+
}),
|
|
137
98
|
|
|
138
99
|
...apply({
|
|
139
|
-
|
|
100
|
+
mode: "keep-files-if-exists",
|
|
101
|
+
files: ["**/*.{cjs,cts}"],
|
|
140
102
|
configs: [...nodePluginCommonjsConfigs],
|
|
141
103
|
}),
|
|
142
104
|
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import json from "@eslint/json";
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
{
|
|
5
|
+
name: "@pob/eslint-config/base/languages/json/plugins",
|
|
6
|
+
plugins: { json },
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
// lint JSON files
|
|
10
|
+
{
|
|
11
|
+
name: "@pob/eslint-config/base/languages/json/json",
|
|
12
|
+
files: ["**/*.json"],
|
|
13
|
+
language: "json/json",
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
...json.configs.recommended,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// lint JSONC files
|
|
19
|
+
{
|
|
20
|
+
name: "@pob/eslint-config/base/languages/json/jsonc",
|
|
21
|
+
files: ["**/*.jsonc", "**/tsconfig.json", ".vscode/*.json"],
|
|
22
|
+
language: "json/jsonc",
|
|
23
|
+
languageOptions: {
|
|
24
|
+
allowTrailingCommas: true,
|
|
25
|
+
},
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
...json.configs.recommended,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
// lint JSON5 files
|
|
31
|
+
{
|
|
32
|
+
name: "@pob/eslint-config/base/languages/json/json5",
|
|
33
|
+
files: ["**/*.json5"],
|
|
34
|
+
language: "json/json5",
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
...json.configs.recommended,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
@@ -116,7 +116,7 @@ export default [
|
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
name: "@pob/eslint-config/import/rollup-config",
|
|
119
|
-
files: ["rollup.config.
|
|
119
|
+
files: ["rollup.config.js", "rollup.config.mjs"],
|
|
120
120
|
rules: {
|
|
121
121
|
"import/no-relative-packages": "off",
|
|
122
122
|
"import/order": "off",
|
package/lib/plugins/regexp.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import eslintPluginRegexp from "eslint-plugin-regexp";
|
|
2
2
|
|
|
3
3
|
export default [
|
|
4
|
-
eslintPluginRegexp.configs["flat/recommended"],
|
|
5
4
|
{
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
...eslintPluginRegexp.configs["flat/recommended"],
|
|
6
|
+
name: "eslint-plugin-regexp/flat/recommended",
|
|
8
7
|
},
|
|
8
|
+
// {
|
|
9
|
+
// name: "@pob/eslint-config/regexp",
|
|
10
|
+
// rules: {},
|
|
11
|
+
// },
|
|
9
12
|
];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
|
|
3
|
+
export const apply = ({
|
|
4
|
+
filesOverridesIf = [],
|
|
5
|
+
extensions = "{js,cjs,mjs}",
|
|
6
|
+
files = [`**/*.${extensions}`],
|
|
7
|
+
configs,
|
|
8
|
+
mode = "throw-if-files-exists",
|
|
9
|
+
}) => {
|
|
10
|
+
return configs.map((config) => {
|
|
11
|
+
switch (mode) {
|
|
12
|
+
case "keep-files-if-exists": {
|
|
13
|
+
return {
|
|
14
|
+
...config,
|
|
15
|
+
files: config.files || files,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
case "throw-if-files-exists": {
|
|
19
|
+
if (config.files) {
|
|
20
|
+
if (
|
|
21
|
+
!filesOverridesIf.some((filesOverrides) =>
|
|
22
|
+
isDeepStrictEqual(filesOverrides, config.files),
|
|
23
|
+
)
|
|
24
|
+
) {
|
|
25
|
+
console.log({ filesOverridesIf });
|
|
26
|
+
throw new Error(
|
|
27
|
+
`"files" already exists: ${JSON.stringify(config.files)} for ${config.name ? `"${config.name}"` : "unknown"}`,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...config,
|
|
34
|
+
files,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
case "keep-extension": {
|
|
38
|
+
if (!Array.isArray(files)) {
|
|
39
|
+
throw new TypeError(`apply: "files" should be an array: ${files}`);
|
|
40
|
+
}
|
|
41
|
+
if (files.length !== 1) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`apply: "files" should have only one element: ${files}`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (!files[0].startsWith("**/")) {
|
|
47
|
+
throw new Error(`apply: "files" should start with "**/": ${files}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
...config,
|
|
52
|
+
files: config.files.map((filesGlob) => {
|
|
53
|
+
if (!filesGlob.startsWith("**/")) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`"files" should start with "**/": ${config.files} for ${config.name ? `"${config.name}"` : JSON.stringify(config)}`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return files[0] + filesGlob.slice(3);
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
case "add-extensions": {
|
|
63
|
+
return {
|
|
64
|
+
...config,
|
|
65
|
+
files: config.files
|
|
66
|
+
? config.files.map((filesGlob) => {
|
|
67
|
+
if (filesGlob.endsWith("/**")) {
|
|
68
|
+
return `${filesGlob}/*.${extensions}`;
|
|
69
|
+
}
|
|
70
|
+
throw new Error(
|
|
71
|
+
`apply: "files" should end with "/**": ${filesGlob} for ${config.name ? `"${config.name}"` : JSON.stringify(config)}`,
|
|
72
|
+
);
|
|
73
|
+
})
|
|
74
|
+
: files,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
case "directory": {
|
|
78
|
+
if (files.length !== 1) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`apply: "files" should have only one element: ${files}`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
...config,
|
|
85
|
+
files: config.files
|
|
86
|
+
? config.files.map((fileGlob) => files[0] + fileGlob)
|
|
87
|
+
: [`${files[0]}**/*.${extensions}`],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
default:
|
|
92
|
+
throw new Error('apply: "mode" is invalid');
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/eslint-config",
|
|
3
|
-
"version": "59.
|
|
3
|
+
"version": "59.4.0",
|
|
4
4
|
"description": "eslint config files",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Christophe Hurpeau <christophe@hurpeau.com> (http://christophe.hurpeau.com/)",
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
"eslint": "^9.9.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@eslint/js": "^9.
|
|
47
|
-
"@
|
|
46
|
+
"@eslint/js": "^9.16.0",
|
|
47
|
+
"@eslint/json": "^0.9.0",
|
|
48
|
+
"@pob/eslint-plugin": "59.4.0",
|
|
48
49
|
"confusing-browser-globals": "^1.0.11",
|
|
49
50
|
"eslint-plugin-import": "^2.31.0",
|
|
50
51
|
"eslint-plugin-n": "^17.15.1",
|
|
@@ -52,11 +53,11 @@
|
|
|
52
53
|
"eslint-plugin-unicorn": "^56.0.1"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"eslint": "9.
|
|
56
|
+
"eslint": "9.18.0",
|
|
56
57
|
"eslint-plugin-import": "2.31.0",
|
|
57
58
|
"eslint-plugin-n": "17.15.1",
|
|
58
59
|
"eslint-plugin-regexp": "2.7.0",
|
|
59
60
|
"eslint-plugin-unicorn": "56.0.1",
|
|
60
|
-
"typescript": "5.7.
|
|
61
|
+
"typescript": "5.7.3"
|
|
61
62
|
}
|
|
62
63
|
}
|