eslint-plugin-package-json 1.1.0 → 1.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/README.md +100 -79
- package/lib/experimental/index.d.mts +34 -0
- package/lib/experimental/index.mjs +7 -0
- package/lib/experimental/plugin.d.mts +40 -0
- package/lib/experimental/plugin.mjs +32 -0
- package/lib/plugin.mjs +30 -28
- package/lib/rules/no-local-dependencies.d.mts +17 -0
- package/lib/rules/no-local-dependencies.mjs +47 -0
- package/lib/rules/valid-repository-directory.mjs +15 -11
- package/package.json +20 -10
- package/CHANGELOG.md +0 -1443
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRule } from "../createRule.mjs";
|
|
2
2
|
import { findPropertyWithKeyValue } from "../utils/findPropertyWithKeyValue.mjs";
|
|
3
|
-
import { findRootSync } from "@altano/repository-tools";
|
|
4
3
|
import path from "node:path";
|
|
5
4
|
import { sep } from "node:path/posix";
|
|
5
|
+
import { findRootSync } from "@altano/repository-tools";
|
|
6
6
|
//#region src/rules/valid-repository-directory.ts
|
|
7
7
|
/**
|
|
8
8
|
* Checks if the child path appears at the end of the parent path.
|
|
@@ -11,7 +11,7 @@ import { sep } from "node:path/posix";
|
|
|
11
11
|
* @example '/a/b/c', 'b' => false
|
|
12
12
|
* @example '/a/b/c', 'd' => false
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
const pathEndsWith = (parent, child) => {
|
|
15
15
|
const segments = parent.split(path.sep);
|
|
16
16
|
if (parent === child) return true;
|
|
17
17
|
let pathToCheck = "";
|
|
@@ -19,7 +19,8 @@ function pathEndsWith(parent, child) {
|
|
|
19
19
|
pathToCheck = path.join(segment, pathToCheck);
|
|
20
20
|
if (pathToCheck === child) return true;
|
|
21
21
|
});
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
|
+
let repoRootCache = null;
|
|
23
24
|
const rule = createRule({
|
|
24
25
|
create(context) {
|
|
25
26
|
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=repository][value.type=JSONObjectExpression]"(node) {
|
|
@@ -27,13 +28,13 @@ const rule = createRule({
|
|
|
27
28
|
if (directoryProperty?.value.type !== "JSONLiteral" || typeof directoryProperty.value.value !== "string") return;
|
|
28
29
|
const directoryValue = directoryProperty.value.value;
|
|
29
30
|
const fileDirectory = path.normalize(path.dirname(context.filename));
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
let repositoryRoot;
|
|
32
|
+
if (repoRootCache && fileDirectory.startsWith(repoRootCache)) repositoryRoot = repoRootCache;
|
|
33
|
+
else {
|
|
34
|
+
repositoryRoot = findRootSync(fileDirectory);
|
|
35
|
+
if (repositoryRoot) repoRootCache = path.normalize(repositoryRoot);
|
|
36
|
+
}
|
|
37
|
+
if (repositoryRoot) {
|
|
37
38
|
const expected = path.relative(repositoryRoot, fileDirectory).replaceAll(path.sep, sep);
|
|
38
39
|
if (expected !== directoryValue) context.report({
|
|
39
40
|
messageId: "mismatched",
|
|
@@ -46,7 +47,10 @@ const rule = createRule({
|
|
|
46
47
|
messageId: "replace"
|
|
47
48
|
}]
|
|
48
49
|
});
|
|
49
|
-
}
|
|
50
|
+
} else if (!pathEndsWith(fileDirectory, path.normalize(directoryValue))) context.report({
|
|
51
|
+
messageId: "mismatched",
|
|
52
|
+
node: directoryProperty.value
|
|
53
|
+
});
|
|
50
54
|
} };
|
|
51
55
|
},
|
|
52
56
|
meta: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Rules for consistent, readable, and valid package.json files. 🗂️",
|
|
5
5
|
"homepage": "https://github.com/michaelfaith/eslint-plugin-package-json#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"name": "michael faith",
|
|
26
|
-
"email": "michaelfaith@users.noreply.github.com",
|
|
27
26
|
"url": "https://michael.faith"
|
|
28
27
|
}
|
|
29
28
|
],
|
|
@@ -33,11 +32,14 @@
|
|
|
33
32
|
".": {
|
|
34
33
|
"types": "./lib/index.d.mts",
|
|
35
34
|
"default": "./lib/index.mjs"
|
|
35
|
+
},
|
|
36
|
+
"./experimental": {
|
|
37
|
+
"types": "./lib/experimental/index.d.mts",
|
|
38
|
+
"default": "./lib/experimental/index.mjs"
|
|
36
39
|
}
|
|
37
40
|
},
|
|
38
41
|
"main": "lib/index.mjs",
|
|
39
42
|
"files": [
|
|
40
|
-
"CHANGELOG.md",
|
|
41
43
|
"lib/"
|
|
42
44
|
],
|
|
43
45
|
"dependencies": {
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
"detect-indent": "^7.0.2",
|
|
47
49
|
"detect-newline": "^4.0.1",
|
|
48
50
|
"eslint-fix-utils": "~0.4.1",
|
|
51
|
+
"eslint-json-compat-utils": "^0.2.3",
|
|
49
52
|
"jsonc-eslint-parser": "^3.1.0",
|
|
50
53
|
"package-json-validator": "^1.5.0",
|
|
51
54
|
"semver": "^7.7.3",
|
|
@@ -57,34 +60,35 @@
|
|
|
57
60
|
"@catppuccin/starlight": "2.0.1",
|
|
58
61
|
"@eslint-community/eslint-plugin-eslint-comments": "4.7.0",
|
|
59
62
|
"@eslint/js": "10.0.1",
|
|
63
|
+
"@eslint/json": "2.0.0",
|
|
60
64
|
"@eslint/markdown": "8.0.1",
|
|
65
|
+
"@ianvs/prettier-plugin-sort-imports": "4.7.1",
|
|
61
66
|
"@types/estree": "1.0.8",
|
|
62
67
|
"@types/node": "24.12.0",
|
|
63
68
|
"@types/semver": "7.7.1",
|
|
64
69
|
"@vitest/coverage-v8": "4.1.0",
|
|
65
70
|
"@vitest/eslint-plugin": "1.6.1",
|
|
66
|
-
"astro": "6.
|
|
71
|
+
"astro": "6.4.2",
|
|
67
72
|
"astro-og-canvas": "0.11.1",
|
|
68
73
|
"canvaskit-wasm": "0.41.1",
|
|
69
74
|
"console-fail-test": "0.6.0",
|
|
70
75
|
"eslint": "10.4.0",
|
|
71
|
-
"eslint-doc-generator": "3.
|
|
76
|
+
"eslint-doc-generator": "3.6.0",
|
|
72
77
|
"eslint-plugin-eslint-plugin": "7.3.1",
|
|
73
|
-
"eslint-plugin-jsdoc": "
|
|
74
|
-
"eslint-plugin-jsonc": "3.
|
|
78
|
+
"eslint-plugin-jsdoc": "63.0.0",
|
|
79
|
+
"eslint-plugin-jsonc": "3.2.0",
|
|
75
80
|
"eslint-plugin-n": "18.0.0",
|
|
76
81
|
"eslint-plugin-node-dependencies": "2.2.0",
|
|
77
82
|
"eslint-plugin-perfectionist": "5.9.0",
|
|
78
83
|
"eslint-plugin-regexp": "3.1.0",
|
|
79
84
|
"eslint-plugin-unicorn": "64.0.0",
|
|
80
|
-
"eslint-plugin-yml": "3.
|
|
85
|
+
"eslint-plugin-yml": "3.4.0",
|
|
81
86
|
"jiti": "2.7.0",
|
|
82
87
|
"json-schema-to-ts": "3.1.1",
|
|
83
88
|
"knip": "6.14.0",
|
|
84
89
|
"prettier": "3.8.0",
|
|
85
90
|
"prettier-plugin-curly": "0.4.0",
|
|
86
91
|
"prettier-plugin-packagejson": "3.0.0",
|
|
87
|
-
"prettier-plugin-sentences-per-line": "0.2.3",
|
|
88
92
|
"prettier-plugin-sh": "0.18.0",
|
|
89
93
|
"pretty-quick": "4.2.2",
|
|
90
94
|
"sharp": "0.34.5",
|
|
@@ -92,12 +96,18 @@
|
|
|
92
96
|
"starlight-auto-sidebar": "0.4.0",
|
|
93
97
|
"tsdown": "0.22.0",
|
|
94
98
|
"typescript": "6.0.2",
|
|
95
|
-
"typescript-eslint": "8.
|
|
99
|
+
"typescript-eslint": "8.60.0",
|
|
96
100
|
"vitest": "4.1.0"
|
|
97
101
|
},
|
|
98
102
|
"peerDependencies": {
|
|
103
|
+
"@eslint/json": ">=1.0.0",
|
|
99
104
|
"eslint": ">=9.0.0"
|
|
100
105
|
},
|
|
106
|
+
"peerDependenciesMeta": {
|
|
107
|
+
"@eslint/json": {
|
|
108
|
+
"optional": true
|
|
109
|
+
}
|
|
110
|
+
},
|
|
101
111
|
"engines": {
|
|
102
112
|
"node": "^22.22.2 || >=24.15.0"
|
|
103
113
|
},
|