eslint-plugin-package-json 0.57.0 β 0.59.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 +14 -2
- package/README.md +10 -8
- package/lib/plugin.d.ts +1 -0
- package/lib/plugin.js +29 -27
- package/lib/rules/exports-subpaths-style.d.ts +18 -0
- package/lib/rules/exports-subpaths-style.js +73 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
# [0.
|
|
3
|
+
# [0.59.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.58.0...v0.59.0) (2025-10-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **exports-subpaths-style:** add new rule ([#1328](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1328)) ([d1a82ed](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/d1a82edf78b7b4bd446018f1ea3bb77e1bc9c772)), closes [#1322](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1322)
|
|
4
9
|
|
|
10
|
+
# [0.58.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.57.0...v0.58.0) (2025-10-22)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- mark `legacy-recommended` config deprecated ([#1331](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1331)) ([5e20411](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/5e204118f4b6ae4a50f9a50a1c2a64a5bf84a5a7)), closes [#1329](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1329) [#1253](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1253)
|
|
15
|
+
|
|
16
|
+
# [0.57.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.56.4...v0.57.0) (2025-10-16)
|
|
5
17
|
|
|
6
18
|
### Features
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- add require-license rule ([#1302](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1302)) ([6d41e06](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/6d41e06dfd2eb89b026229d4045dcdae2cc29e70)), closes [#846](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/846)
|
|
9
21
|
|
|
10
22
|
## [0.56.4](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.56.3...v0.56.4) (2025-10-14)
|
|
11
23
|
|
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: 31" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-31-21bb42.svg" /></a>
|
|
12
12
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
13
13
|
<!-- prettier-ignore-end -->
|
|
14
14
|
<a href="https://github.com/JoshuaKGoldberg/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>
|
|
@@ -28,7 +28,7 @@ npm install eslint eslint-plugin-package-json --save-dev
|
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
31
|
-
###
|
|
31
|
+
### Config
|
|
32
32
|
|
|
33
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
34
|
|
|
@@ -61,7 +61,7 @@ export default [
|
|
|
61
61
|
|
|
62
62
|
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.
|
|
63
63
|
|
|
64
|
-
### Legacy Config
|
|
64
|
+
### Legacy Config (deprecated)
|
|
65
65
|
|
|
66
66
|
Usage with ESLint's legacy ("eslintrc") format requires also installing [`jsonc-eslint-parser`](https://github.com/ota-meshi/jsonc-eslint-parser):
|
|
67
67
|
|
|
@@ -142,8 +142,8 @@ By default, this is:
|
|
|
142
142
|
- `false` for [`require-name`](docs/rules/require-name.md) and [`require-version`](docs/rules/require-version.md).
|
|
143
143
|
- `true` for every other `require-*` rule.
|
|
144
144
|
|
|
145
|
-
By specifying this setting as `true` or `false`, it will override the defaults and apply the setting for ALL rules.
|
|
146
|
-
In that case, either all `require-*` rules will be applied to private packages or no `require-*` rules will be applied to private packages.
|
|
145
|
+
By specifying this setting as `true` or `false`, it will override the defaults and apply the setting for ALL rules.
|
|
146
|
+
In that case, either all `require-*` rules will be applied to private packages or no `require-*` rules will be applied to private packages.
|
|
147
147
|
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.
|
|
148
148
|
|
|
149
149
|
### Usage Alongside Prettier
|
|
@@ -166,6 +166,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
166
166
|
|
|
167
167
|
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | π§ | π‘ | β |
|
|
168
168
|
| :------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------- | :--- | :- | :- | :- |
|
|
169
|
+
| [exports-subpaths-style](docs/rules/exports-subpaths-style.md) | Enforce consistent format for the exports field (implicit or explicit subpaths). | | π§ | | |
|
|
169
170
|
| [no-empty-fields](docs/rules/no-empty-fields.md) | Reports on unnecessary empty arrays and objects. | βοΈ β
| | π‘ | |
|
|
170
171
|
| [no-redundant-files](docs/rules/no-redundant-files.md) | Prevents adding unnecessary / redundant files. | βοΈ β
| | π‘ | |
|
|
171
172
|
| [order-properties](docs/rules/order-properties.md) | Package properties must be declared in standard order | βοΈ β
| π§ | | |
|
|
@@ -261,30 +262,31 @@ Thanks! π
|
|
|
261
262
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=davidlj95" title="Documentation">π</a></td>
|
|
262
263
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Alishaduck" title="Bug reports">π</a></td>
|
|
263
264
|
<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>
|
|
265
|
+
<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></td>
|
|
264
266
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=Zamiell" title="Code">π»</a> <a href="#ideas-Zamiell" title="Ideas, Planning, & Feedback">π€</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3AZamiell" title="Bug reports">π</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=Zamiell" title="Documentation">π</a></td>
|
|
265
267
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=zetlen" title="Code">π»</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Azetlen" title="Bug reports">π</a> <a href="https://github.com/JoshuaKGoldberg/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>
|
|
266
268
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=piranna" title="Code">π»</a></td>
|
|
267
|
-
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">π</a> <a href="https://github.com/JoshuaKGoldberg/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/JoshuaKGoldberg/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>
|
|
268
269
|
</tr>
|
|
269
270
|
<tr>
|
|
271
|
+
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">π</a> <a href="https://github.com/JoshuaKGoldberg/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/JoshuaKGoldberg/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>
|
|
270
272
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=kendallgassner" title="Code">π»</a> <a href="#maintenance-kendallgassner" title="Maintenance">π§</a></td>
|
|
271
273
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Akristjanesperanto" title="Bug reports">π</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=kristjanesperanto" title="Code">π»</a></td>
|
|
272
274
|
<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>
|
|
273
275
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=cellule" title="Code">π»</a></td>
|
|
274
276
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3AMorrisonCole" title="Bug reports">π</a></td>
|
|
275
277
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=nschonni" title="Code">π»</a></td>
|
|
276
|
-
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=rakleed" title="Documentation">π</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=rakleed" title="Code">π»</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Arakleed" title="Bug reports">π</a></td>
|
|
277
278
|
</tr>
|
|
278
279
|
<tr>
|
|
280
|
+
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=rakleed" title="Documentation">π</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=rakleed" title="Code">π»</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Arakleed" title="Bug reports">π</a></td>
|
|
279
281
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=sasial-dev" title="Code">π»</a></td>
|
|
280
282
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=sirugh" title="Code">π»</a></td>
|
|
281
283
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Ahyoban" title="Bug reports">π</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=hyoban" title="Code">π»</a> <a href="#ideas-hyoban" title="Ideas, Planning, & Feedback">π€</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=hyoban" title="Documentation">π</a></td>
|
|
282
284
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Aota-meshi" title="Bug reports">π</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=ota-meshi" title="Code">π»</a></td>
|
|
283
285
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Ab3rnhard" title="Bug reports">π</a></td>
|
|
284
286
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=chouchouji" title="Code">π»</a></td>
|
|
285
|
-
<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/JoshuaKGoldberg/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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Amichaelfaith" title="Bug reports">π</a> <a href="#tool-michaelfaith" title="Tools">π§</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=michaelfaith" title="Documentation">π</a></td>
|
|
286
287
|
</tr>
|
|
287
288
|
<tr>
|
|
289
|
+
<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/JoshuaKGoldberg/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/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Amichaelfaith" title="Bug reports">π</a> <a href="#tool-michaelfaith" title="Tools">π§</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=michaelfaith" title="Documentation">π</a></td>
|
|
288
290
|
<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/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=roottool" title="Code">π»</a></td>
|
|
289
291
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sunnytsang1998"><img src="https://avatars.githubusercontent.com/u/207208443?v=4?s=100" width="100px;" alt="sunnytsang1998"/><br /><sub><b>sunnytsang1998</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Asunnytsang1998" title="Bug reports">π</a></td>
|
|
290
292
|
</tr>
|
package/lib/plugin.d.ts
CHANGED
package/lib/plugin.js
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import { rule } from "./rules/
|
|
2
|
-
import { rule as rule$1 } from "./rules/no-
|
|
3
|
-
import { rule as rule$2 } from "./rules/
|
|
4
|
-
import { rule as rule$3 } from "./rules/
|
|
1
|
+
import { rule } from "./rules/exports-subpaths-style.js";
|
|
2
|
+
import { rule as rule$1 } from "./rules/no-empty-fields.js";
|
|
3
|
+
import { rule as rule$2 } from "./rules/no-redundant-files.js";
|
|
4
|
+
import { rule as rule$3 } from "./rules/order-properties.js";
|
|
5
|
+
import { rule as rule$4 } from "./rules/repository-shorthand.js";
|
|
5
6
|
import { rules } from "./rules/require-properties.js";
|
|
6
|
-
import { rule as rule$
|
|
7
|
-
import { rule as rule$
|
|
8
|
-
import { rule as rule$
|
|
9
|
-
import { rule as rule$
|
|
10
|
-
import { rule as rule$
|
|
11
|
-
import { rule as rule$
|
|
12
|
-
import { rule as rule$
|
|
7
|
+
import { rule as rule$5 } from "./rules/restrict-dependency-ranges.js";
|
|
8
|
+
import { rule as rule$6 } from "./rules/sort-collections.js";
|
|
9
|
+
import { rule as rule$7 } from "./rules/unique-dependencies.js";
|
|
10
|
+
import { rule as rule$8 } from "./rules/valid-bin.js";
|
|
11
|
+
import { rule as rule$9 } from "./rules/valid-local-dependency.js";
|
|
12
|
+
import { rule as rule$10 } from "./rules/valid-name.js";
|
|
13
|
+
import { rule as rule$11 } from "./rules/valid-package-definition.js";
|
|
13
14
|
import { rules as rules$1 } from "./rules/valid-properties.js";
|
|
14
|
-
import { rule as rule$
|
|
15
|
-
import { rule as rule$
|
|
15
|
+
import { rule as rule$12 } from "./rules/valid-repository-directory.js";
|
|
16
|
+
import { rule as rule$13 } from "./rules/valid-version.js";
|
|
16
17
|
import { createRequire } from "node:module";
|
|
17
18
|
import * as parserJsonc from "jsonc-eslint-parser";
|
|
18
19
|
|
|
19
20
|
//#region src/plugin.ts
|
|
20
21
|
const { name, version } = createRequire(import.meta.url)("../package.json");
|
|
21
22
|
const rules$2 = {
|
|
22
|
-
"
|
|
23
|
-
"no-
|
|
24
|
-
"
|
|
23
|
+
"exports-subpaths-style": rule,
|
|
24
|
+
"no-empty-fields": rule$1,
|
|
25
|
+
"no-redundant-files": rule$2,
|
|
26
|
+
"order-properties": rule$3,
|
|
25
27
|
...rules,
|
|
26
|
-
"repository-shorthand": rule$
|
|
27
|
-
"restrict-dependency-ranges": rule$
|
|
28
|
-
"sort-collections": rule$
|
|
29
|
-
"unique-dependencies": rule$
|
|
28
|
+
"repository-shorthand": rule$4,
|
|
29
|
+
"restrict-dependency-ranges": rule$5,
|
|
30
|
+
"sort-collections": rule$6,
|
|
31
|
+
"unique-dependencies": rule$7,
|
|
30
32
|
...rules$1,
|
|
31
|
-
"valid-bin": rule$
|
|
32
|
-
"valid-local-dependency": rule$
|
|
33
|
-
"valid-name": rule$
|
|
34
|
-
"valid-package-definition": rule$
|
|
35
|
-
"valid-repository-directory": rule$
|
|
36
|
-
"valid-version": rule$
|
|
33
|
+
"valid-bin": rule$8,
|
|
34
|
+
"valid-local-dependency": rule$9,
|
|
35
|
+
"valid-name": rule$10,
|
|
36
|
+
"valid-package-definition": rule$11,
|
|
37
|
+
"valid-repository-directory": rule$12,
|
|
38
|
+
"valid-version": rule$13
|
|
37
39
|
};
|
|
38
|
-
const baseRecommendedRules = { ...Object.fromEntries(Object.entries(rules$2).filter(([, rule$
|
|
40
|
+
const baseRecommendedRules = { ...Object.fromEntries(Object.entries(rules$2).filter(([, rule$14]) => rule$14.meta.docs?.recommended).map(([name$1]) => ["package-json/" + name$1, "error"])) };
|
|
39
41
|
const recommendedRules = {
|
|
40
42
|
...baseRecommendedRules,
|
|
41
43
|
"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,18 @@
|
|
|
1
|
+
import { PackageJsonRuleModule } from "../createRule.js";
|
|
2
|
+
|
|
3
|
+
//#region src/rules/exports-subpaths-style.d.ts
|
|
4
|
+
declare const rule: PackageJsonRuleModule<[({
|
|
5
|
+
prefer?: "explicit" | "implicit" | undefined;
|
|
6
|
+
} | undefined)?], [{
|
|
7
|
+
readonly additionalProperties: false;
|
|
8
|
+
readonly properties: {
|
|
9
|
+
readonly prefer: {
|
|
10
|
+
readonly description: "Specifies which exports format to enforce.";
|
|
11
|
+
readonly enum: readonly ["implicit", "explicit"];
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
}]>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { rule };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createRule } from "../createRule.js";
|
|
2
|
+
import { isJSONStringLiteral } from "../utils/predicates.js";
|
|
3
|
+
|
|
4
|
+
//#region src/rules/exports-subpaths-style.ts
|
|
5
|
+
function isImplicitFormat(node) {
|
|
6
|
+
if (node.type === "JSONLiteral") return true;
|
|
7
|
+
return node.properties.every((property) => !isJSONStringLiteral(property.key) || !property.key.value.startsWith("."));
|
|
8
|
+
}
|
|
9
|
+
const rule = createRule({
|
|
10
|
+
create(context) {
|
|
11
|
+
const [{ prefer = "explicit" } = {}] = context.options;
|
|
12
|
+
function validateForExplicit(node) {
|
|
13
|
+
const { value } = node;
|
|
14
|
+
if (value.type !== "JSONLiteral" && value.type !== "JSONObjectExpression" || !isImplicitFormat(value)) return;
|
|
15
|
+
context.report({
|
|
16
|
+
fix(fixer) {
|
|
17
|
+
const valueText = context.sourceCode.getText(value);
|
|
18
|
+
const fixedValue = JSON.stringify({ ".": JSON.parse(valueText) }, null, 2);
|
|
19
|
+
return fixer.replaceText(value, fixedValue);
|
|
20
|
+
},
|
|
21
|
+
messageId: "preferExplicit",
|
|
22
|
+
node: value
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function validateForImplicit(node) {
|
|
26
|
+
const { value } = node;
|
|
27
|
+
if (value.type !== "JSONObjectExpression") return;
|
|
28
|
+
if (value.properties.length !== 1 || !isJSONStringLiteral(value.properties[0].key) || value.properties[0].key.value !== ".") return;
|
|
29
|
+
const dotProperty = value.properties[0];
|
|
30
|
+
context.report({
|
|
31
|
+
fix(fixer) {
|
|
32
|
+
const valueText = context.sourceCode.getText(dotProperty.value);
|
|
33
|
+
const fixedValue = JSON.stringify(JSON.parse(valueText), null, 2);
|
|
34
|
+
return fixer.replaceText(value, fixedValue);
|
|
35
|
+
},
|
|
36
|
+
messageId: "preferImplicit",
|
|
37
|
+
node: value
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return { JSONProperty(node) {
|
|
41
|
+
if (node.key.type !== "JSONLiteral" || node.key.value !== "exports" || node.parent.parent.parent.type !== "Program") return;
|
|
42
|
+
if (prefer === "explicit") validateForExplicit(node);
|
|
43
|
+
else validateForImplicit(node);
|
|
44
|
+
} };
|
|
45
|
+
},
|
|
46
|
+
meta: {
|
|
47
|
+
defaultOptions: [{ prefer: "explicit" }],
|
|
48
|
+
docs: {
|
|
49
|
+
category: "Best Practices",
|
|
50
|
+
description: "Enforce consistent format for the exports field (implicit or explicit subpaths).",
|
|
51
|
+
recommended: false
|
|
52
|
+
},
|
|
53
|
+
fixable: "code",
|
|
54
|
+
messages: {
|
|
55
|
+
preferExplicit: "Prefer explicit subpaths format with \".\" key for single root export.",
|
|
56
|
+
preferImplicit: "Prefer implicit format without \".\" key for single root export."
|
|
57
|
+
},
|
|
58
|
+
schema: [{
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
properties: { prefer: {
|
|
61
|
+
description: "Specifies which exports format to enforce.",
|
|
62
|
+
enum: ["implicit", "explicit"],
|
|
63
|
+
type: "string"
|
|
64
|
+
} },
|
|
65
|
+
type: "object"
|
|
66
|
+
}],
|
|
67
|
+
type: "suggestion"
|
|
68
|
+
},
|
|
69
|
+
name: "exports-subpaths-style"
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { rule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.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": {
|
|
@@ -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.38.0",
|
|
60
60
|
"@release-it/conventional-changelog": "10.0.0",
|
|
61
61
|
"@types/estree": "1.0.7",
|
|
62
62
|
"@types/node": "22.18.0",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@vitest/coverage-v8": "3.2.0",
|
|
66
66
|
"@vitest/eslint-plugin": "1.3.3",
|
|
67
67
|
"console-fail-test": "0.5.0",
|
|
68
|
-
"eslint": "9.
|
|
68
|
+
"eslint": "9.38.0",
|
|
69
69
|
"eslint-doc-generator": "2.3.0",
|
|
70
70
|
"eslint-plugin-eslint-plugin": "7.0.0",
|
|
71
|
-
"eslint-plugin-jsdoc": "61.
|
|
71
|
+
"eslint-plugin-jsdoc": "61.1.0",
|
|
72
72
|
"eslint-plugin-jsonc": "2.21.0",
|
|
73
73
|
"eslint-plugin-n": "17.23.1",
|
|
74
74
|
"eslint-plugin-perfectionist": "4.15.0",
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
"jiti": "2.6.0",
|
|
79
79
|
"json-schema-to-ts": "3.1.1",
|
|
80
80
|
"jsonc-eslint-parser": "2.4.1",
|
|
81
|
-
"knip": "5.
|
|
81
|
+
"knip": "5.66.0",
|
|
82
82
|
"lint-staged": "16.2.0",
|
|
83
|
-
"markdownlint": "0.
|
|
83
|
+
"markdownlint": "0.39.0",
|
|
84
84
|
"markdownlint-cli": "0.45.0",
|
|
85
85
|
"prettier": "3.6.0",
|
|
86
86
|
"prettier-plugin-curly": "0.3.1",
|