eslint-plugin-package-json 0.65.2 → 0.65.3

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,17 @@
1
1
  # Changelog
2
2
 
3
- ## [0.65.2](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.1...v0.65.2) (2025-11-10)
3
+ ## [0.65.3](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.2...v0.65.3) (2025-11-10)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **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)
4
9
 
10
+ ## [0.65.2](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.1...v0.65.2) (2025-11-10)
5
11
 
6
12
  ### Bug Fixes
7
13
 
8
- * **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)
14
+ - **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
15
 
10
16
  ## [0.65.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.65.0...v0.65.1) (2025-11-09)
11
17
 
@@ -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
- [x: string]: PackageJsonRuleModule<[], []>;
6
+ [k: string]: PackageJsonRuleModule<[], []>;
7
7
  };
8
8
  //#endregion
9
9
  export { rules };
@@ -1,18 +1,7 @@
1
- import { createLegacySimpleValidPropertyRule, createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.js";
1
+ import { createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.js";
2
2
  import { validateAuthor, validateBin, 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
- 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,27 @@ 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],
28
19
  ["license", validateLicense],
20
+ ["optionalDependencies", validateDependencies],
21
+ ["peerDependencies", validateDependencies],
22
+ ["scripts", validateScripts],
29
23
  ["type", validateType]
30
24
  ];
31
25
  /** All basic valid- flavor rules */
32
- const rules = {
33
- ...legacyRules,
34
- ...Object.fromEntries(properties.map(([propertyName, validationFunctionOrOptions]) => {
35
- let validationFunction;
36
- let aliases = [];
37
- if (typeof validationFunctionOrOptions === "object") {
38
- validationFunction = validationFunctionOrOptions.validator;
39
- aliases = validationFunctionOrOptions.aliases;
40
- } else validationFunction = validationFunctionOrOptions;
41
- const { rule, ruleName } = createSimpleValidPropertyRule(propertyName, validationFunction, aliases);
42
- return [ruleName, rule];
43
- }))
44
- };
26
+ const rules = Object.fromEntries(properties.map(([propertyName, validationFunctionOrOptions]) => {
27
+ let validationFunction;
28
+ let aliases = [];
29
+ if (typeof validationFunctionOrOptions === "object") {
30
+ validationFunction = validationFunctionOrOptions.validator;
31
+ aliases = validationFunctionOrOptions.aliases;
32
+ } else validationFunction = validationFunctionOrOptions;
33
+ const { rule, ruleName } = createSimpleValidPropertyRule(propertyName, validationFunction, aliases);
34
+ return [ruleName, rule];
35
+ }));
45
36
 
46
37
  //#endregion
47
38
  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 { LegacyValidationFunction, ValidationFunction, createLegacySimpleValidPropertyRule, createSimpleValidPropertyRule };
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 { createLegacySimpleValidPropertyRule, createSimpleValidPropertyRule };
58
+ export { createSimpleValidPropertyRule };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-package-json",
3
- "version": "0.65.2",
3
+ "version": "0.65.3",
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.42.0",
51
+ "package-json-validator": "~0.46.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.38.0",
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.38.0",
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",