eslint-plugin-package-json 0.51.0 → 0.52.1
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 +14 -2
- package/README.md +2 -1
- package/lib/rules/no-empty-fields.js +2 -0
- package/lib/rules/order-properties.js +3 -1
- package/lib/rules/repository-shorthand.js +2 -0
- package/lib/rules/restrict-dependency-ranges.js +6 -0
- package/lib/rules/sort-collections.js +23 -31
- package/lib/rules/valid-bin.js +2 -1
- package/lib/rules/valid-package-definition.js +2 -0
- package/lib/rules/valid-properties.js +2 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## [0.52.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.52.0...v0.52.1) (2025-08-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **sort-collections:** align sorting of scripts with `prettier-plugin-packagejson` ([#1203](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1203)) ([1f5c590](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/1f5c590adc846194766127ab962f8efa72942d06)), closes [#753](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/753)
|
|
4
9
|
|
|
10
|
+
# [0.52.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.51.0...v0.52.0) (2025-08-07)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **valid-description:** add new rule for validating `description` ([#1204](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1204)) ([4acb265](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/4acb26563c0cacb5834c8b53dae68fb291c0ffd1)), closes [#823](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/823)
|
|
15
|
+
|
|
16
|
+
# [0.51.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.50.0...v0.51.0) (2025-08-05)
|
|
5
17
|
|
|
6
18
|
### Features
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- add `ignorePrivate` option to all `require-*` rules ([#1158](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1158)) ([055009b](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/055009bf864c9f8db153bf0c5bb9568d023abe12)), closes [#1092](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1092)
|
|
9
21
|
|
|
10
22
|
# [0.50.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.49.0...v0.50.0) (2025-08-05)
|
|
11
23
|
|
package/README.md
CHANGED
|
@@ -183,6 +183,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
183
183
|
| [valid-config](docs/rules/valid-config.md) | Enforce that the `config` property is valid. | ✔️ ✅ | | | |
|
|
184
184
|
| [valid-cpu](docs/rules/valid-cpu.md) | Enforce that the `cpu` property is valid. | ✔️ ✅ | | | |
|
|
185
185
|
| [valid-dependencies](docs/rules/valid-dependencies.md) | Enforce that the `dependencies` property is valid. | ✔️ ✅ | | | |
|
|
186
|
+
| [valid-description](docs/rules/valid-description.md) | Enforce that the `description` property is valid. | ✔️ ✅ | | | |
|
|
186
187
|
| [valid-devDependencies](docs/rules/valid-devDependencies.md) | Enforce that the `devDependencies` property is valid. | ✔️ ✅ | | | |
|
|
187
188
|
| [valid-license](docs/rules/valid-license.md) | Enforce that the `license` property is valid. | ✔️ ✅ | | | |
|
|
188
189
|
| [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json | | | | ❌ |
|
|
@@ -246,7 +247,7 @@ Thanks! 🗂
|
|
|
246
247
|
<td align="center" valign="top" width="14.28%"><a href="https://davidlj95.com"><img src="https://avatars.githubusercontent.com/u/8050648?v=4?s=100" width="100px;" alt="David LJ"/><br /><sub><b>David LJ</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=davidlj95" title="Documentation">📖</a></td>
|
|
247
248
|
<td align="center" valign="top" width="14.28%"><a href="http://lishaduck.github.io"><img src="https://avatars.githubusercontent.com/u/88557639?v=4?s=100" width="100px;" alt="Eli"/><br /><sub><b>Eli</b></sub></a><br /><a href="#ideas-lishaduck" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Alishaduck" title="Bug reports">🐛</a></td>
|
|
248
249
|
<td align="center" valign="top" width="14.28%"><a href="http://heggria.site"><img src="https://avatars.githubusercontent.com/u/34475327?v=4?s=100" width="100px;" alt="Heggria"/><br /><sub><b>Heggria</b></sub></a><br /><a href="#ideas-heggria" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
249
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Zamiell"><img src="https://avatars.githubusercontent.com/u/5511220?v=4?s=100" width="100px;" alt="James"/><br /><sub><b>James</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=Zamiell" title="Code">💻</a></td>
|
|
250
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Zamiell"><img src="https://avatars.githubusercontent.com/u/5511220?v=4?s=100" width="100px;" alt="James"/><br /><sub><b>James</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=Zamiell" title="Code">💻</a> <a href="#ideas-Zamiell" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
250
251
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zetlen"><img src="https://avatars.githubusercontent.com/u/1643758?v=4?s=100" width="100px;" alt="James Zetlen"/><br /><sub><b>James Zetlen</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=zetlen" title="Code">💻</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Azetlen" title="Bug reports">🐛</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=zetlen" title="Documentation">📖</a> <a href="#infra-zetlen" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-zetlen" title="Maintenance">🚧</a> <a href="#tool-zetlen" title="Tools">🔧</a></td>
|
|
251
252
|
<td align="center" valign="top" width="14.28%"><a href="https://piranna.github.io/"><img src="https://avatars.githubusercontent.com/u/532414?v=4?s=100" width="100px;" alt="Jesús Leganés-Combarro"/><br /><sub><b>Jesús Leganés-Combarro</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=piranna" title="Code">💻</a></td>
|
|
252
253
|
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com/"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg ✨"/><br /><sub><b>Josh Goldberg ✨</b></sub></a><br /><a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">🐛</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=JoshuaKGoldberg" title="Code">💻</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=JoshuaKGoldberg" title="Documentation">📖</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">🚧</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">🤔</a> <a href="#content-JoshuaKGoldberg" title="Content">🖋</a> <a href="#projectManagement-JoshuaKGoldberg" title="Project Management">📆</a></td>
|
|
@@ -90,6 +90,7 @@ const rule = createRule({
|
|
|
90
90
|
};
|
|
91
91
|
},
|
|
92
92
|
meta: {
|
|
93
|
+
defaultOptions: [{ ignoreProperties: [] }],
|
|
93
94
|
docs: {
|
|
94
95
|
category: "Best Practices",
|
|
95
96
|
description: "Reports on unnecessary empty arrays and objects.",
|
|
@@ -106,6 +107,7 @@ const rule = createRule({
|
|
|
106
107
|
additionalProperties: false,
|
|
107
108
|
properties: {
|
|
108
109
|
ignoreProperties: {
|
|
110
|
+
description: "Array of top-level properties to ignore.",
|
|
109
111
|
items: {
|
|
110
112
|
type: "string"
|
|
111
113
|
},
|
|
@@ -85,6 +85,7 @@ const rule = createRule({
|
|
|
85
85
|
};
|
|
86
86
|
},
|
|
87
87
|
meta: {
|
|
88
|
+
defaultOptions: [{ order: "sort-package-json" }],
|
|
88
89
|
docs: {
|
|
89
90
|
category: "Best Practices",
|
|
90
91
|
description: "Package properties must be declared in standard order",
|
|
@@ -110,7 +111,8 @@ const rule = createRule({
|
|
|
110
111
|
},
|
|
111
112
|
type: ["array"]
|
|
112
113
|
}
|
|
113
|
-
]
|
|
114
|
+
],
|
|
115
|
+
description: "Specifies the sorting order of top-level properties."
|
|
114
116
|
}
|
|
115
117
|
},
|
|
116
118
|
type: "object"
|
|
@@ -89,6 +89,7 @@ const rule = createRule({
|
|
|
89
89
|
};
|
|
90
90
|
},
|
|
91
91
|
meta: {
|
|
92
|
+
defaultOptions: [{ form: "object" }],
|
|
92
93
|
docs: {
|
|
93
94
|
category: "Best Practices",
|
|
94
95
|
description: "Enforce either object or shorthand declaration for repository.",
|
|
@@ -104,6 +105,7 @@ const rule = createRule({
|
|
|
104
105
|
additionalProperties: false,
|
|
105
106
|
properties: {
|
|
106
107
|
form: {
|
|
108
|
+
description: "Specifies which repository form to enforce.",
|
|
107
109
|
enum: ["object", "shorthand"],
|
|
108
110
|
type: ["string"]
|
|
109
111
|
}
|
|
@@ -12,21 +12,25 @@ const schemaOptions = {
|
|
|
12
12
|
additionalProperties: false,
|
|
13
13
|
properties: {
|
|
14
14
|
forDependencyTypes: {
|
|
15
|
+
description: "Apply a range type restriction for an entire group of dependencies by which type of dependencies they belong to.",
|
|
15
16
|
items: {
|
|
16
17
|
enum: DEPENDENCY_TYPES
|
|
17
18
|
},
|
|
18
19
|
type: "array"
|
|
19
20
|
},
|
|
20
21
|
forPackages: {
|
|
22
|
+
description: "The exact name of a package, or a regex pattern used to match a group of packages by name.",
|
|
21
23
|
items: {
|
|
22
24
|
type: "string"
|
|
23
25
|
},
|
|
24
26
|
type: "array"
|
|
25
27
|
},
|
|
26
28
|
forVersions: {
|
|
29
|
+
description: "Apply a restriction to a specific semver range.",
|
|
27
30
|
type: "string"
|
|
28
31
|
},
|
|
29
32
|
rangeType: {
|
|
33
|
+
description: "Identifies which range type or types you want to apply to packages that match any of the other match options (or all dependencies if no other options are provided).",
|
|
30
34
|
oneOf: [
|
|
31
35
|
{
|
|
32
36
|
enum: RANGE_TYPES
|
|
@@ -176,6 +180,7 @@ const rule = createRule({
|
|
|
176
180
|
};
|
|
177
181
|
},
|
|
178
182
|
meta: {
|
|
183
|
+
defaultOptions: [[]],
|
|
179
184
|
docs: {
|
|
180
185
|
description: "Restricts the range of dependencies to allow or disallow specific types of ranges."
|
|
181
186
|
},
|
|
@@ -191,6 +196,7 @@ const rule = createRule({
|
|
|
191
196
|
oneOf: [
|
|
192
197
|
schemaOptions,
|
|
193
198
|
{
|
|
199
|
+
description: "Array of configuration options, specifying range requirements.",
|
|
194
200
|
items: schemaOptions,
|
|
195
201
|
type: "array"
|
|
196
202
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import sortPackageJson from "sort-package-json";
|
|
1
2
|
import { createRule } from "../createRule.js";
|
|
2
3
|
const defaultCollections = /* @__PURE__ */ new Set([
|
|
3
4
|
"config",
|
|
@@ -37,38 +38,27 @@ const rule = createRule({
|
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
const currentOrder = collection.properties;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const desiredOrder = currentOrder.slice().sort((a, b) => {
|
|
46
|
-
let aKey = a.key.value;
|
|
47
|
-
let bKey = b.key.value;
|
|
48
|
-
if (keyPartsReversed.at(-1) !== "scripts") {
|
|
41
|
+
let desiredOrder;
|
|
42
|
+
if (keyPartsReversed.at(-1) !== "scripts") {
|
|
43
|
+
desiredOrder = currentOrder.slice().sort((a, b) => {
|
|
44
|
+
const aKey = a.key.value;
|
|
45
|
+
const bKey = b.key.value;
|
|
49
46
|
return aKey > bKey ? 1 : -1;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
if (aKey === bKey) {
|
|
67
|
-
return modifier;
|
|
68
|
-
}
|
|
69
|
-
return aKey > bKey ? 1 : -1;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
const scriptsSource = context.sourceCode.getText(node);
|
|
50
|
+
const minimalJson = JSON.parse(`{${scriptsSource}}`);
|
|
51
|
+
const { scripts: sortedScripts } = sortPackageJson(minimalJson);
|
|
52
|
+
const propertyNodeMap = Object.fromEntries(
|
|
53
|
+
collection.properties.map((prop) => [
|
|
54
|
+
prop.key.value,
|
|
55
|
+
prop
|
|
56
|
+
])
|
|
57
|
+
);
|
|
58
|
+
desiredOrder = Object.keys(sortedScripts).map(
|
|
59
|
+
(prop) => propertyNodeMap[prop]
|
|
60
|
+
);
|
|
61
|
+
}
|
|
72
62
|
if (currentOrder.some(
|
|
73
63
|
(property, i) => desiredOrder[i] !== property
|
|
74
64
|
)) {
|
|
@@ -103,6 +93,7 @@ const rule = createRule({
|
|
|
103
93
|
};
|
|
104
94
|
},
|
|
105
95
|
meta: {
|
|
96
|
+
defaultOptions: [Array.from(defaultCollections)],
|
|
106
97
|
docs: {
|
|
107
98
|
category: "Best Practices",
|
|
108
99
|
description: "Dependencies, scripts, and configuration values must be declared in alphabetical order.",
|
|
@@ -114,6 +105,7 @@ const rule = createRule({
|
|
|
114
105
|
},
|
|
115
106
|
schema: [
|
|
116
107
|
{
|
|
108
|
+
description: "Array of package properties to require sorting.",
|
|
117
109
|
items: {
|
|
118
110
|
type: "string"
|
|
119
111
|
},
|
package/lib/rules/valid-bin.js
CHANGED
|
@@ -51,6 +51,7 @@ const rule = createRule({
|
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
53
|
meta: {
|
|
54
|
+
defaultOptions: [{ enforceCase: false }],
|
|
54
55
|
docs: {
|
|
55
56
|
category: "Best Practices",
|
|
56
57
|
description: "Enforce that the `bin` property is valid.",
|
|
@@ -67,7 +68,7 @@ const rule = createRule({
|
|
|
67
68
|
additionalProperties: false,
|
|
68
69
|
properties: {
|
|
69
70
|
enforceCase: {
|
|
70
|
-
|
|
71
|
+
description: "Enforce that the bin's keys should be in kebab case.",
|
|
71
72
|
type: "boolean"
|
|
72
73
|
}
|
|
73
74
|
},
|
|
@@ -29,6 +29,7 @@ const rule = createRule({
|
|
|
29
29
|
},
|
|
30
30
|
// eslint-disable-next-line eslint-plugin/prefer-message-ids
|
|
31
31
|
meta: {
|
|
32
|
+
defaultOptions: [{ ignoreProperties: [] }],
|
|
32
33
|
docs: {
|
|
33
34
|
category: "Best Practices",
|
|
34
35
|
description: "Enforce that package.json has all properties required by the npm spec",
|
|
@@ -39,6 +40,7 @@ const rule = createRule({
|
|
|
39
40
|
additionalProperties: false,
|
|
40
41
|
properties: {
|
|
41
42
|
ignoreProperties: {
|
|
43
|
+
description: "Array of top-level package properties to ignore.",
|
|
42
44
|
items: {
|
|
43
45
|
type: "string"
|
|
44
46
|
},
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
validateConfig,
|
|
5
5
|
validateCpu,
|
|
6
6
|
validateDependencies,
|
|
7
|
+
validateDescription,
|
|
7
8
|
validateLicense,
|
|
8
9
|
validateScripts,
|
|
9
10
|
validateType
|
|
@@ -23,6 +24,7 @@ const properties = [
|
|
|
23
24
|
["config", validateConfig],
|
|
24
25
|
["cpu", validateCpu],
|
|
25
26
|
["dependencies", validateDependencies],
|
|
27
|
+
["description", validateDescription],
|
|
26
28
|
["devDependencies", validateDependencies],
|
|
27
29
|
["license", validateLicense],
|
|
28
30
|
["optionalDependencies", validateDependencies],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.1",
|
|
4
4
|
"description": "Rules for consistent, readable, and valid package.json files. 🗂️",
|
|
5
5
|
"homepage": "https://github.com/JoshuaKGoldberg/eslint-plugin-package-json#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"*": "prettier --ignore-unknown --write"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@altano/repository-tools": "^2.0.
|
|
47
|
+
"@altano/repository-tools": "^2.0.1",
|
|
48
48
|
"change-case": "^5.4.4",
|
|
49
49
|
"detect-indent": "^7.0.1",
|
|
50
50
|
"detect-newline": "^4.0.1",
|
|
51
51
|
"eslint-fix-utils": "~0.4.0",
|
|
52
|
-
"package-json-validator": "~0.
|
|
52
|
+
"package-json-validator": "~0.27.0",
|
|
53
53
|
"semver": "^7.5.4",
|
|
54
54
|
"sort-object-keys": "^1.1.3",
|
|
55
|
-
"sort-package-json": "^3.
|
|
56
|
-
"validate-npm-package-name": "^6.0.
|
|
55
|
+
"sort-package-json": "^3.3.0",
|
|
56
|
+
"validate-npm-package-name": "^6.0.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"create-typescript-app": "2.46.1",
|
|
72
72
|
"eslint": "9.32.0",
|
|
73
73
|
"eslint-doc-generator": "2.2.0",
|
|
74
|
-
"eslint-plugin-eslint-plugin": "
|
|
74
|
+
"eslint-plugin-eslint-plugin": "7.0.0",
|
|
75
75
|
"eslint-plugin-jsdoc": "52.0.0",
|
|
76
76
|
"eslint-plugin-jsonc": "2.20.0",
|
|
77
77
|
"eslint-plugin-markdown": "5.1.0",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"release-it": "19.0.1",
|
|
94
94
|
"sentences-per-line": "0.3.0",
|
|
95
95
|
"tsup": "8.5.0",
|
|
96
|
-
"typescript": "5.
|
|
96
|
+
"typescript": "5.9.2",
|
|
97
97
|
"typescript-eslint": "8.38.0",
|
|
98
98
|
"vitest": "3.2.0"
|
|
99
99
|
},
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"eslint": ">=8.0.0",
|
|
102
102
|
"jsonc-eslint-parser": "^2.0.0"
|
|
103
103
|
},
|
|
104
|
-
"packageManager": "pnpm@10.
|
|
104
|
+
"packageManager": "pnpm@10.14.0",
|
|
105
105
|
"engines": {
|
|
106
106
|
"node": "^=20.19.0 || >=22.12.0"
|
|
107
107
|
},
|