eslint-plugin-package-json 0.90.1 → 0.91.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
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.91.1](https://github.com/michaelfaith/eslint-plugin-package-json/compare/v0.91.0...v0.91.1) (2026-03-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### 🩹 Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **no-empty-fields:** Allow `files` to be an empty list ([#1682](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1682)) ([4311f74](https://github.com/michaelfaith/eslint-plugin-package-json/commit/4311f743a79b6fc792822680720106a2a84953d4))
|
|
9
|
+
|
|
10
|
+
## [0.91.0](https://github.com/michaelfaith/eslint-plugin-package-json/compare/v0.90.1...v0.91.0) (2026-03-13)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* add `valid-devEngines` rule ([#1663](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1663))
|
|
16
|
+
|
|
17
|
+
### 🚀 Features
|
|
18
|
+
|
|
19
|
+
* add `require-cpu` rule ([#1659](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1659)) ([40ed2f6](https://github.com/michaelfaith/eslint-plugin-package-json/commit/40ed2f6a97040bcf5d516bcf1ac3e1a3a580c5ee))
|
|
20
|
+
* add `valid-devEngines` rule ([#1663](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1663)) ([7325be2](https://github.com/michaelfaith/eslint-plugin-package-json/commit/7325be2c6d3bc77467e8da7019ac24861261e27a))
|
|
21
|
+
* add require-module rule ([#1656](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1656)) ([557254c](https://github.com/michaelfaith/eslint-plugin-package-json/commit/557254cac267d1f37fe019662f8293d123aa0e60))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### 🩹 Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **valid-publishConfig:** rule not reporting violations for deeply nested objects ([#1662](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1662)) ([4c78698](https://github.com/michaelfaith/eslint-plugin-package-json/commit/4c786980b3efc2c25bc9a767a826ec43c3912c2e))
|
|
27
|
+
|
|
3
28
|
## [0.90.1](https://github.com/michaelfaith/eslint-plugin-package-json/compare/v0.90.0...v0.90.1) (2026-03-10)
|
|
4
29
|
|
|
5
30
|
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<!-- prettier-ignore-start -->
|
|
10
10
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
11
|
-
<a href="#contributors" target="_blank"><img alt="👪 All Contributors:
|
|
11
|
+
<a href="#contributors" target="_blank"><img alt="👪 All Contributors: 41" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-41-21bb42.svg" /></a>
|
|
12
12
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
13
13
|
<!-- prettier-ignore-end -->
|
|
14
14
|
<a href="https://github.com/michaelfaith/eslint-plugin-package-json/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="🤝 Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
|
|
@@ -18,179 +18,9 @@
|
|
|
18
18
|
<img alt="💪 TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Getting Started
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```shell
|
|
26
|
-
npm install eslint eslint-plugin-package-json --save-dev
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Usage
|
|
30
|
-
|
|
31
|
-
### Recommended Config
|
|
32
|
-
|
|
33
|
-
This plugin's recommended configuration enables its rules on `**/package.json` files, parsing them with [`jsonc-eslint-parser`](https://github.com/ota-meshi/jsonc-eslint-parser).
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
// eslint.config.ts
|
|
37
|
-
import packageJson from "eslint-plugin-package-json";
|
|
38
|
-
import { defineConfig } from "eslint/config";
|
|
39
|
-
|
|
40
|
-
export default defineConfig([
|
|
41
|
-
// your other ESLint configurations
|
|
42
|
-
packageJson.configs.recommended,
|
|
43
|
-
]);
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
If you want to override the recommended rules:
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
// eslint.config.ts
|
|
50
|
-
import packageJson from "eslint-plugin-package-json";
|
|
51
|
-
import { defineConfig } from "eslint/config";
|
|
52
|
-
|
|
53
|
-
export default defineConfig([
|
|
54
|
-
// your other ESLint configurations
|
|
55
|
-
{
|
|
56
|
-
extends: [packageJson.configs.recommended],
|
|
57
|
-
files: ["package.json"],
|
|
58
|
-
rules: {
|
|
59
|
-
"package-json/require-author": "error",
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
]);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
See [ESLint's _Configuration Files_ guide](https://eslint.org/docs/latest/use/configure/configuration-files-new) for details on how to customize your rules and other config settings.
|
|
66
|
-
|
|
67
|
-
### Recommended Config for Publishable Packages
|
|
68
|
-
|
|
69
|
-
> [!NOTE]
|
|
70
|
-
> This config was recently made redundant and is now the same as `recommended`.
|
|
71
|
-
> However, we're keeping it as its own config for now, in the event that we add new rules unique to the publishable use case.
|
|
72
|
-
|
|
73
|
-
The `recommended-publishable` configuration has everything in it from the standard `recommended` config, with some additional rules added that are geared towards packages that are intended to be published.
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
// eslint.config.ts
|
|
77
|
-
import packageJson from "eslint-plugin-package-json";
|
|
78
|
-
import { defineConfig } from "eslint/config";
|
|
79
|
-
|
|
80
|
-
export default defineConfig([
|
|
81
|
-
// your other ESLint configurations
|
|
82
|
-
packageJson.configs["recommended-publishable"],
|
|
83
|
-
]);
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Stylistic Config
|
|
87
|
-
|
|
88
|
-
The `stylistic` configuration sets up the parser and files similar to the recommended config, but includes rules that are more opinionated about the style of a package.json.
|
|
89
|
-
This can be used in addition to the recommended config, or on its own.
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
// eslint.config.ts
|
|
93
|
-
import packageJson from "eslint-plugin-package-json";
|
|
94
|
-
import { defineConfig } from "eslint/config";
|
|
95
|
-
|
|
96
|
-
export default defineConfig([
|
|
97
|
-
// your other ESLint configurations
|
|
98
|
-
packageJson.configs.recommended, // or packageJson.configs["recommended-publishable"]
|
|
99
|
-
packageJson.configs.stylistic,
|
|
100
|
-
]);
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Legacy Recommended Config (deprecated)
|
|
104
|
-
|
|
105
|
-
Usage with ESLint's legacy ("eslintrc") format requires also installing [`jsonc-eslint-parser`](https://github.com/ota-meshi/jsonc-eslint-parser):
|
|
106
|
-
|
|
107
|
-
```shell
|
|
108
|
-
npm install jsonc-eslint-parser --save-dev
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Add an override to your ESLint configuration file that specifies `jsonc-eslint-parser`, this plugin, and its recommended rules for your `package.json` file:
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
module.exports = {
|
|
115
|
-
overrides: [
|
|
116
|
-
{
|
|
117
|
-
extends: ["plugin:package-json/legacy-recommended"],
|
|
118
|
-
files: ["package.json"],
|
|
119
|
-
parser: "jsonc-eslint-parser",
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
};
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
You may also want to individually configure rules.
|
|
126
|
-
See [ESLint's _Configure Rules_ guide](https://eslint.org/docs/latest/use/configure/rules) for details on how to customize your rules.
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
module.exports = {
|
|
130
|
-
overrides: [
|
|
131
|
-
{
|
|
132
|
-
extends: ["plugin:package-json/legacy-recommended"],
|
|
133
|
-
files: ["package.json"],
|
|
134
|
-
parser: "jsonc-eslint-parser",
|
|
135
|
-
rules: {
|
|
136
|
-
"package-json/valid-package-definition": "error",
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
};
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Settings
|
|
144
|
-
|
|
145
|
-
Some rules can be configured in ESLint shared settings.
|
|
146
|
-
You can set them in `settings.packageJson` in an ESLint flat config.
|
|
147
|
-
|
|
148
|
-
Example:
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
// eslint.config.ts
|
|
152
|
-
import packageJson from "eslint-plugin-package-json";
|
|
153
|
-
import { defineConfig } from "eslint/config";
|
|
154
|
-
|
|
155
|
-
export default defineConfig({
|
|
156
|
-
plugins: {
|
|
157
|
-
"package-json": packageJson,
|
|
158
|
-
},
|
|
159
|
-
rules: {
|
|
160
|
-
// `description` won't be required in package.json with `"private": true`
|
|
161
|
-
"package-json/require-description": "error",
|
|
162
|
-
},
|
|
163
|
-
settings: {
|
|
164
|
-
packageJson: {
|
|
165
|
-
enforceForPrivate: false,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
#### `enforceForPrivate`
|
|
172
|
-
|
|
173
|
-
- **Type:** `boolean`
|
|
174
|
-
- **Default:** [see below]
|
|
175
|
-
|
|
176
|
-
When a package.json file has a `"private": true` field, it indicates that the package will not be published to npm (or another online registry).
|
|
177
|
-
Some fields that are nice to have in public packages become less relevant when a package is private.
|
|
178
|
-
This option determines whether `require-*` rules, if used, should enforce the presence of the corresponding property in package.json files that have `"private": true`.
|
|
179
|
-
|
|
180
|
-
By default, this is:
|
|
181
|
-
|
|
182
|
-
- `false` for [`require-name`](docs/rules/require-name.md) and [`require-version`](docs/rules/require-version.md).
|
|
183
|
-
- `true` for every other `require-*` rule.
|
|
184
|
-
|
|
185
|
-
By specifying this setting as `true` or `false`, it will override the defaults and apply the setting for ALL rules.
|
|
186
|
-
In that case, either all `require-*` rules will be applied to private packages or no `require-*` rules will be applied to private packages.
|
|
187
|
-
Even then, you can override the setting again at the rule level, by using the rule's `ignorePrivate` option, which will take precedence over this global setting.
|
|
188
|
-
|
|
189
|
-
### Usage Alongside Prettier
|
|
190
|
-
|
|
191
|
-
**[`prettier-plugin-packagejson`](https://github.com/matzkoh/prettier-plugin-packagejson)** is a [Prettier plugin](https://prettier.io/docs/en/plugins) that enforces the same `package.json` keys ordering as the [`order-properties`](docs/rules/order-properties.md) and [sort-collections](docs/rules/sort-collections.md) rules with default options.
|
|
192
|
-
We recommend using both the Prettier plugin and `eslint-plugin-package-json`'s recommended configuration.
|
|
193
|
-
The default settings don't conflict, and Prettier plugins can quickly fix up ordering in your editor on save and/or as a Git hook.
|
|
23
|
+
See [Getting Started](https://github.com/michaelfaith/eslint-plugin-package-json/blob/main/docs/getting-started.md) for details.
|
|
194
24
|
|
|
195
25
|
## Supported Rules
|
|
196
26
|
|
|
@@ -221,6 +51,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
221
51
|
| [require-bugs](docs/rules/require-bugs.md) | Requires the `bugs` property to be present. | | | | |
|
|
222
52
|
| [require-bundleDependencies](docs/rules/require-bundleDependencies.md) | Requires the `bundleDependencies` property to be present. | | | | |
|
|
223
53
|
| [require-contributors](docs/rules/require-contributors.md) | Requires the `contributors` property to be present. | | | | |
|
|
54
|
+
| [require-cpu](docs/rules/require-cpu.md) | Requires the `cpu` property to be present. | | | | |
|
|
224
55
|
| [require-dependencies](docs/rules/require-dependencies.md) | Requires the `dependencies` property to be present. | | | | |
|
|
225
56
|
| [require-description](docs/rules/require-description.md) | Requires the `description` property to be present. | ✔️ ✅ 📦 | | | |
|
|
226
57
|
| [require-devDependencies](docs/rules/require-devDependencies.md) | Requires the `devDependencies` property to be present. | | | | |
|
|
@@ -235,6 +66,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
235
66
|
| [require-license](docs/rules/require-license.md) | Requires the `license` property to be present. | ✔️ ✅ 📦 | | | |
|
|
236
67
|
| [require-main](docs/rules/require-main.md) | Requires the `main` property to be present. | | | | |
|
|
237
68
|
| [require-man](docs/rules/require-man.md) | Requires the `man` property to be present. | | | | |
|
|
69
|
+
| [require-module](docs/rules/require-module.md) | Requires the `module` property to be present. | | | | |
|
|
238
70
|
| [require-name](docs/rules/require-name.md) | Requires the `name` property to be present. | ✔️ ✅ 📦 | | | |
|
|
239
71
|
| [require-optionalDependencies](docs/rules/require-optionalDependencies.md) | Requires the `optionalDependencies` property to be present. | | | | |
|
|
240
72
|
| [require-os](docs/rules/require-os.md) | Requires the `os` property to be present. | | | | |
|
|
@@ -264,6 +96,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
264
96
|
| [valid-dependencies](docs/rules/valid-dependencies.md) | Enforce that the `dependencies` property is valid. | ✔️ ✅ 📦 | | | |
|
|
265
97
|
| [valid-description](docs/rules/valid-description.md) | Enforce that the `description` property is valid. | ✔️ ✅ 📦 | | | |
|
|
266
98
|
| [valid-devDependencies](docs/rules/valid-devDependencies.md) | Enforce that the `devDependencies` property is valid. | ✔️ ✅ 📦 | | | |
|
|
99
|
+
| [valid-devEngines](docs/rules/valid-devEngines.md) | Enforce that the `devEngines` property is valid. | ✔️ ✅ 📦 | | | |
|
|
267
100
|
| [valid-directories](docs/rules/valid-directories.md) | Enforce that the `directories` property is valid. | ✔️ ✅ 📦 | | | |
|
|
268
101
|
| [valid-engines](docs/rules/valid-engines.md) | Enforce that the `engines` property is valid. | ✔️ ✅ 📦 | | | |
|
|
269
102
|
| [valid-exports](docs/rules/valid-exports.md) | Enforce that the `exports` property is valid. | ✔️ ✅ 📦 | | | |
|
|
@@ -340,41 +173,43 @@ Thanks! 🗂
|
|
|
340
173
|
</tr>
|
|
341
174
|
<tr>
|
|
342
175
|
<td align="center" valign="top" width="14.28%"><a href="https://christopher-buss.gitbook.io/portfolio"><img src="https://avatars.githubusercontent.com/u/32301681?v=4?s=100" width="100px;" alt="Christopher Buss"/><br /><sub><b>Christopher Buss</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Achristopher-buss" title="Bug reports">🐛</a> <a href="#ideas-christopher-buss" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=christopher-buss" title="Code">💻</a></td>
|
|
176
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ClementValot"><img src="https://avatars.githubusercontent.com/u/65364056?v=4?s=100" width="100px;" alt="Clément Valot"/><br /><sub><b>Clément Valot</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3AClementValot" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=ClementValot" title="Code">💻</a></td>
|
|
343
177
|
<td align="center" valign="top" width="14.28%"><a href="http://www.curtisjewell.dev/"><img src="https://avatars.githubusercontent.com/u/67483?v=4?s=100" width="100px;" alt="Curtis Jewell"/><br /><sub><b>Curtis Jewell</b></sub></a><br /><a href="#ideas-csjewell" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
344
178
|
<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/michaelfaith/eslint-plugin-package-json/commits?author=davidlj95" title="Documentation">📖</a></td>
|
|
345
179
|
<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/michaelfaith/eslint-plugin-package-json/issues?q=author%3Alishaduck" title="Bug reports">🐛</a></td>
|
|
346
180
|
<td align="center" valign="top" width="14.28%"><a href="https://open-fixture-library.org"><img src="https://avatars.githubusercontent.com/u/202916?v=4?s=100" width="100px;" alt="Flo Edelmann"/><br /><sub><b>Flo Edelmann</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=FloEdelmann" title="Documentation">📖</a></td>
|
|
347
181
|
<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>
|
|
348
|
-
<td align="center" valign="top" width="14.28%"><a href="https://hirok.io"><img src="https://avatars.githubusercontent.com/u/1075694?v=4?s=100" width="100px;" alt="Hiroki Osame"/><br /><sub><b>Hiroki Osame</b></sub></a><br /><a href="#ideas-privatenumber" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=privatenumber" title="Code">💻</a></td>
|
|
349
182
|
</tr>
|
|
350
183
|
<tr>
|
|
184
|
+
<td align="center" valign="top" width="14.28%"><a href="https://hirok.io"><img src="https://avatars.githubusercontent.com/u/1075694?v=4?s=100" width="100px;" alt="Hiroki Osame"/><br /><sub><b>Hiroki Osame</b></sub></a><br /><a href="#ideas-privatenumber" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=privatenumber" title="Code">💻</a></td>
|
|
351
185
|
<td align="center" valign="top" width="14.28%"><a href="https://vanyauhalin.me/"><img src="https://avatars.githubusercontent.com/u/56481109?v=4?s=100" width="100px;" alt="Ivan Uhalin"/><br /><sub><b>Ivan Uhalin</b></sub></a><br /><a href="#ideas-vanyauhalin" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
352
186
|
<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/michaelfaith/eslint-plugin-package-json/commits?author=Zamiell" title="Code">💻</a> <a href="#ideas-Zamiell" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3AZamiell" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=Zamiell" title="Documentation">📖</a></td>
|
|
353
187
|
<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/michaelfaith/eslint-plugin-package-json/commits?author=zetlen" title="Code">💻</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Azetlen" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/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>
|
|
354
188
|
<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/michaelfaith/eslint-plugin-package-json/commits?author=piranna" title="Code">💻</a></td>
|
|
355
189
|
<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/michaelfaith/eslint-plugin-package-json/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/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/michaelfaith/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>
|
|
356
190
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kendallgassner"><img src="https://avatars.githubusercontent.com/u/15275462?v=4?s=100" width="100px;" alt="Kendall Gassner"/><br /><sub><b>Kendall Gassner</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=kendallgassner" title="Code">💻</a> <a href="#maintenance-kendallgassner" title="Maintenance">🚧</a></td>
|
|
357
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/KristjanESPERANTO"><img src="https://avatars.githubusercontent.com/u/35647502?v=4?s=100" width="100px;" alt="Kristjan ESPERANTO"/><br /><sub><b>Kristjan ESPERANTO</b></sub></a><br /><a href="#ideas-kristjanesperanto" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Akristjanesperanto" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=kristjanesperanto" title="Code">💻</a></td>
|
|
358
191
|
</tr>
|
|
359
192
|
<tr>
|
|
193
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/KristjanESPERANTO"><img src="https://avatars.githubusercontent.com/u/35647502?v=4?s=100" width="100px;" alt="Kristjan ESPERANTO"/><br /><sub><b>Kristjan ESPERANTO</b></sub></a><br /><a href="#ideas-kristjanesperanto" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Akristjanesperanto" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=kristjanesperanto" title="Code">💻</a></td>
|
|
360
194
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/marcalexiei"><img src="https://avatars.githubusercontent.com/u/24919330?v=4?s=100" width="100px;" alt="Marco Pasqualetti"/><br /><sub><b>Marco Pasqualetti</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=marcalexiei" title="Code">💻</a> <a href="#tool-marcalexiei" title="Tools">🔧</a> <a href="#maintenance-marcalexiei" title="Maintenance">🚧</a></td>
|
|
361
195
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lo1tuma"><img src="https://avatars.githubusercontent.com/u/169170?v=4?s=100" width="100px;" alt="Mathias Schreck"/><br /><sub><b>Mathias Schreck</b></sub></a><br /><a href="#ideas-lo1tuma" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
362
196
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Cellule"><img src="https://avatars.githubusercontent.com/u/4157103?v=4?s=100" width="100px;" alt="Michael "Mike" Ferris"/><br /><sub><b>Michael "Mike" Ferris</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=cellule" title="Code">💻</a></td>
|
|
363
197
|
<td align="center" valign="top" width="14.28%"><a href="https://morrisoncole.co.uk"><img src="https://avatars.githubusercontent.com/u/963368?v=4?s=100" width="100px;" alt="Morrison Cole"/><br /><sub><b>Morrison Cole</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3AMorrisonCole" title="Bug reports">🐛</a></td>
|
|
364
198
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/nschonni"><img src="https://avatars.githubusercontent.com/u/1297909?v=4?s=100" width="100px;" alt="Nick Schonning"/><br /><sub><b>Nick Schonning</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=nschonni" title="Code">💻</a></td>
|
|
365
199
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/OlivierZal"><img src="https://avatars.githubusercontent.com/u/88216225?v=4?s=100" width="100px;" alt="Olivier Zalmanski"/><br /><sub><b>Olivier Zalmanski</b></sub></a><br /><a href="#maintenance-olivierzal" title="Maintenance">🚧</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=olivierzal" title="Documentation">📖</a></td>
|
|
366
|
-
<td align="center" valign="top" width="14.28%"><a href="http://patrikcsak.com"><img src="https://avatars.githubusercontent.com/u/4766244?v=4?s=100" width="100px;" alt="Patrik Csak"/><br /><sub><b>Patrik Csak</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Apatrik-csak" title="Bug reports">🐛</a></td>
|
|
367
200
|
</tr>
|
|
368
201
|
<tr>
|
|
202
|
+
<td align="center" valign="top" width="14.28%"><a href="http://patrikcsak.com"><img src="https://avatars.githubusercontent.com/u/4766244?v=4?s=100" width="100px;" alt="Patrik Csak"/><br /><sub><b>Patrik Csak</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Apatrik-csak" title="Bug reports">🐛</a></td>
|
|
369
203
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/rakleed"><img src="https://avatars.githubusercontent.com/u/19418601?v=4?s=100" width="100px;" alt="Pavel"/><br /><sub><b>Pavel</b></sub></a><br /><a href="#ideas-rakleed" title="Ideas, Planning, & Feedback">🤔</a> <a href="#tool-rakleed" title="Tools">🔧</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=rakleed" title="Documentation">📖</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=rakleed" title="Code">💻</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Arakleed" title="Bug reports">🐛</a></td>
|
|
370
204
|
<td align="center" valign="top" width="14.28%"><a href="https://sasial.dev"><img src="https://avatars.githubusercontent.com/u/44125644?v=4?s=100" width="100px;" alt="Sasial"/><br /><sub><b>Sasial</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=sasial-dev" title="Code">💻</a></td>
|
|
371
205
|
<td align="center" valign="top" width="14.28%"><a href="https://shayan-zamani.me"><img src="https://avatars.githubusercontent.com/u/81762186?v=4?s=100" width="100px;" alt="Shayan Zamani"/><br /><sub><b>Shayan Zamani</b></sub></a><br /><a href="#ideas-ShayanTheNerd" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=ShayanTheNerd" title="Documentation">📖</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=ShayanTheNerd" title="Code">💻</a></td>
|
|
206
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Sigmabrogz"><img src="https://avatars.githubusercontent.com/u/122412346?v=4?s=100" width="100px;" alt="Sigmabro"/><br /><sub><b>Sigmabro</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=Sigmabrogz" title="Code">💻</a></td>
|
|
372
207
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sirugh"><img src="https://avatars.githubusercontent.com/u/1278869?v=4?s=100" width="100px;" alt="Stephen"/><br /><sub><b>Stephen</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=sirugh" title="Code">💻</a></td>
|
|
373
208
|
<td align="center" valign="top" width="14.28%"><a href="https://hyoban.cc"><img src="https://avatars.githubusercontent.com/u/38493346?v=4?s=100" width="100px;" alt="Stephen Zhou"/><br /><sub><b>Stephen Zhou</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Ahyoban" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=hyoban" title="Code">💻</a> <a href="#ideas-hyoban" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=hyoban" title="Documentation">📖</a></td>
|
|
374
|
-
<td align="center" valign="top" width="14.28%"><a href="https://ota-meshi.github.io/"><img src="https://avatars.githubusercontent.com/u/16508807?v=4?s=100" width="100px;" alt="Yosuke Ota"/><br /><sub><b>Yosuke Ota</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Aota-meshi" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=ota-meshi" title="Code">💻</a></td>
|
|
375
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/b3rnhard"><img src="https://avatars.githubusercontent.com/u/10774404?v=4?s=100" width="100px;" alt="b3rnhard"/><br /><sub><b>b3rnhard</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Ab3rnhard" title="Bug reports">🐛</a></td>
|
|
376
209
|
</tr>
|
|
377
210
|
<tr>
|
|
211
|
+
<td align="center" valign="top" width="14.28%"><a href="https://ota-meshi.github.io/"><img src="https://avatars.githubusercontent.com/u/16508807?v=4?s=100" width="100px;" alt="Yosuke Ota"/><br /><sub><b>Yosuke Ota</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Aota-meshi" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=ota-meshi" title="Code">💻</a></td>
|
|
212
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/b3rnhard"><img src="https://avatars.githubusercontent.com/u/10774404?v=4?s=100" width="100px;" alt="b3rnhard"/><br /><sub><b>b3rnhard</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Ab3rnhard" title="Bug reports">🐛</a></td>
|
|
378
213
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chouchouji"><img src="https://avatars.githubusercontent.com/u/70570907?v=4?s=100" width="100px;" alt="chouchouji"/><br /><sub><b>chouchouji</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=chouchouji" title="Code">💻</a></td>
|
|
379
214
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/michaelfaith"><img src="https://avatars.githubusercontent.com/u/8071845?v=4?s=100" width="100px;" alt="michael faith"/><br /><sub><b>michael faith</b></sub></a><br /><a href="#infra-michaelfaith" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=michaelfaith" title="Code">💻</a> <a href="#maintenance-michaelfaith" title="Maintenance">🚧</a> <a href="#ideas-michaelfaith" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Amichaelfaith" title="Bug reports">🐛</a> <a href="#tool-michaelfaith" title="Tools">🔧</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=michaelfaith" title="Documentation">📖</a> <a href="#projectManagement-michaelfaith" title="Project Management">📆</a></td>
|
|
380
215
|
<td align="center" valign="top" width="14.28%"><a href="https://roottool.vercel.app"><img src="https://avatars.githubusercontent.com/u/11808736?v=4?s=100" width="100px;" alt="roottool"/><br /><sub><b>roottool</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=roottool" title="Code">💻</a></td>
|
|
@@ -37,16 +37,17 @@ const getTopLevelProperty = (node) => {
|
|
|
37
37
|
while (n.parent.parent?.parent?.type !== void 0 && n.parent.parent.parent.type !== "Program") n = n.parent;
|
|
38
38
|
return n.type === "JSONProperty" ? n.key : void 0;
|
|
39
39
|
};
|
|
40
|
+
const defaultIgnoreProperties = ["files"];
|
|
40
41
|
const rule = createRule({
|
|
41
42
|
create(context) {
|
|
42
|
-
const ignoreProperties = context.options[0]?.ignoreProperties ??
|
|
43
|
+
const ignoreProperties = new Set(context.options[0]?.ignoreProperties ?? defaultIgnoreProperties);
|
|
43
44
|
return {
|
|
44
45
|
JSONArrayExpression(node) {
|
|
45
46
|
const topLevelProperty = getTopLevelProperty(node);
|
|
46
47
|
if (!topLevelProperty) return;
|
|
47
48
|
if (!node.elements.length) {
|
|
48
49
|
const topLevelPropertyName = topLevelProperty.value;
|
|
49
|
-
if (!ignoreProperties.
|
|
50
|
+
if (!ignoreProperties.has(topLevelPropertyName)) report(context, getNode(node));
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
53
|
JSONObjectExpression(node) {
|
|
@@ -54,13 +55,13 @@ const rule = createRule({
|
|
|
54
55
|
if (!topLevelProperty) return;
|
|
55
56
|
if (!node.properties.length) {
|
|
56
57
|
const topLevelPropertyName = topLevelProperty.value;
|
|
57
|
-
if (!ignoreProperties.
|
|
58
|
+
if (!ignoreProperties.has(topLevelPropertyName)) report(context, getNode(node));
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
};
|
|
61
62
|
},
|
|
62
63
|
meta: {
|
|
63
|
-
defaultOptions: [{ ignoreProperties:
|
|
64
|
+
defaultOptions: [{ ignoreProperties: defaultIgnoreProperties }],
|
|
64
65
|
docs: {
|
|
65
66
|
category: "Best Practices",
|
|
66
67
|
description: "Reports on unnecessary empty arrays and objects.",
|
|
@@ -6,6 +6,7 @@ const propertyConfig = [
|
|
|
6
6
|
["bugs", { ignorePrivateDefault: true }],
|
|
7
7
|
["bundleDependencies"],
|
|
8
8
|
["contributors"],
|
|
9
|
+
["cpu"],
|
|
9
10
|
["dependencies"],
|
|
10
11
|
["description", { isRecommended: true }],
|
|
11
12
|
["devDependencies"],
|
|
@@ -29,6 +30,7 @@ const propertyConfig = [
|
|
|
29
30
|
}],
|
|
30
31
|
["main"],
|
|
31
32
|
["man"],
|
|
33
|
+
["module"],
|
|
32
34
|
["name", {
|
|
33
35
|
ignorePrivateDefault: true,
|
|
34
36
|
isRecommended: true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.mjs";
|
|
2
|
-
import { validateAuthor, validateBin, validateBugs, validateBundleDependencies, validateConfig, validateContributors, validateCpu, validateDependencies, validateDescription, validateDirectories, validateEngines, validateExports, validateFiles, validateFunding, validateHomepage, validateKeywords, validateLicense, validateMain, validateMan, validateOs, validatePackageManager, validatePrivate, validatePublishConfig, validateRepository, validateScripts, validateSideEffects, validateType, validateWorkspaces } from "package-json-validator";
|
|
2
|
+
import { validateAuthor, validateBin, validateBugs, validateBundleDependencies, validateConfig, validateContributors, validateCpu, validateDependencies, validateDescription, validateDevEngines, validateDirectories, validateEngines, validateExports, validateFiles, validateFunding, validateHomepage, validateKeywords, validateLicense, validateMain, validateMan, validateOs, validatePackageManager, validatePrivate, validatePublishConfig, validateRepository, validateScripts, validateSideEffects, validateType, validateWorkspaces } from "package-json-validator";
|
|
3
3
|
//#region src/rules/valid-properties.ts
|
|
4
4
|
const properties = [
|
|
5
5
|
["author", validateAuthor],
|
|
@@ -15,6 +15,7 @@ const properties = [
|
|
|
15
15
|
["description", validateDescription],
|
|
16
16
|
["dependencies", validateDependencies],
|
|
17
17
|
["devDependencies", validateDependencies],
|
|
18
|
+
["devEngines", validateDevEngines],
|
|
18
19
|
["directories", validateDirectories],
|
|
19
20
|
["engines", validateEngines],
|
|
20
21
|
["exports", validateExports],
|
|
@@ -22,7 +22,7 @@ const createSimpleValidPropertyRule = (propertyName, validationFunction, aliases
|
|
|
22
22
|
const childrenWithIssues = result.childResults.filter((childResult) => childResult.errorMessages.length);
|
|
23
23
|
if (node.type === "JSONObjectExpression" && childrenWithIssues.length) for (const childResult of childrenWithIssues) {
|
|
24
24
|
const childNode = node.properties[childResult.index];
|
|
25
|
-
reportIssues(childResult, childNode);
|
|
25
|
+
reportIssues(childResult, childNode.value);
|
|
26
26
|
}
|
|
27
27
|
else if (node.type === "JSONArrayExpression" && childrenWithIssues.length) for (const childResult of childrenWithIssues) {
|
|
28
28
|
const childNode = node.elements[childResult.index];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.1",
|
|
4
4
|
"description": "Rules for consistent, readable, and valid package.json files. 🗂️",
|
|
5
5
|
"homepage": "https://github.com/michaelfaith/eslint-plugin-package-json#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"detect-indent": "^7.0.2",
|
|
50
50
|
"detect-newline": "^4.0.1",
|
|
51
51
|
"eslint-fix-utils": "~0.4.1",
|
|
52
|
-
"package-json-validator": "^1.
|
|
52
|
+
"package-json-validator": "^1.3.1",
|
|
53
53
|
"semver": "^7.7.3",
|
|
54
54
|
"sort-object-keys": "^2.0.0",
|
|
55
55
|
"sort-package-json": "^3.4.0",
|
|
@@ -63,35 +63,35 @@
|
|
|
63
63
|
"@types/node": "24.12.0",
|
|
64
64
|
"@types/semver": "7.7.1",
|
|
65
65
|
"@types/validate-npm-package-name": "4.0.2",
|
|
66
|
-
"@vitest/coverage-v8": "4.0
|
|
66
|
+
"@vitest/coverage-v8": "4.1.0",
|
|
67
67
|
"@vitest/eslint-plugin": "1.6.1",
|
|
68
68
|
"console-fail-test": "0.6.0",
|
|
69
|
-
"eslint": "10.
|
|
69
|
+
"eslint": "10.1.0",
|
|
70
70
|
"eslint-doc-generator": "3.3.1",
|
|
71
71
|
"eslint-plugin-eslint-plugin": "7.3.1",
|
|
72
|
-
"eslint-plugin-jsdoc": "62.
|
|
72
|
+
"eslint-plugin-jsdoc": "62.8.0",
|
|
73
73
|
"eslint-plugin-jsonc": "3.1.0",
|
|
74
74
|
"eslint-plugin-n": "17.24.0",
|
|
75
75
|
"eslint-plugin-node-dependencies": "2.2.0",
|
|
76
|
-
"eslint-plugin-perfectionist": "5.
|
|
77
|
-
"eslint-plugin-regexp": "3.
|
|
76
|
+
"eslint-plugin-perfectionist": "5.7.0",
|
|
77
|
+
"eslint-plugin-regexp": "3.1.0",
|
|
78
78
|
"eslint-plugin-unicorn": "63.0.0",
|
|
79
79
|
"eslint-plugin-yml": "3.3.0",
|
|
80
80
|
"husky": "9.1.7",
|
|
81
81
|
"jiti": "2.6.1",
|
|
82
82
|
"json-schema-to-ts": "3.1.1",
|
|
83
83
|
"jsonc-eslint-parser": "3.1.0",
|
|
84
|
-
"knip": "
|
|
85
|
-
"lint-staged": "16.
|
|
84
|
+
"knip": "6.0.0",
|
|
85
|
+
"lint-staged": "16.4.0",
|
|
86
86
|
"prettier": "3.8.0",
|
|
87
87
|
"prettier-plugin-curly": "0.4.0",
|
|
88
88
|
"prettier-plugin-packagejson": "3.0.0",
|
|
89
89
|
"prettier-plugin-sentences-per-line": "0.2.3",
|
|
90
90
|
"prettier-plugin-sh": "0.18.0",
|
|
91
91
|
"tsdown": "0.21.0",
|
|
92
|
-
"typescript": "
|
|
93
|
-
"typescript-eslint": "8.
|
|
94
|
-
"vitest": "4.0
|
|
92
|
+
"typescript": "6.0.2",
|
|
93
|
+
"typescript-eslint": "8.57.0",
|
|
94
|
+
"vitest": "4.1.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"eslint": ">=8.0.0",
|