eslint-plugin-package-json 0.46.0 → 0.47.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,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
# [0.
|
|
3
|
+
# [0.47.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.46.0...v0.47.0) (2025-07-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **no-empty-fields:** Add `ignoreProperties` option ([#1186](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1186)) ([91e7156](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/91e7156d9f4569e8fee6f1124c4c1bb18ffdfbe0)), closes [#1182](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1182)
|
|
4
9
|
|
|
10
|
+
# [0.46.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.45.2...v0.46.0) (2025-07-24)
|
|
5
11
|
|
|
6
12
|
### Features
|
|
7
13
|
|
|
8
|
-
|
|
14
|
+
- **valid-config:** add new rule for validating `config` ([#1179](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1179)) ([b71de96](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/b71de96a2a79a91d177ee0d734dc5f5d1d8e5b3b)), closes [#820](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/820)
|
|
9
15
|
|
|
10
16
|
## [0.45.2](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.45.1...v0.45.2) (2025-07-24)
|
|
11
17
|
|
|
@@ -3,8 +3,12 @@ import * as jsonc_eslint_parser from 'jsonc-eslint-parser';
|
|
|
3
3
|
import { PackageJsonRuleContext } from '../createRule.js';
|
|
4
4
|
import 'estree';
|
|
5
5
|
|
|
6
|
+
interface Option {
|
|
7
|
+
ignoreProperties?: string[];
|
|
8
|
+
}
|
|
9
|
+
type Options = [Option?];
|
|
6
10
|
declare const rule: {
|
|
7
|
-
create(context: PackageJsonRuleContext<
|
|
11
|
+
create(context: PackageJsonRuleContext<Options>): jsonc_eslint_parser.RuleListener;
|
|
8
12
|
meta: eslint.Rule.RuleMetaData;
|
|
9
13
|
};
|
|
10
14
|
|
|
@@ -52,17 +52,31 @@ const report = (context, node) => {
|
|
|
52
52
|
const getNode = (node) => {
|
|
53
53
|
return node.parent.type === "JSONProperty" ? node.parent : node;
|
|
54
54
|
};
|
|
55
|
+
const getTopLevelPropertyName = (node) => {
|
|
56
|
+
let n = node;
|
|
57
|
+
while (n.parent.parent?.parent?.type !== void 0 && n.parent.parent.parent.type !== "Program") {
|
|
58
|
+
n = n.parent;
|
|
59
|
+
}
|
|
60
|
+
return n.key.value;
|
|
61
|
+
};
|
|
55
62
|
const rule = createRule({
|
|
56
63
|
create(context) {
|
|
64
|
+
const ignoreProperties = context.options[0]?.ignoreProperties ?? [];
|
|
57
65
|
return {
|
|
58
66
|
JSONArrayExpression(node) {
|
|
59
67
|
if (!node.elements.length) {
|
|
60
|
-
|
|
68
|
+
const topLevelProperty = getTopLevelPropertyName(node);
|
|
69
|
+
if (!ignoreProperties.includes(topLevelProperty)) {
|
|
70
|
+
report(context, getNode(node));
|
|
71
|
+
}
|
|
61
72
|
}
|
|
62
73
|
},
|
|
63
74
|
JSONObjectExpression(node) {
|
|
64
75
|
if (!node.properties.length) {
|
|
65
|
-
|
|
76
|
+
const topLevelProperty = getTopLevelPropertyName(node);
|
|
77
|
+
if (!ignoreProperties.includes(topLevelProperty)) {
|
|
78
|
+
report(context, getNode(node));
|
|
79
|
+
}
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
};
|
|
@@ -79,7 +93,20 @@ const rule = createRule({
|
|
|
79
93
|
emptyFields: "The field '{{field}}' does nothing and can be removed.",
|
|
80
94
|
remove: "Remove this empty field."
|
|
81
95
|
},
|
|
82
|
-
schema: [
|
|
96
|
+
schema: [
|
|
97
|
+
{
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
properties: {
|
|
100
|
+
ignoreProperties: {
|
|
101
|
+
items: {
|
|
102
|
+
type: "string"
|
|
103
|
+
},
|
|
104
|
+
type: "array"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
type: "object"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
83
110
|
type: "suggestion"
|
|
84
111
|
}
|
|
85
112
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.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": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"husky": "9.1.7",
|
|
83
83
|
"jiti": "2.4.2",
|
|
84
84
|
"jsonc-eslint-parser": "2.4.0",
|
|
85
|
-
"knip": "5.
|
|
85
|
+
"knip": "5.62.0",
|
|
86
86
|
"lint-staged": "16.1.0",
|
|
87
87
|
"markdownlint": "0.38.0",
|
|
88
88
|
"markdownlint-cli": "0.45.0",
|