eslint-plugin-package-json 0.65.2 → 0.66.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
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# [0.66.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.3...v0.66.0) (2025-11-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **valid-homepage:** add new rule for validating `homepage` ([#1376](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1376)) ([34ad9b8](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/34ad9b8dda81601e9f710dc66c61a02fe7ecfa0e)), closes [#828](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/828)
|
|
4
9
|
|
|
10
|
+
## [0.65.3](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.2...v0.65.3) (2025-11-10)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **valid-dependencies:** improve report precision ([#1363](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1363)) ([336677a](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/336677af4b94834e729b21a450992ca998d42099)), closes [#1213](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1213)
|
|
15
|
+
|
|
16
|
+
## [0.65.2](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.1...v0.65.2) (2025-11-10)
|
|
5
17
|
|
|
6
18
|
### Bug Fixes
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- **valid-exports:** improve report precision ([#1361](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1361)) ([5d7bd4a](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/5d7bd4affb93c3eb22576062c963599b6e56bdd1)), closes [#000](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/000)
|
|
9
21
|
|
|
10
22
|
## [0.65.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.0...v0.65.1) (2025-11-09)
|
|
11
23
|
|
package/README.md
CHANGED
|
@@ -221,6 +221,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
221
221
|
| [valid-devDependencies](docs/rules/valid-devDependencies.md) | Enforce that the `devDependencies` property is valid. | ✔️ ✅ | | | |
|
|
222
222
|
| [valid-directories](docs/rules/valid-directories.md) | Enforce that the `directories` property is valid. | ✔️ ✅ | | | |
|
|
223
223
|
| [valid-exports](docs/rules/valid-exports.md) | Enforce that the `exports` property is valid. | ✔️ ✅ | | | |
|
|
224
|
+
| [valid-homepage](docs/rules/valid-homepage.md) | Enforce that the `homepage` property is valid. | ✔️ ✅ | | | |
|
|
224
225
|
| [valid-license](docs/rules/valid-license.md) | Enforce that the `license` property is valid. | ✔️ ✅ | | | |
|
|
225
226
|
| [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json | | | | ❌ |
|
|
226
227
|
| [valid-name](docs/rules/valid-name.md) | Enforce that package names are valid npm package names | ✔️ ✅ | | | |
|
|
@@ -3,7 +3,7 @@ import { PackageJsonRuleModule } from "../createRule.js";
|
|
|
3
3
|
//#region src/rules/valid-properties.d.ts
|
|
4
4
|
/** All basic valid- flavor rules */
|
|
5
5
|
declare const rules: {
|
|
6
|
-
[
|
|
6
|
+
[k: string]: PackageJsonRuleModule<[], []>;
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
9
9
|
export { rules };
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { validateAuthor, validateBin, validateBundleDependencies, validateConfig, validateCpu, validateDependencies, validateDescription, validateDirectories, validateExports, validateLicense, validateScripts, validateType } from "package-json-validator";
|
|
1
|
+
import { createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.js";
|
|
2
|
+
import { validateAuthor, validateBin, validateBundleDependencies, validateConfig, validateCpu, validateDependencies, validateDescription, validateDirectories, validateExports, validateHomepage, validateLicense, validateScripts, validateType } from "package-json-validator";
|
|
3
3
|
|
|
4
4
|
//#region src/rules/valid-properties.ts
|
|
5
|
-
const legacyProperties = [
|
|
6
|
-
["dependencies", validateDependencies],
|
|
7
|
-
["devDependencies", validateDependencies],
|
|
8
|
-
["optionalDependencies", validateDependencies],
|
|
9
|
-
["peerDependencies", validateDependencies],
|
|
10
|
-
["scripts", validateScripts]
|
|
11
|
-
];
|
|
12
|
-
const legacyRules = Object.fromEntries(legacyProperties.map(([propertyName, validationFunction]) => {
|
|
13
|
-
const { rule, ruleName } = createLegacySimpleValidPropertyRule(propertyName, validationFunction);
|
|
14
|
-
return [ruleName, rule];
|
|
15
|
-
}));
|
|
16
5
|
const properties = [
|
|
17
6
|
["author", validateAuthor],
|
|
18
7
|
["bin", validateBin],
|
|
@@ -23,25 +12,28 @@ const properties = [
|
|
|
23
12
|
["config", validateConfig],
|
|
24
13
|
["cpu", validateCpu],
|
|
25
14
|
["description", validateDescription],
|
|
15
|
+
["dependencies", validateDependencies],
|
|
16
|
+
["devDependencies", validateDependencies],
|
|
26
17
|
["directories", validateDirectories],
|
|
27
18
|
["exports", validateExports],
|
|
19
|
+
["homepage", validateHomepage],
|
|
28
20
|
["license", validateLicense],
|
|
21
|
+
["optionalDependencies", validateDependencies],
|
|
22
|
+
["peerDependencies", validateDependencies],
|
|
23
|
+
["scripts", validateScripts],
|
|
29
24
|
["type", validateType]
|
|
30
25
|
];
|
|
31
26
|
/** All basic valid- flavor rules */
|
|
32
|
-
const rules = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return [ruleName, rule];
|
|
43
|
-
}))
|
|
44
|
-
};
|
|
27
|
+
const rules = Object.fromEntries(properties.map(([propertyName, validationFunctionOrOptions]) => {
|
|
28
|
+
let validationFunction;
|
|
29
|
+
let aliases = [];
|
|
30
|
+
if (typeof validationFunctionOrOptions === "object") {
|
|
31
|
+
validationFunction = validationFunctionOrOptions.validator;
|
|
32
|
+
aliases = validationFunctionOrOptions.aliases;
|
|
33
|
+
} else validationFunction = validationFunctionOrOptions;
|
|
34
|
+
const { rule, ruleName } = createSimpleValidPropertyRule(propertyName, validationFunction, aliases);
|
|
35
|
+
return [ruleName, rule];
|
|
36
|
+
}));
|
|
45
37
|
|
|
46
38
|
//#endregion
|
|
47
39
|
export { rules };
|
|
@@ -2,7 +2,6 @@ import { PackageJsonRuleModule } from "../createRule.js";
|
|
|
2
2
|
import { Result } from "package-json-validator";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/createSimpleValidPropertyRule.d.ts
|
|
5
|
-
type LegacyValidationFunction = (value: unknown) => string[];
|
|
6
5
|
type ValidationFunction = (value: unknown) => Result;
|
|
7
6
|
/**
|
|
8
7
|
* Given a top-level property name, and a validation function, create a rule that validates the property using the validation function.
|
|
@@ -14,15 +13,5 @@ declare const createSimpleValidPropertyRule: (propertyName: string, validationFu
|
|
|
14
13
|
rule: PackageJsonRuleModule<[], []>;
|
|
15
14
|
ruleName: string;
|
|
16
15
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Given a top-level property name, and a validation function, create a rule that validates the property using the validation function.
|
|
19
|
-
* These rules will always be included in the recommended config.
|
|
20
|
-
* Note: this will only create a basic validation rule, with no options. If you need
|
|
21
|
-
* to create a more complex rule, create it in its own file.
|
|
22
|
-
*/
|
|
23
|
-
declare const createLegacySimpleValidPropertyRule: (propertyName: string, validationFunction: LegacyValidationFunction, aliases?: string[]) => {
|
|
24
|
-
rule: PackageJsonRuleModule<[], []>;
|
|
25
|
-
ruleName: string;
|
|
26
|
-
};
|
|
27
16
|
//#endregion
|
|
28
|
-
export {
|
|
17
|
+
export { ValidationFunction, createSimpleValidPropertyRule };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRule } from "../createRule.js";
|
|
2
|
-
import { formatErrors } from "./formatErrors.js";
|
|
3
2
|
|
|
4
3
|
//#region src/utils/createSimpleValidPropertyRule.ts
|
|
5
4
|
/**
|
|
@@ -54,46 +53,6 @@ const createSimpleValidPropertyRule = (propertyName, validationFunction, aliases
|
|
|
54
53
|
ruleName
|
|
55
54
|
};
|
|
56
55
|
};
|
|
57
|
-
/**
|
|
58
|
-
* Given a top-level property name, and a validation function, create a rule that validates the property using the validation function.
|
|
59
|
-
* These rules will always be included in the recommended config.
|
|
60
|
-
* Note: this will only create a basic validation rule, with no options. If you need
|
|
61
|
-
* to create a more complex rule, create it in its own file.
|
|
62
|
-
*/
|
|
63
|
-
const createLegacySimpleValidPropertyRule = (propertyName, validationFunction, aliases = []) => {
|
|
64
|
-
const ruleName = `valid-${propertyName}`;
|
|
65
|
-
const propertyNames = [propertyName, ...aliases];
|
|
66
|
-
return {
|
|
67
|
-
rule: createRule({
|
|
68
|
-
create(context) {
|
|
69
|
-
return propertyNames.reduce((acc, name) => {
|
|
70
|
-
acc[`Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=${name}]`] = (node) => {
|
|
71
|
-
const valueNode = node.value;
|
|
72
|
-
const errors = validationFunction(JSON.parse(context.sourceCode.getText(valueNode)));
|
|
73
|
-
if (errors.length) context.report({
|
|
74
|
-
data: { errors: formatErrors(errors) },
|
|
75
|
-
messageId: "validationError",
|
|
76
|
-
node: valueNode
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
},
|
|
82
|
-
meta: {
|
|
83
|
-
docs: {
|
|
84
|
-
category: "Best Practices",
|
|
85
|
-
description: `Enforce that the \`${propertyName}\`${aliases.length ? ` (also: ${aliases.map((alias) => `\`${alias}\``).join(", ")})` : ""} property is valid.`,
|
|
86
|
-
recommended: true
|
|
87
|
-
},
|
|
88
|
-
messages: { validationError: `Invalid ${propertyName}: {{ errors }}` },
|
|
89
|
-
schema: [],
|
|
90
|
-
type: "problem"
|
|
91
|
-
},
|
|
92
|
-
name: ruleName
|
|
93
|
-
}),
|
|
94
|
-
ruleName
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
56
|
|
|
98
57
|
//#endregion
|
|
99
|
-
export {
|
|
58
|
+
export { createSimpleValidPropertyRule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
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": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"detect-indent": "^7.0.2",
|
|
49
49
|
"detect-newline": "^4.0.1",
|
|
50
50
|
"eslint-fix-utils": "~0.4.0",
|
|
51
|
-
"package-json-validator": "~0.
|
|
51
|
+
"package-json-validator": "~0.57.0",
|
|
52
52
|
"semver": "^7.7.3",
|
|
53
53
|
"sort-object-keys": "^2.0.0",
|
|
54
54
|
"sort-package-json": "^3.4.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
|
|
59
|
-
"@eslint/js": "9.
|
|
59
|
+
"@eslint/js": "9.39.1",
|
|
60
60
|
"@release-it/conventional-changelog": "10.0.0",
|
|
61
61
|
"@types/estree": "1.0.7",
|
|
62
62
|
"@types/node": "24.10.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@vitest/coverage-v8": "4.0.4",
|
|
66
66
|
"@vitest/eslint-plugin": "1.4.0",
|
|
67
67
|
"console-fail-test": "0.5.0",
|
|
68
|
-
"eslint": "9.
|
|
68
|
+
"eslint": "9.39.1",
|
|
69
69
|
"eslint-doc-generator": "2.3.0",
|
|
70
70
|
"eslint-plugin-eslint-plugin": "7.2.0",
|
|
71
71
|
"eslint-plugin-jsdoc": "61.1.0",
|