eslint-plugin-package-json 1.0.0-beta.6 โ 1.1.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 +52 -0
- package/LICENSE.md +2 -0
- package/README.md +108 -105
- package/lib/createRule.d.mts +4 -3
- package/lib/createRule.mjs +2 -1
- package/lib/index.d.mts +7 -9
- package/lib/plugin.d.mts +4 -4
- package/lib/plugin.mjs +4 -8
- package/lib/rules/require-attribution.mjs +11 -5
- package/lib/rules/require-properties.mjs +5 -0
- package/lib/rules/valid-properties.mjs +6 -6
- package/lib/types/estree.d.mts +1 -1
- package/lib/utils/createSimpleRequirePropertyRule.d.mts +1 -1
- package/lib/utils/createSimpleRequirePropertyRule.mjs +7 -3
- package/lib/utils/createSimpleValidPropertyRule.mjs +3 -2
- package/package.json +15 -17
- package/lib/rules/valid-name.d.mts +0 -6
- package/lib/rules/valid-name.mjs +0 -42
- package/lib/rules/valid-version.d.mts +0 -6
- package/lib/rules/valid-version.mjs +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.0](https://github.com/michaelfaith/eslint-plugin-package-json/compare/v1.0.0...v1.1.0) (2026-05-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ๐ Features
|
|
7
|
+
|
|
8
|
+
* add `require-peerDependenciesMeta` rule ([#1852](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1852)) ([e66ac55](https://github.com/michaelfaith/eslint-plugin-package-json/commit/e66ac55c64b5be4c829e67884611e335a34db70c))
|
|
9
|
+
|
|
10
|
+
## [1.0.0](https://github.com/michaelfaith/eslint-plugin-package-json/compare/v0.91.2...v1.0.0) (2026-05-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### โ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* add `valid-browser` rule ([#1763](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1763))
|
|
16
|
+
* add `valid-bugs` rule ([#1644](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1644))
|
|
17
|
+
* add `valid-funding` rule ([#1643](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1643))
|
|
18
|
+
* add `valid-gypfile` rule ([#1765](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1765))
|
|
19
|
+
* add `valid-libc` rule ([#1764](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1764))
|
|
20
|
+
* add `valid-packageManager` rule ([#1640](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1640))
|
|
21
|
+
* add `valid-peerDependenciesMeta-relationship` rule ([#1767](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1767))
|
|
22
|
+
* add `valid-peerDependenciesMeta` rule ([#1766](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1766))
|
|
23
|
+
* drop `legacy-recommended` rc-based config ([#1579](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1579))
|
|
24
|
+
* drop support for eslint v8 ([#1589](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1589))
|
|
25
|
+
* **order-properties:** remove legacy order option
|
|
26
|
+
* remove `valid-package-definition` rule ([#1707](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1707))
|
|
27
|
+
* update node engines to `^22.22.2 || >=24.15.0` ([#1824](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1824))
|
|
28
|
+
* **valid-name:** refactor to align with other `valid-` rules ([#1821](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1821))
|
|
29
|
+
|
|
30
|
+
### ๐ Features
|
|
31
|
+
|
|
32
|
+
* add `require-browser` rule ([#1835](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1835)) ([56433d0](https://github.com/michaelfaith/eslint-plugin-package-json/commit/56433d0b3ae784a14e700074b678a271804f1e3e))
|
|
33
|
+
* add `require-config` rule ([#1834](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1834)) ([24f4eb0](https://github.com/michaelfaith/eslint-plugin-package-json/commit/24f4eb004749ecc953a5ebbc090a256608538f3c))
|
|
34
|
+
* add `require-gypfile` rule ([#1836](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1836)) ([d6cc291](https://github.com/michaelfaith/eslint-plugin-package-json/commit/d6cc29190bf3377b6541efa0f6a477012e68b3af))
|
|
35
|
+
* add `require-libc` rule ([#1837](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1837)) ([53a208e](https://github.com/michaelfaith/eslint-plugin-package-json/commit/53a208e786fd5ade05a16d00cf90eb5c1121f7d4))
|
|
36
|
+
* add `valid-browser` rule ([#1763](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1763)) ([6cb438b](https://github.com/michaelfaith/eslint-plugin-package-json/commit/6cb438bb5c68af1062a5d7a26131795b7aa9a24b))
|
|
37
|
+
* add `valid-bugs` rule ([#1644](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1644)) ([f981fa3](https://github.com/michaelfaith/eslint-plugin-package-json/commit/f981fa38ab4f1630c6db0933d859974d0a6ec0b3))
|
|
38
|
+
* add `valid-funding` rule ([#1643](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1643)) ([5b3c77d](https://github.com/michaelfaith/eslint-plugin-package-json/commit/5b3c77da9b8edcd659a1fd9b3e51d1e43803aa5e))
|
|
39
|
+
* add `valid-gypfile` rule ([#1765](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1765)) ([c14f624](https://github.com/michaelfaith/eslint-plugin-package-json/commit/c14f624137fa11f42f6b5d97357043a94408edd7))
|
|
40
|
+
* add `valid-libc` rule ([#1764](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1764)) ([4dd5e9c](https://github.com/michaelfaith/eslint-plugin-package-json/commit/4dd5e9c251e2b4e68571080cfe9fbfeb030b1775))
|
|
41
|
+
* add `valid-packageManager` rule ([#1640](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1640)) ([9a65480](https://github.com/michaelfaith/eslint-plugin-package-json/commit/9a65480cb55a4d03043916def549cfd7fc4b604b))
|
|
42
|
+
* add `valid-peerDependenciesMeta-relationship` rule ([#1767](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1767)) ([7fc3f0d](https://github.com/michaelfaith/eslint-plugin-package-json/commit/7fc3f0d17ab9be57b3fc118746a38caf9395db18))
|
|
43
|
+
* add `valid-peerDependenciesMeta` rule ([#1766](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1766)) ([8731609](https://github.com/michaelfaith/eslint-plugin-package-json/commit/873160958c77caa6b479053a2fad2b41dacc18fe))
|
|
44
|
+
* **order-properties:** remove legacy order option ([935f6dc](https://github.com/michaelfaith/eslint-plugin-package-json/commit/935f6dccccdfe7d61deb43e083647a0a1dc8e953))
|
|
45
|
+
* remove `valid-package-definition` rule ([#1707](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1707)) ([a4a5b86](https://github.com/michaelfaith/eslint-plugin-package-json/commit/a4a5b86e94b1fd41da8b113f49c96a8149e30fa6))
|
|
46
|
+
* update node engines to `^22.22.2 || >=24.15.0` ([#1824](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1824)) ([ce1aa5e](https://github.com/michaelfaith/eslint-plugin-package-json/commit/ce1aa5e222cd17cd25baa9ebf2221642ddc6ed79))
|
|
47
|
+
* **valid-name:** refactor to align with other `valid-` rules ([#1821](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1821)) ([2104e75](https://github.com/michaelfaith/eslint-plugin-package-json/commit/2104e75e70eee219d57309e50f1812f8d144a11e))
|
|
48
|
+
* **valid-version:** refactor to align with other valid- rules ([#1827](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1827)) ([958c105](https://github.com/michaelfaith/eslint-plugin-package-json/commit/958c10558d4186c9885588c2e7da23e5644d98a6))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### ๐ฉน Bug Fixes
|
|
52
|
+
|
|
53
|
+
* improve report range for `require-` rules ([#1840](https://github.com/michaelfaith/eslint-plugin-package-json/issues/1840)) ([1f03c6a](https://github.com/michaelfaith/eslint-plugin-package-json/commit/1f03c6ac732ffae7d29177411a6cbc6798b813da))
|
|
54
|
+
|
|
3
55
|
## [1.0.0-beta.6](https://github.com/michaelfaith/eslint-plugin-package-json/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2026-05-02)
|
|
4
56
|
|
|
5
57
|
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
<
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img
|
|
3
|
+
src="https://raw.githubusercontent.com/michaelfaith/eslint-plugin-package-json/main/site/src/assets/logo/logo.svg"
|
|
4
|
+
alt="Logo Image"
|
|
5
|
+
height="240"
|
|
6
|
+
/>
|
|
7
|
+
|
|
8
|
+
<h1 align="center">ESLint Plugin: Package JSON</h1>
|
|
2
9
|
|
|
3
10
|
<p align="center">
|
|
4
11
|
Rules for consistent, readable, and valid package.json files.
|
|
@@ -11,20 +18,17 @@
|
|
|
11
18
|
<a href="#contributors" target="_blank"><img alt="๐ช All Contributors: 42" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-42-21bb42.svg" /></a>
|
|
12
19
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
13
20
|
<!-- prettier-ignore-end -->
|
|
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>
|
|
15
21
|
<a href="https://codecov.io/gh/michaelfaith/eslint-plugin-package-json" target="_blank"><img alt="๐งช Coverage" src="https://img.shields.io/codecov/c/github/michaelfaith/eslint-plugin-package-json?label=%F0%9F%A7%AA%20coverage" /></a>
|
|
16
22
|
<a href="https://github.com/michaelfaith/eslint-plugin-package-json/blob/main/LICENSE.md" target="_blank"><img alt="๐ License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg" /></a>
|
|
17
23
|
<a href="http://npmjs.com/package/eslint-plugin-package-json" target="_blank"><img alt="๐ฆ npm version" src="https://img.shields.io/npm/v/eslint-plugin-package-json?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
|
|
18
|
-
<img alt="๐ช TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
|
|
19
24
|
</p>
|
|
20
25
|
|
|
21
26
|
## Getting Started
|
|
22
27
|
|
|
23
|
-
See [Getting Started](https://
|
|
28
|
+
See [Getting Started](https://eslint-plugin-package-json.dev/getting-started) for details.
|
|
24
29
|
|
|
25
30
|
## Supported Rules
|
|
26
31
|
|
|
27
|
-
<!-- prettier-ignore-start -->
|
|
28
32
|
<!-- begin auto-generated rules list -->
|
|
29
33
|
|
|
30
34
|
๐ผ Configurations enabled in.\
|
|
@@ -34,101 +38,105 @@ See [Getting Started](https://github.com/michaelfaith/eslint-plugin-package-json
|
|
|
34
38
|
๐ง Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
|
|
35
39
|
๐ก Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
|
|
36
40
|
|
|
37
|
-
| Name
|
|
38
|
-
|
|
|
39
|
-
| [bin-name-casing](
|
|
40
|
-
| [exports-subpaths-style](
|
|
41
|
-
| [no-empty-fields](
|
|
42
|
-
| [no-redundant-files](
|
|
43
|
-
| [no-redundant-publishConfig](
|
|
44
|
-
| [order-properties](
|
|
45
|
-
| [repository-shorthand](
|
|
46
|
-
| [require-attribution](
|
|
47
|
-
| [require-author](
|
|
48
|
-
| [require-bin](
|
|
49
|
-
| [require-
|
|
50
|
-
| [require-
|
|
51
|
-
| [require-
|
|
52
|
-
| [require-
|
|
53
|
-
| [require-
|
|
54
|
-
| [require-
|
|
55
|
-
| [require-
|
|
56
|
-
| [require-
|
|
57
|
-
| [require-
|
|
58
|
-
| [require-
|
|
59
|
-
| [require-
|
|
60
|
-
| [require-
|
|
61
|
-
| [require-
|
|
62
|
-
| [require-
|
|
63
|
-
| [require-
|
|
64
|
-
| [require-
|
|
65
|
-
| [require-
|
|
66
|
-
| [require-
|
|
67
|
-
| [require-
|
|
68
|
-
| [require-
|
|
69
|
-
| [require-
|
|
70
|
-
| [require-
|
|
71
|
-
| [require-
|
|
72
|
-
| [require-
|
|
73
|
-
| [require-
|
|
74
|
-
| [require-
|
|
75
|
-
| [require-
|
|
76
|
-
| [require-
|
|
77
|
-
| [require-
|
|
78
|
-
| [require-
|
|
79
|
-
| [require-
|
|
80
|
-
| [require-
|
|
81
|
-
| [
|
|
82
|
-
| [
|
|
83
|
-
| [
|
|
84
|
-
| [
|
|
85
|
-
| [
|
|
86
|
-
| [
|
|
87
|
-
| [
|
|
88
|
-
| [
|
|
89
|
-
| [
|
|
90
|
-
| [
|
|
91
|
-
| [
|
|
92
|
-
| [
|
|
93
|
-
| [valid-
|
|
94
|
-
| [valid-
|
|
95
|
-
| [valid-
|
|
96
|
-
| [valid-
|
|
97
|
-
| [valid-
|
|
98
|
-
| [valid-
|
|
99
|
-
| [valid-
|
|
100
|
-
| [valid-
|
|
101
|
-
| [valid-
|
|
102
|
-
| [valid-
|
|
103
|
-
| [valid-
|
|
104
|
-
| [valid-
|
|
105
|
-
| [valid-
|
|
106
|
-
| [valid-
|
|
107
|
-
| [valid-
|
|
108
|
-
| [valid-
|
|
109
|
-
| [valid-
|
|
110
|
-
| [valid-
|
|
111
|
-
| [valid-
|
|
112
|
-
| [valid-
|
|
113
|
-
| [valid-
|
|
114
|
-
| [valid-
|
|
115
|
-
| [valid-
|
|
116
|
-
| [valid-
|
|
117
|
-
| [valid-
|
|
118
|
-
| [valid-
|
|
119
|
-
| [valid-
|
|
120
|
-
| [valid-
|
|
121
|
-
| [valid-
|
|
122
|
-
| [valid-
|
|
123
|
-
| [valid-
|
|
124
|
-
| [valid-
|
|
125
|
-
| [valid-
|
|
126
|
-
| [valid-
|
|
127
|
-
| [valid-
|
|
128
|
-
| [valid-
|
|
41
|
+
| Nameย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย | Description | ๐ผ | ๐ง | ๐ก |
|
|
42
|
+
| :------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---- | :-- | :-- |
|
|
43
|
+
| [bin-name-casing](https://eslint-plugin-package-json.dev/rules/bin-name-casing) | Enforce that names for bin properties are in kebab case. | ๐จ | | ๐ก |
|
|
44
|
+
| [exports-subpaths-style](https://eslint-plugin-package-json.dev/rules/exports-subpaths-style) | Enforce consistent format for the exports field (implicit or explicit subpaths). | ๐จ | ๐ง | |
|
|
45
|
+
| [no-empty-fields](https://eslint-plugin-package-json.dev/rules/no-empty-fields) | Reports on unnecessary empty arrays and objects. | โ
๐ฆ | | ๐ก |
|
|
46
|
+
| [no-redundant-files](https://eslint-plugin-package-json.dev/rules/no-redundant-files) | Prevents adding unnecessary / redundant files. | โ
๐ฆ | | ๐ก |
|
|
47
|
+
| [no-redundant-publishConfig](https://eslint-plugin-package-json.dev/rules/no-redundant-publishConfig) | Warns when publishConfig.access is used in unscoped packages. | โ
๐ฆ | | ๐ก |
|
|
48
|
+
| [order-properties](https://eslint-plugin-package-json.dev/rules/order-properties) | Package properties should be declared in standard order | ๐จ | ๐ง | |
|
|
49
|
+
| [repository-shorthand](https://eslint-plugin-package-json.dev/rules/repository-shorthand) | Enforce either object or shorthand declaration for repository. | โ
๐ฆ | ๐ง | |
|
|
50
|
+
| [require-attribution](https://eslint-plugin-package-json.dev/rules/require-attribution) | Ensures that proper attribution is included, requiring that either `author` or `contributors` is defined, and that if `contributors` is present, it should include at least one contributor. | โ
๐ฆ | | ๐ก |
|
|
51
|
+
| [require-author](https://eslint-plugin-package-json.dev/rules/require-properties/require-author) | Requires the `author` property to be present. | | | |
|
|
52
|
+
| [require-bin](https://eslint-plugin-package-json.dev/rules/require-properties/require-bin) | Requires the `bin` property to be present. | | | |
|
|
53
|
+
| [require-browser](https://eslint-plugin-package-json.dev/rules/require-properties/require-browser) | Requires the `browser` property to be present. | | | |
|
|
54
|
+
| [require-bugs](https://eslint-plugin-package-json.dev/rules/require-properties/require-bugs) | Requires the `bugs` property to be present. | | | |
|
|
55
|
+
| [require-bundleDependencies](https://eslint-plugin-package-json.dev/rules/require-properties/require-bundleDependencies) | Requires the `bundleDependencies` property to be present. | | | |
|
|
56
|
+
| [require-config](https://eslint-plugin-package-json.dev/rules/require-properties/require-config) | Requires the `config` property to be present. | | | |
|
|
57
|
+
| [require-contributors](https://eslint-plugin-package-json.dev/rules/require-properties/require-contributors) | Requires the `contributors` property to be present. | | | |
|
|
58
|
+
| [require-cpu](https://eslint-plugin-package-json.dev/rules/require-properties/require-cpu) | Requires the `cpu` property to be present. | | | |
|
|
59
|
+
| [require-dependencies](https://eslint-plugin-package-json.dev/rules/require-properties/require-dependencies) | Requires the `dependencies` property to be present. | | | |
|
|
60
|
+
| [require-description](https://eslint-plugin-package-json.dev/rules/require-properties/require-description) | Requires the `description` property to be present. | โ
๐ฆ | | |
|
|
61
|
+
| [require-devDependencies](https://eslint-plugin-package-json.dev/rules/require-properties/require-devDependencies) | Requires the `devDependencies` property to be present. | | | |
|
|
62
|
+
| [require-devEngines](https://eslint-plugin-package-json.dev/rules/require-properties/require-devEngines) | Requires the `devEngines` property to be present. | | | |
|
|
63
|
+
| [require-directories](https://eslint-plugin-package-json.dev/rules/require-properties/require-directories) | Requires the `directories` property to be present. | | | |
|
|
64
|
+
| [require-engines](https://eslint-plugin-package-json.dev/rules/require-properties/require-engines) | Requires the `engines` property to be present. | | | |
|
|
65
|
+
| [require-exports](https://eslint-plugin-package-json.dev/rules/require-properties/require-exports) | Requires the `exports` property to be present. | โ
๐ฆ | | |
|
|
66
|
+
| [require-files](https://eslint-plugin-package-json.dev/rules/require-properties/require-files) | Requires the `files` property to be present. | โ
๐ฆ | | |
|
|
67
|
+
| [require-funding](https://eslint-plugin-package-json.dev/rules/require-properties/require-funding) | Requires the `funding` property to be present. | | | |
|
|
68
|
+
| [require-gypfile](https://eslint-plugin-package-json.dev/rules/require-properties/require-gypfile) | Requires the `gypfile` property to be present. | | | |
|
|
69
|
+
| [require-homepage](https://eslint-plugin-package-json.dev/rules/require-properties/require-homepage) | Requires the `homepage` property to be present. | | | |
|
|
70
|
+
| [require-keywords](https://eslint-plugin-package-json.dev/rules/require-properties/require-keywords) | Requires the `keywords` property to be present. | | | |
|
|
71
|
+
| [require-libc](https://eslint-plugin-package-json.dev/rules/require-properties/require-libc) | Requires the `libc` property to be present. | | | |
|
|
72
|
+
| [require-license](https://eslint-plugin-package-json.dev/rules/require-properties/require-license) | Requires the `license` property to be present. | โ
๐ฆ | | |
|
|
73
|
+
| [require-main](https://eslint-plugin-package-json.dev/rules/require-properties/require-main) | Requires the `main` property to be present. | | | |
|
|
74
|
+
| [require-man](https://eslint-plugin-package-json.dev/rules/require-properties/require-man) | Requires the `man` property to be present. | | | |
|
|
75
|
+
| [require-module](https://eslint-plugin-package-json.dev/rules/require-properties/require-module) | Requires the `module` property to be present. | | | |
|
|
76
|
+
| [require-name](https://eslint-plugin-package-json.dev/rules/require-properties/require-name) | Requires the `name` property to be present. | โ
๐ฆ | | |
|
|
77
|
+
| [require-optionalDependencies](https://eslint-plugin-package-json.dev/rules/require-properties/require-optionalDependencies) | Requires the `optionalDependencies` property to be present. | | | |
|
|
78
|
+
| [require-os](https://eslint-plugin-package-json.dev/rules/require-properties/require-os) | Requires the `os` property to be present. | | | |
|
|
79
|
+
| [require-packageManager](https://eslint-plugin-package-json.dev/rules/require-properties/require-packageManager) | Requires the `packageManager` property to be present. | | | |
|
|
80
|
+
| [require-peerDependencies](https://eslint-plugin-package-json.dev/rules/require-properties/require-peerDependencies) | Requires the `peerDependencies` property to be present. | | | |
|
|
81
|
+
| [require-peerDependenciesMeta](https://eslint-plugin-package-json.dev/rules/require-properties/require-peerDependenciesMeta) | Requires the `peerDependenciesMeta` property to be present. | | | |
|
|
82
|
+
| [require-private](https://eslint-plugin-package-json.dev/rules/require-properties/require-private) | Requires the `private` property to be present. | | ๐ง | |
|
|
83
|
+
| [require-publishConfig](https://eslint-plugin-package-json.dev/rules/require-properties/require-publishConfig) | Requires the `publishConfig` property to be present. | | | |
|
|
84
|
+
| [require-repository](https://eslint-plugin-package-json.dev/rules/require-properties/require-repository) | Requires the `repository` property to be present. | โ
๐ฆ | | |
|
|
85
|
+
| [require-scripts](https://eslint-plugin-package-json.dev/rules/require-properties/require-scripts) | Requires the `scripts` property to be present. | | | |
|
|
86
|
+
| [require-sideEffects](https://eslint-plugin-package-json.dev/rules/require-properties/require-sideEffects) | Requires the `sideEffects` property to be present. | โ
๐ฆ | | |
|
|
87
|
+
| [require-type](https://eslint-plugin-package-json.dev/rules/require-properties/require-type) | Requires the `type` property to be present. | โ
๐ฆ | ๐ง | |
|
|
88
|
+
| [require-types](https://eslint-plugin-package-json.dev/rules/require-properties/require-types) | Requires the `types` property to be present. | | | |
|
|
89
|
+
| [require-version](https://eslint-plugin-package-json.dev/rules/require-properties/require-version) | Requires the `version` property to be present. | โ
๐ฆ | | |
|
|
90
|
+
| [restrict-dependency-ranges](https://eslint-plugin-package-json.dev/rules/restrict-dependency-ranges) | Restricts the range of dependencies to allow or disallow specific types of ranges. | | | ๐ก |
|
|
91
|
+
| [restrict-private-properties](https://eslint-plugin-package-json.dev/rules/restrict-private-properties) | Disallows unnecessary properties in private packages. | | ๐ง | ๐ก |
|
|
92
|
+
| [restrict-top-level-properties](https://eslint-plugin-package-json.dev/rules/restrict-top-level-properties) | Disallows specified top-level properties in package.json. | | | ๐ก |
|
|
93
|
+
| [scripts-name-casing](https://eslint-plugin-package-json.dev/rules/scripts-name-casing) | Enforce that names for `scripts` are in kebab case (optionally separated by colons). | ๐จ | | ๐ก |
|
|
94
|
+
| [sort-collections](https://eslint-plugin-package-json.dev/rules/sort-collections) | Selected collections must be in a consistent order (lexicographical for most; lifecycle-aware for scripts). | โ
๐ฆ | ๐ง | |
|
|
95
|
+
| [specify-peers-locally](https://eslint-plugin-package-json.dev/rules/specify-peers-locally) | Requires that all peer dependencies are also declared as dev dependencies | โ
๐ฆ | | ๐ก |
|
|
96
|
+
| [unique-dependencies](https://eslint-plugin-package-json.dev/rules/unique-dependencies) | Checks a dependency isn't specified more than once (i.e. in `dependencies` and `devDependencies`) | โ
๐ฆ | | ๐ก |
|
|
97
|
+
| [valid-author](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-author) | Enforce that the `author` property is valid. | โ
๐ฆ | | |
|
|
98
|
+
| [valid-bin](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-bin) | Enforce that the `bin` property is valid. | โ
๐ฆ | | |
|
|
99
|
+
| [valid-browser](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-browser) | Enforce that the `browser` property is valid. | โ
๐ฆ | | |
|
|
100
|
+
| [valid-bugs](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-bugs) | Enforce that the `bugs` property is valid. | โ
๐ฆ | | |
|
|
101
|
+
| [valid-bundleDependencies](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-bundleDependencies) | Enforce that the `bundleDependencies` (also `bundledDependencies`) property is valid. | โ
๐ฆ | | |
|
|
102
|
+
| [valid-config](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-config) | Enforce that the `config` property is valid. | โ
๐ฆ | | |
|
|
103
|
+
| [valid-contributors](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-contributors) | Enforce that the `contributors` property is valid. | โ
๐ฆ | | |
|
|
104
|
+
| [valid-cpu](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-cpu) | Enforce that the `cpu` property is valid. | โ
๐ฆ | | |
|
|
105
|
+
| [valid-dependencies](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-dependencies) | Enforce that the `dependencies` property is valid. | โ
๐ฆ | | |
|
|
106
|
+
| [valid-description](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-description) | Enforce that the `description` property is valid. | โ
๐ฆ | | |
|
|
107
|
+
| [valid-devDependencies](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-devDependencies) | Enforce that the `devDependencies` property is valid. | โ
๐ฆ | | |
|
|
108
|
+
| [valid-devEngines](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-devEngines) | Enforce that the `devEngines` property is valid. | โ
๐ฆ | | |
|
|
109
|
+
| [valid-directories](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-directories) | Enforce that the `directories` property is valid. | โ
๐ฆ | | |
|
|
110
|
+
| [valid-engines](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-engines) | Enforce that the `engines` property is valid. | โ
๐ฆ | | |
|
|
111
|
+
| [valid-exports](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-exports) | Enforce that the `exports` property is valid. | โ
๐ฆ | | |
|
|
112
|
+
| [valid-files](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-files) | Enforce that the `files` property is valid. | โ
๐ฆ | | |
|
|
113
|
+
| [valid-funding](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-funding) | Enforce that the `funding` property is valid. | โ
๐ฆ | | |
|
|
114
|
+
| [valid-gypfile](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-gypfile) | Enforce that the `gypfile` property is valid. | โ
๐ฆ | | |
|
|
115
|
+
| [valid-homepage](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-homepage) | Enforce that the `homepage` property is valid. | โ
๐ฆ | | |
|
|
116
|
+
| [valid-keywords](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-keywords) | Enforce that the `keywords` property is valid. | โ
๐ฆ | | |
|
|
117
|
+
| [valid-libc](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-libc) | Enforce that the `libc` property is valid. | โ
๐ฆ | | |
|
|
118
|
+
| [valid-license](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-license) | Enforce that the `license` property is valid. | โ
๐ฆ | | |
|
|
119
|
+
| [valid-main](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-main) | Enforce that the `main` property is valid. | โ
๐ฆ | | |
|
|
120
|
+
| [valid-man](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-man) | Enforce that the `man` property is valid. | โ
๐ฆ | | |
|
|
121
|
+
| [valid-module](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-module) | Enforce that the `module` property is valid. | โ
๐ฆ | | |
|
|
122
|
+
| [valid-name](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-name) | Enforce that the `name` property is valid. | โ
๐ฆ | | |
|
|
123
|
+
| [valid-optionalDependencies](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-optionalDependencies) | Enforce that the `optionalDependencies` property is valid. | โ
๐ฆ | | |
|
|
124
|
+
| [valid-os](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-os) | Enforce that the `os` property is valid. | โ
๐ฆ | | |
|
|
125
|
+
| [valid-packageManager](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-packageManager) | Enforce that the `packageManager` property is valid. | โ
๐ฆ | | |
|
|
126
|
+
| [valid-peerDependencies](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-peerDependencies) | Enforce that the `peerDependencies` property is valid. | โ
๐ฆ | | |
|
|
127
|
+
| [valid-peerDependenciesMeta](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-peerDependenciesMeta) | Enforce that the `peerDependenciesMeta` property is valid. | โ
๐ฆ | | |
|
|
128
|
+
| [valid-peerDependenciesMeta-relationship](https://eslint-plugin-package-json.dev/rules/valid-peerDependenciesMeta-relationship) | Enforces that any dependencies declared in `peerDependenciesMeta` are also defined in the package's `peerDependencies`. | โ
๐ฆ | | ๐ก |
|
|
129
|
+
| [valid-private](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-private) | Enforce that the `private` property is valid. | โ
๐ฆ | | |
|
|
130
|
+
| [valid-publishConfig](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-publishConfig) | Enforce that the `publishConfig` property is valid. | โ
๐ฆ | | |
|
|
131
|
+
| [valid-repository](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-repository) | Enforce that the `repository` property is valid. | โ
๐ฆ | | |
|
|
132
|
+
| [valid-repository-directory](https://eslint-plugin-package-json.dev/rules/valid-repository-directory) | Enforce that if repository directory is specified, it matches the path to the package.json file | โ
๐ฆ | | ๐ก |
|
|
133
|
+
| [valid-scripts](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-scripts) | Enforce that the `scripts` property is valid. | โ
๐ฆ | | |
|
|
134
|
+
| [valid-sideEffects](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-sideEffects) | Enforce that the `sideEffects` property is valid. | โ
๐ฆ | | |
|
|
135
|
+
| [valid-type](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-type) | Enforce that the `type` property is valid. | โ
๐ฆ | | |
|
|
136
|
+
| [valid-version](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-version) | Enforce that the `version` property is valid. | โ
๐ฆ | | |
|
|
137
|
+
| [valid-workspaces](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-workspaces) | Enforce that the `workspaces` property is valid. | โ
๐ฆ | | |
|
|
129
138
|
|
|
130
139
|
<!-- end auto-generated rules list -->
|
|
131
|
-
<!-- prettier-ignore-end -->
|
|
132
140
|
|
|
133
141
|
These rules only run on `package.json` files; they will ignore all other files being linted.
|
|
134
142
|
They can lint `package.json` files at project root and in any subfolder of the project, making this plugin great for monorepos.
|
|
@@ -159,10 +167,8 @@ Thanks! ๐
|
|
|
159
167
|
|
|
160
168
|
## Contributors
|
|
161
169
|
|
|
162
|
-
<!-- spellchecker: disable -->
|
|
163
170
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
164
171
|
<!-- prettier-ignore-start -->
|
|
165
|
-
<!-- markdownlint-disable -->
|
|
166
172
|
<table>
|
|
167
173
|
<tbody>
|
|
168
174
|
<tr>
|
|
@@ -222,12 +228,9 @@ Thanks! ๐
|
|
|
222
228
|
</tbody>
|
|
223
229
|
</table>
|
|
224
230
|
|
|
225
|
-
<!-- markdownlint-restore -->
|
|
226
231
|
<!-- prettier-ignore-end -->
|
|
227
|
-
|
|
228
232
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
229
|
-
<!-- spellchecker: enable -->
|
|
230
233
|
|
|
231
|
-
##
|
|
234
|
+
## License
|
|
232
235
|
|
|
233
|
-
|
|
236
|
+
See the [LICENSE](./LICENSE.md) file for license rights and limitations (MIT).
|
package/lib/createRule.d.mts
CHANGED
|
@@ -35,10 +35,11 @@ interface PackageJsonRuleContext<Options extends unknown[] = unknown[]> extends
|
|
|
35
35
|
}
|
|
36
36
|
interface PackageJsonRuleModule<Options extends unknown[] = unknown[], Schema extends JSONSchema[] = JSONSchema[]> {
|
|
37
37
|
create(context: PackageJsonRuleContext<Options>): RuleListener;
|
|
38
|
-
meta: Omit<Rule.RuleMetaData,
|
|
38
|
+
meta: Omit<Rule.RuleMetaData, 'defaultOptions' | 'docs' | 'schema'> & {
|
|
39
39
|
defaultOptions?: NoInfer<Options>;
|
|
40
|
-
docs?: Rule.RuleMetaData[
|
|
41
|
-
category?: string;
|
|
40
|
+
docs?: Rule.RuleMetaData['docs'] & {
|
|
41
|
+
category?: string; /** An optional route segment to group this rule under */
|
|
42
|
+
ruleGroup?: string;
|
|
42
43
|
};
|
|
43
44
|
schema?: Schema;
|
|
44
45
|
};
|
package/lib/createRule.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { isPackageJson } from "./utils/isPackageJson.mjs";
|
|
|
5
5
|
* If you're not satisfied with the inferred type, you may specify it manually in the first type parameter.
|
|
6
6
|
*/
|
|
7
7
|
function createRule(rule) {
|
|
8
|
+
const ruleGroup = rule.meta.docs?.ruleGroup;
|
|
8
9
|
return {
|
|
9
10
|
create(context) {
|
|
10
11
|
if (!isPackageJson(context.filename)) return {};
|
|
@@ -14,7 +15,7 @@ function createRule(rule) {
|
|
|
14
15
|
...rule.meta,
|
|
15
16
|
docs: {
|
|
16
17
|
...rule.meta.docs,
|
|
17
|
-
url: `https://
|
|
18
|
+
url: `https://eslint-plugin-package-json.dev/rules/${ruleGroup ? `${ruleGroup}/` : ""}${rule.name}`
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
};
|
package/lib/index.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { JSONSchema } from "./node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/definitions/jsonSchema.mjs";
|
|
2
2
|
import { PackageJsonPluginSettings, PackageJsonRuleModule } from "./createRule.mjs";
|
|
3
3
|
import { plugin } from "./plugin.mjs";
|
|
4
|
-
import * as jsonc_eslint_parser0 from "jsonc-eslint-parser";
|
|
5
|
-
import * as eslint from "eslint";
|
|
6
4
|
|
|
7
5
|
//#region src/index.d.ts
|
|
8
6
|
declare const rules: Record<string, PackageJsonRuleModule<unknown[], JSONSchema[]>>;
|
|
@@ -10,24 +8,24 @@ declare const configs: {
|
|
|
10
8
|
recommended: {
|
|
11
9
|
files: string[];
|
|
12
10
|
languageOptions: {
|
|
13
|
-
parser: typeof
|
|
11
|
+
parser: typeof import("jsonc-eslint-parser");
|
|
14
12
|
};
|
|
15
13
|
name: string;
|
|
16
14
|
plugins: {
|
|
17
|
-
readonly
|
|
15
|
+
readonly 'package-json': import("eslint").ESLint.Plugin;
|
|
18
16
|
};
|
|
19
17
|
rules: {
|
|
20
18
|
[k: string]: "error";
|
|
21
19
|
};
|
|
22
20
|
};
|
|
23
|
-
|
|
21
|
+
'recommended-publishable': {
|
|
24
22
|
files: string[];
|
|
25
23
|
languageOptions: {
|
|
26
|
-
parser: typeof
|
|
24
|
+
parser: typeof import("jsonc-eslint-parser");
|
|
27
25
|
};
|
|
28
26
|
name: string;
|
|
29
27
|
plugins: {
|
|
30
|
-
readonly
|
|
28
|
+
readonly 'package-json': import("eslint").ESLint.Plugin;
|
|
31
29
|
};
|
|
32
30
|
rules: {
|
|
33
31
|
[x: string]: "error";
|
|
@@ -36,11 +34,11 @@ declare const configs: {
|
|
|
36
34
|
stylistic: {
|
|
37
35
|
files: string[];
|
|
38
36
|
languageOptions: {
|
|
39
|
-
parser: typeof
|
|
37
|
+
parser: typeof import("jsonc-eslint-parser");
|
|
40
38
|
};
|
|
41
39
|
name: string;
|
|
42
40
|
plugins: {
|
|
43
|
-
readonly
|
|
41
|
+
readonly 'package-json': import("eslint").ESLint.Plugin;
|
|
44
42
|
};
|
|
45
43
|
rules: {
|
|
46
44
|
[k: string]: "error";
|
package/lib/plugin.d.mts
CHANGED
|
@@ -13,20 +13,20 @@ declare const plugin: {
|
|
|
13
13
|
};
|
|
14
14
|
name: string;
|
|
15
15
|
plugins: {
|
|
16
|
-
readonly
|
|
16
|
+
readonly 'package-json': ESLint.Plugin;
|
|
17
17
|
};
|
|
18
18
|
rules: {
|
|
19
19
|
[k: string]: "error";
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
'recommended-publishable': {
|
|
23
23
|
files: string[];
|
|
24
24
|
languageOptions: {
|
|
25
25
|
parser: typeof parserJsonc;
|
|
26
26
|
};
|
|
27
27
|
name: string;
|
|
28
28
|
plugins: {
|
|
29
|
-
readonly
|
|
29
|
+
readonly 'package-json': ESLint.Plugin;
|
|
30
30
|
};
|
|
31
31
|
rules: {
|
|
32
32
|
[x: string]: "error";
|
|
@@ -39,7 +39,7 @@ declare const plugin: {
|
|
|
39
39
|
};
|
|
40
40
|
name: string;
|
|
41
41
|
plugins: {
|
|
42
|
-
readonly
|
|
42
|
+
readonly 'package-json': ESLint.Plugin;
|
|
43
43
|
};
|
|
44
44
|
rules: {
|
|
45
45
|
[k: string]: "error";
|
package/lib/plugin.mjs
CHANGED
|
@@ -14,11 +14,9 @@ import { rule as rule$11 } from "./rules/scripts-name-casing.mjs";
|
|
|
14
14
|
import { rule as rule$12 } from "./rules/sort-collections.mjs";
|
|
15
15
|
import { rule as rule$13 } from "./rules/specify-peers-locally.mjs";
|
|
16
16
|
import { rule as rule$14 } from "./rules/unique-dependencies.mjs";
|
|
17
|
-
import { rule as rule$15 } from "./rules/valid-
|
|
18
|
-
import { rule as rule$16 } from "./rules/valid-peerDependenciesMeta-relationship.mjs";
|
|
17
|
+
import { rule as rule$15 } from "./rules/valid-peerDependenciesMeta-relationship.mjs";
|
|
19
18
|
import { rules as rules$2 } from "./rules/valid-properties.mjs";
|
|
20
|
-
import { rule as rule$
|
|
21
|
-
import { rule as rule$18 } from "./rules/valid-version.mjs";
|
|
19
|
+
import { rule as rule$16 } from "./rules/valid-repository-directory.mjs";
|
|
22
20
|
import { createRequire } from "node:module";
|
|
23
21
|
import * as parserJsonc from "jsonc-eslint-parser";
|
|
24
22
|
//#region src/plugin.ts
|
|
@@ -41,10 +39,8 @@ const rules = {
|
|
|
41
39
|
"specify-peers-locally": rule$13,
|
|
42
40
|
"unique-dependencies": rule$14,
|
|
43
41
|
...rules$2,
|
|
44
|
-
"valid-
|
|
45
|
-
"valid-
|
|
46
|
-
"valid-repository-directory": rule$17,
|
|
47
|
-
"valid-version": rule$18
|
|
42
|
+
"valid-peerDependenciesMeta-relationship": rule$15,
|
|
43
|
+
"valid-repository-directory": rule$16
|
|
48
44
|
};
|
|
49
45
|
const recommendedRules = { ...Object.fromEntries(Object.entries(rules).filter(([, rule]) => rule.meta.docs?.recommended).map(([name]) => ["package-json/" + name, "error"])) };
|
|
50
46
|
const recommendedPublishableRules = {
|
|
@@ -23,7 +23,7 @@ const rule = createRule({
|
|
|
23
23
|
"Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=private]"(node) {
|
|
24
24
|
if (node.value.type === "JSONLiteral" && node.value.value === true) isPrivatePackage = true;
|
|
25
25
|
},
|
|
26
|
-
"Program:exit"(
|
|
26
|
+
"Program:exit"() {
|
|
27
27
|
if (ignorePrivate && isPrivatePackage) return;
|
|
28
28
|
if (preferContributorsOnly) {
|
|
29
29
|
if (authorPropertyNode) context.report({
|
|
@@ -35,12 +35,18 @@ const rule = createRule({
|
|
|
35
35
|
}]
|
|
36
36
|
});
|
|
37
37
|
if (!contributorsPropertyNode) context.report({
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
loc: {
|
|
39
|
+
column: 0,
|
|
40
|
+
line: 1
|
|
41
|
+
},
|
|
42
|
+
messageId: "missingContributor"
|
|
40
43
|
});
|
|
41
44
|
} else if (!authorPropertyNode && !contributorsPropertyNode) context.report({
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
loc: {
|
|
46
|
+
column: 0,
|
|
47
|
+
line: 1
|
|
48
|
+
},
|
|
49
|
+
messageId: "missing"
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
};
|
|
@@ -3,8 +3,10 @@ import { createSimpleRequirePropertyRule } from "../utils/createSimpleRequirePro
|
|
|
3
3
|
const propertyConfig = [
|
|
4
4
|
["author"],
|
|
5
5
|
["bin"],
|
|
6
|
+
["browser"],
|
|
6
7
|
["bugs", { ignorePrivateDefault: true }],
|
|
7
8
|
["bundleDependencies"],
|
|
9
|
+
["config"],
|
|
8
10
|
["contributors"],
|
|
9
11
|
["cpu"],
|
|
10
12
|
["dependencies"],
|
|
@@ -22,8 +24,10 @@ const propertyConfig = [
|
|
|
22
24
|
isRecommended: true
|
|
23
25
|
}],
|
|
24
26
|
["funding"],
|
|
27
|
+
["gypfile"],
|
|
25
28
|
["homepage", { ignorePrivateDefault: true }],
|
|
26
29
|
["keywords", { ignorePrivateDefault: true }],
|
|
30
|
+
["libc"],
|
|
27
31
|
["license", {
|
|
28
32
|
ignorePrivateDefault: true,
|
|
29
33
|
isRecommended: true
|
|
@@ -39,6 +43,7 @@ const propertyConfig = [
|
|
|
39
43
|
["os"],
|
|
40
44
|
["packageManager"],
|
|
41
45
|
["peerDependencies"],
|
|
46
|
+
["peerDependenciesMeta"],
|
|
42
47
|
["private", { fixValue: false }],
|
|
43
48
|
["publishConfig", { ignorePrivateDefault: true }],
|
|
44
49
|
["repository", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.mjs";
|
|
2
|
-
import { validateAuthor, validateBin, validateBrowser, validateBugs, validateBundleDependencies, validateConfig, validateContributors, validateCpu, validateDependencies, validateDescription, validateDevEngines, validateDirectories, validateEngines, validateExports, validateFiles, validateFunding, validateGypfile, validateHomepage, validateKeywords, validateLibc, validateLicense, validateMain, validateMan, validateOs, validatePackageManager, validatePeerDependenciesMeta, validatePrivate, validatePublishConfig, validateRepository, validateScripts, validateSideEffects, validateType, validateWorkspaces } from "package-json-validator";
|
|
3
|
-
|
|
4
|
-
const
|
|
2
|
+
import { validateAuthor, validateBin, validateBrowser, validateBugs, validateBundleDependencies, validateConfig, validateContributors, validateCpu, validateDependencies, validateDescription, validateDevEngines, validateDirectories, validateEngines, validateExports, validateFiles, validateFunding, validateGypfile, validateHomepage, validateKeywords, validateLibc, validateLicense, validateMain, validateMan, validateName, validateOs, validatePackageManager, validatePeerDependenciesMeta, validatePrivate, validatePublishConfig, validateRepository, validateScripts, validateSideEffects, validateType, validateVersion, validateWorkspaces } from "package-json-validator";
|
|
3
|
+
/** All basic valid- flavor rules */
|
|
4
|
+
const rules = Object.fromEntries([
|
|
5
5
|
["author", validateAuthor],
|
|
6
6
|
["bin", validateBin],
|
|
7
7
|
["browser", validateBrowser],
|
|
@@ -30,6 +30,7 @@ const properties = [
|
|
|
30
30
|
["main", validateMain],
|
|
31
31
|
["man", validateMan],
|
|
32
32
|
["module", validateMain],
|
|
33
|
+
["name", validateName],
|
|
33
34
|
["optionalDependencies", validateDependencies],
|
|
34
35
|
["os", validateOs],
|
|
35
36
|
["packageManager", validatePackageManager],
|
|
@@ -41,10 +42,9 @@ const properties = [
|
|
|
41
42
|
["scripts", validateScripts],
|
|
42
43
|
["sideEffects", validateSideEffects],
|
|
43
44
|
["type", validateType],
|
|
45
|
+
["version", validateVersion],
|
|
44
46
|
["workspaces", validateWorkspaces]
|
|
45
|
-
]
|
|
46
|
-
/** All basic valid- flavor rules */
|
|
47
|
-
const rules = Object.fromEntries(properties.map(([propertyName, validationFunctionOrOptions]) => {
|
|
47
|
+
].map(([propertyName, validationFunctionOrOptions]) => {
|
|
48
48
|
let validationFunction;
|
|
49
49
|
let aliases = [];
|
|
50
50
|
if (typeof validationFunctionOrOptions === "object") {
|
package/lib/types/estree.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ interface CreateRequirePropertyRuleOptions {
|
|
|
5
5
|
/**
|
|
6
6
|
* The category for this rule.
|
|
7
7
|
*/
|
|
8
|
-
category?:
|
|
8
|
+
category?: 'Publishable' | (string & {});
|
|
9
9
|
/** The value to use when fixing a violation when this property is missing */
|
|
10
10
|
fixValue?: unknown;
|
|
11
11
|
/**
|
|
@@ -22,8 +22,11 @@ const createSimpleRequirePropertyRule = (propertyName, { category, fixValue, ign
|
|
|
22
22
|
yield fixer.insertTextAfterRange([0, 1], `\n "${propertyName}": ${JSON.stringify(fixValue)}`);
|
|
23
23
|
yield node.properties.length > 0 ? fixer.insertTextAfterRange([0, 1], ",") : fixer.insertTextAfterRange([0, 1], "\n");
|
|
24
24
|
},
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
loc: {
|
|
26
|
+
column: 0,
|
|
27
|
+
line: 1
|
|
28
|
+
},
|
|
29
|
+
messageId: "missing"
|
|
27
30
|
});
|
|
28
31
|
} };
|
|
29
32
|
},
|
|
@@ -31,7 +34,8 @@ const createSimpleRequirePropertyRule = (propertyName, { category, fixValue, ign
|
|
|
31
34
|
docs: {
|
|
32
35
|
category,
|
|
33
36
|
description: `Requires the \`${propertyName}\` property to be present.`,
|
|
34
|
-
recommended: isRecommended
|
|
37
|
+
recommended: isRecommended,
|
|
38
|
+
ruleGroup: "require-properties"
|
|
35
39
|
},
|
|
36
40
|
fixable: fixValue === void 0 ? void 0 : "code",
|
|
37
41
|
messages: { missing: "Property '{{property}}' is required." },
|
|
@@ -40,8 +40,9 @@ const createSimpleValidPropertyRule = (propertyName, validationFunction, aliases
|
|
|
40
40
|
meta: {
|
|
41
41
|
docs: {
|
|
42
42
|
category: "Best Practices",
|
|
43
|
-
description: `Enforce that the \`${propertyName}\`${aliases.length ? ` (also
|
|
44
|
-
recommended: true
|
|
43
|
+
description: `Enforce that the \`${propertyName}\`${aliases.length ? ` (also ${aliases.map((alias) => `\`${alias}\``).join(", ")})` : ""} property is valid.`,
|
|
44
|
+
recommended: true,
|
|
45
|
+
ruleGroup: "valid-properties"
|
|
45
46
|
},
|
|
46
47
|
messages: { validationError: `Invalid ${propertyName}: {{ error }}` },
|
|
47
48
|
schema: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
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": {
|
|
@@ -40,9 +40,6 @@
|
|
|
40
40
|
"CHANGELOG.md",
|
|
41
41
|
"lib/"
|
|
42
42
|
],
|
|
43
|
-
"lint-staged": {
|
|
44
|
-
"*": "prettier --ignore-unknown --write"
|
|
45
|
-
},
|
|
46
43
|
"dependencies": {
|
|
47
44
|
"@altano/repository-tools": "^2.0.1",
|
|
48
45
|
"change-case": "^5.4.4",
|
|
@@ -53,11 +50,10 @@
|
|
|
53
50
|
"package-json-validator": "^1.5.0",
|
|
54
51
|
"semver": "^7.7.3",
|
|
55
52
|
"sort-object-keys": "^2.0.0",
|
|
56
|
-
"sort-package-json": "^3.4.0"
|
|
57
|
-
"validate-npm-package-name": "^7.0.0"
|
|
53
|
+
"sort-package-json": "^3.4.0"
|
|
58
54
|
},
|
|
59
55
|
"devDependencies": {
|
|
60
|
-
"@astrojs/starlight": "0.
|
|
56
|
+
"@astrojs/starlight": "0.39.0",
|
|
61
57
|
"@catppuccin/starlight": "2.0.1",
|
|
62
58
|
"@eslint-community/eslint-plugin-eslint-comments": "4.7.0",
|
|
63
59
|
"@eslint/js": "10.0.1",
|
|
@@ -65,34 +61,36 @@
|
|
|
65
61
|
"@types/estree": "1.0.8",
|
|
66
62
|
"@types/node": "24.12.0",
|
|
67
63
|
"@types/semver": "7.7.1",
|
|
68
|
-
"@types/validate-npm-package-name": "4.0.2",
|
|
69
64
|
"@vitest/coverage-v8": "4.1.0",
|
|
70
65
|
"@vitest/eslint-plugin": "1.6.1",
|
|
71
|
-
"astro": "6.
|
|
66
|
+
"astro": "6.3.0",
|
|
67
|
+
"astro-og-canvas": "0.11.1",
|
|
68
|
+
"canvaskit-wasm": "0.41.1",
|
|
72
69
|
"console-fail-test": "0.6.0",
|
|
73
|
-
"eslint": "10.
|
|
70
|
+
"eslint": "10.4.0",
|
|
74
71
|
"eslint-doc-generator": "3.3.1",
|
|
75
72
|
"eslint-plugin-eslint-plugin": "7.3.1",
|
|
76
73
|
"eslint-plugin-jsdoc": "62.9.0",
|
|
77
74
|
"eslint-plugin-jsonc": "3.1.0",
|
|
78
|
-
"eslint-plugin-n": "
|
|
75
|
+
"eslint-plugin-n": "18.0.0",
|
|
79
76
|
"eslint-plugin-node-dependencies": "2.2.0",
|
|
80
77
|
"eslint-plugin-perfectionist": "5.9.0",
|
|
81
78
|
"eslint-plugin-regexp": "3.1.0",
|
|
82
79
|
"eslint-plugin-unicorn": "64.0.0",
|
|
83
80
|
"eslint-plugin-yml": "3.3.0",
|
|
84
|
-
"
|
|
85
|
-
"jiti": "2.6.1",
|
|
81
|
+
"jiti": "2.7.0",
|
|
86
82
|
"json-schema-to-ts": "3.1.1",
|
|
87
|
-
"knip": "6.
|
|
88
|
-
"lint-staged": "16.4.0",
|
|
83
|
+
"knip": "6.14.0",
|
|
89
84
|
"prettier": "3.8.0",
|
|
90
85
|
"prettier-plugin-curly": "0.4.0",
|
|
91
86
|
"prettier-plugin-packagejson": "3.0.0",
|
|
92
87
|
"prettier-plugin-sentences-per-line": "0.2.3",
|
|
93
88
|
"prettier-plugin-sh": "0.18.0",
|
|
89
|
+
"pretty-quick": "4.2.2",
|
|
94
90
|
"sharp": "0.34.5",
|
|
95
|
-
"
|
|
91
|
+
"simple-git-hooks": "2.13.1",
|
|
92
|
+
"starlight-auto-sidebar": "0.4.0",
|
|
93
|
+
"tsdown": "0.22.0",
|
|
96
94
|
"typescript": "6.0.2",
|
|
97
95
|
"typescript-eslint": "8.59.0",
|
|
98
96
|
"vitest": "4.1.0"
|
|
@@ -101,7 +99,7 @@
|
|
|
101
99
|
"eslint": ">=9.0.0"
|
|
102
100
|
},
|
|
103
101
|
"engines": {
|
|
104
|
-
"node": "^22.
|
|
102
|
+
"node": "^22.22.2 || >=24.15.0"
|
|
105
103
|
},
|
|
106
104
|
"scripts": {
|
|
107
105
|
"build": "tsdown",
|
package/lib/rules/valid-name.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { createRule } from "../createRule.mjs";
|
|
2
|
-
import validate from "validate-npm-package-name";
|
|
3
|
-
//#region src/rules/valid-name.ts
|
|
4
|
-
const rule = createRule({
|
|
5
|
-
create(context) {
|
|
6
|
-
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=name]"(node) {
|
|
7
|
-
if (node.value.type !== "JSONLiteral" || typeof node.value.value !== "string") {
|
|
8
|
-
context.report({
|
|
9
|
-
messageId: "type",
|
|
10
|
-
node: node.value
|
|
11
|
-
});
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const privateField = node.parent.properties.find((p) => p.key.type === "JSONLiteral" && p.key.value === "private");
|
|
15
|
-
if (privateField?.value.type === "JSONLiteral" && (privateField.value.value === true || privateField.value.value === "true")) return;
|
|
16
|
-
const { errors, warnings } = validate(node.value.value);
|
|
17
|
-
const complaints = [...errors ?? [], ...warnings ?? []];
|
|
18
|
-
if (!complaints.length) return;
|
|
19
|
-
context.report({
|
|
20
|
-
data: { complaints: complaints.map((error) => error.slice(0, Math.max(0, error.length))).join("; ") },
|
|
21
|
-
messageId: "invalid",
|
|
22
|
-
node: node.value
|
|
23
|
-
});
|
|
24
|
-
} };
|
|
25
|
-
},
|
|
26
|
-
meta: {
|
|
27
|
-
docs: {
|
|
28
|
-
category: "Best Practices",
|
|
29
|
-
description: "Enforce that package names are valid npm package names",
|
|
30
|
-
recommended: true
|
|
31
|
-
},
|
|
32
|
-
messages: {
|
|
33
|
-
invalid: "Invalid npm package name: {{ complaints }}.",
|
|
34
|
-
type: "\"name\" should be a string."
|
|
35
|
-
},
|
|
36
|
-
schema: [],
|
|
37
|
-
type: "problem"
|
|
38
|
-
},
|
|
39
|
-
name: "valid-name"
|
|
40
|
-
});
|
|
41
|
-
//#endregion
|
|
42
|
-
export { rule };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createRule } from "../createRule.mjs";
|
|
2
|
-
import semver from "semver";
|
|
3
|
-
//#region src/rules/valid-version.ts
|
|
4
|
-
const rule = createRule({
|
|
5
|
-
create(context) {
|
|
6
|
-
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=version]"(node) {
|
|
7
|
-
if (node.value.type !== "JSONLiteral" || typeof node.value.value !== "string") {
|
|
8
|
-
context.report({
|
|
9
|
-
messageId: "type",
|
|
10
|
-
node: node.value
|
|
11
|
-
});
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (!semver.valid(node.value.value)) context.report({
|
|
15
|
-
messageId: "invalid",
|
|
16
|
-
node: node.value
|
|
17
|
-
});
|
|
18
|
-
} };
|
|
19
|
-
},
|
|
20
|
-
meta: {
|
|
21
|
-
docs: {
|
|
22
|
-
category: "Best Practices",
|
|
23
|
-
description: "Enforce that package versions are valid semver specifiers",
|
|
24
|
-
recommended: true
|
|
25
|
-
},
|
|
26
|
-
messages: {
|
|
27
|
-
invalid: "Version is not a valid semver specifier.",
|
|
28
|
-
type: "\"version\" should be a string."
|
|
29
|
-
},
|
|
30
|
-
schema: [],
|
|
31
|
-
type: "problem"
|
|
32
|
-
},
|
|
33
|
-
name: "valid-version"
|
|
34
|
-
});
|
|
35
|
-
//#endregion
|
|
36
|
-
export { rule };
|