eslint-plugin-package-json 0.59.1 → 0.60.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 +8 -2
- package/lib/plugin.js +15 -13
- package/lib/rules/valid-author.d.ts +6 -0
- package/lib/rules/valid-author.js +39 -0
- package/lib/rules/valid-bin.js +1 -1
- package/lib/rules/valid-properties.js +1 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# [0.60.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.59.1...v0.60.0) (2025-11-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **valid-author:** create more precise reports ([#1337](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1337)) ([e79ff9a](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/e79ff9ac602d85bf999686b018de6ace3a7bee36)), closes [#000](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/000)
|
|
4
9
|
|
|
10
|
+
## [0.59.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.59.0...v0.59.1) (2025-10-30)
|
|
5
11
|
|
|
6
12
|
### Bug Fixes
|
|
7
13
|
|
|
8
|
-
|
|
14
|
+
- **deps:** update dependency validate-npm-package-name to v7 ([#1353](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1353)) ([be9970a](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/be9970a18c73521906d1564ca461d94159e88807))
|
|
9
15
|
|
|
10
16
|
# [0.59.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.58.0...v0.59.0) (2025-10-25)
|
|
11
17
|
|
package/lib/plugin.js
CHANGED
|
@@ -7,13 +7,14 @@ import { rules } from "./rules/require-properties.js";
|
|
|
7
7
|
import { rule as rule$5 } from "./rules/restrict-dependency-ranges.js";
|
|
8
8
|
import { rule as rule$6 } from "./rules/sort-collections.js";
|
|
9
9
|
import { rule as rule$7 } from "./rules/unique-dependencies.js";
|
|
10
|
-
import { rule as rule$8 } from "./rules/valid-
|
|
11
|
-
import { rule as rule$9 } from "./rules/valid-
|
|
12
|
-
import { rule as rule$10 } from "./rules/valid-
|
|
13
|
-
import { rule as rule$11 } from "./rules/valid-
|
|
10
|
+
import { rule as rule$8 } from "./rules/valid-author.js";
|
|
11
|
+
import { rule as rule$9 } from "./rules/valid-bin.js";
|
|
12
|
+
import { rule as rule$10 } from "./rules/valid-local-dependency.js";
|
|
13
|
+
import { rule as rule$11 } from "./rules/valid-name.js";
|
|
14
|
+
import { rule as rule$12 } from "./rules/valid-package-definition.js";
|
|
14
15
|
import { rules as rules$1 } from "./rules/valid-properties.js";
|
|
15
|
-
import { rule as rule$
|
|
16
|
-
import { rule as rule$
|
|
16
|
+
import { rule as rule$13 } from "./rules/valid-repository-directory.js";
|
|
17
|
+
import { rule as rule$14 } from "./rules/valid-version.js";
|
|
17
18
|
import { createRequire } from "node:module";
|
|
18
19
|
import * as parserJsonc from "jsonc-eslint-parser";
|
|
19
20
|
|
|
@@ -30,14 +31,15 @@ const rules$2 = {
|
|
|
30
31
|
"sort-collections": rule$6,
|
|
31
32
|
"unique-dependencies": rule$7,
|
|
32
33
|
...rules$1,
|
|
33
|
-
"valid-
|
|
34
|
-
"valid-
|
|
35
|
-
"valid-
|
|
36
|
-
"valid-
|
|
37
|
-
"valid-
|
|
38
|
-
"valid-
|
|
34
|
+
"valid-author": rule$8,
|
|
35
|
+
"valid-bin": rule$9,
|
|
36
|
+
"valid-local-dependency": rule$10,
|
|
37
|
+
"valid-name": rule$11,
|
|
38
|
+
"valid-package-definition": rule$12,
|
|
39
|
+
"valid-repository-directory": rule$13,
|
|
40
|
+
"valid-version": rule$14
|
|
39
41
|
};
|
|
40
|
-
const baseRecommendedRules = { ...Object.fromEntries(Object.entries(rules$2).filter(([, rule$
|
|
42
|
+
const baseRecommendedRules = { ...Object.fromEntries(Object.entries(rules$2).filter(([, rule$15]) => rule$15.meta.docs?.recommended).map(([name$1]) => ["package-json/" + name$1, "error"])) };
|
|
41
43
|
const recommendedRules = {
|
|
42
44
|
...baseRecommendedRules,
|
|
43
45
|
"package-json/valid-package-definition": ["error", { ignoreProperties: Object.entries(baseRecommendedRules).filter(([name$1]) => name$1.startsWith("package-json/valid-") && name$1 !== "package-json/valid-package-definition").map(([name$1]) => name$1.replace("package-json/valid-", "")) }]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createRule } from "../createRule.js";
|
|
2
|
+
import { validateAuthor } from "package-json-validator";
|
|
3
|
+
|
|
4
|
+
//#region src/rules/valid-author.ts
|
|
5
|
+
const rule = createRule({
|
|
6
|
+
create(context) {
|
|
7
|
+
const reportIssues = (result, node) => {
|
|
8
|
+
if (result.errorMessages.length === 0) return;
|
|
9
|
+
if (result.issues.length) for (const issue of result.issues) context.report({
|
|
10
|
+
data: { error: issue.message },
|
|
11
|
+
messageId: "validationError",
|
|
12
|
+
node
|
|
13
|
+
});
|
|
14
|
+
const childrenWithIssues = result.childResults.filter((childResult) => childResult.errorMessages.length);
|
|
15
|
+
if (node.type === "JSONObjectExpression" && childrenWithIssues.length) for (const childResult of childrenWithIssues) {
|
|
16
|
+
const childNode = node.properties[childResult.index];
|
|
17
|
+
reportIssues(childResult, childNode);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=author]"(node) {
|
|
21
|
+
const valueNode = node.value;
|
|
22
|
+
reportIssues(validateAuthor(JSON.parse(context.sourceCode.getText(valueNode))), valueNode);
|
|
23
|
+
} };
|
|
24
|
+
},
|
|
25
|
+
meta: {
|
|
26
|
+
docs: {
|
|
27
|
+
category: "Best Practices",
|
|
28
|
+
description: "Enforce that the `author` property is valid.",
|
|
29
|
+
recommended: true
|
|
30
|
+
},
|
|
31
|
+
messages: { validationError: `Invalid author: {{ error }}` },
|
|
32
|
+
schema: [],
|
|
33
|
+
type: "problem"
|
|
34
|
+
},
|
|
35
|
+
name: "valid-author"
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { rule };
|
package/lib/rules/valid-bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRule } from "../createRule.js";
|
|
2
2
|
import { formatErrors } from "../utils/formatErrors.js";
|
|
3
|
-
import { kebabCase } from "change-case";
|
|
4
3
|
import { validateBin } from "package-json-validator";
|
|
4
|
+
import { kebabCase } from "change-case";
|
|
5
5
|
|
|
6
6
|
//#region src/rules/valid-bin.ts
|
|
7
7
|
const rule = createRule({
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.js";
|
|
2
|
-
import {
|
|
2
|
+
import { validateBundleDependencies, validateConfig, validateCpu, validateDependencies, validateDescription, validateDirectories, validateExports, validateLicense, validateScripts, validateType } from "package-json-validator";
|
|
3
3
|
|
|
4
4
|
//#region src/rules/valid-properties.ts
|
|
5
5
|
const properties = [
|
|
6
|
-
["author", validateAuthor],
|
|
7
6
|
["bundleDependencies", {
|
|
8
7
|
aliases: ["bundledDependencies"],
|
|
9
8
|
validator: validateBundleDependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.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.32.1",
|
|
52
52
|
"semver": "^7.7.3",
|
|
53
53
|
"sort-object-keys": "^2.0.0",
|
|
54
54
|
"sort-package-json": "^3.4.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"console-fail-test": "0.5.0",
|
|
68
68
|
"eslint": "9.38.0",
|
|
69
69
|
"eslint-doc-generator": "2.3.0",
|
|
70
|
-
"eslint-plugin-eslint-plugin": "7.
|
|
70
|
+
"eslint-plugin-eslint-plugin": "7.2.0",
|
|
71
71
|
"eslint-plugin-jsdoc": "61.1.0",
|
|
72
72
|
"eslint-plugin-jsonc": "2.21.0",
|
|
73
73
|
"eslint-plugin-n": "17.23.1",
|