eslint-plugin-package-json 0.56.1 β†’ 0.56.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,23 @@
1
1
  # Changelog
2
2
 
3
- ## [0.56.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.56.0...v0.56.1) (2025-08-31)
3
+ ## [0.56.3](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.56.2...v0.56.3) (2025-09-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **plugin:** update types to be compatible with `defineConfig` ([#1245](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1245)) ([861e5e1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/861e5e129b3a5e3455b6b2a2a26d453086f20c14)), closes [#1242](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1242)
4
9
 
10
+ ## [0.56.2](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.56.1...v0.56.2) (2025-09-04)
11
+
12
+ ### Bug Fixes
13
+
14
+ - improve sort-collections docs and error messages ([#1250](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1250)) ([1864376](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/1864376039db3db690423051b0dd8a2104395aa4)), closes [#1243](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1243) [#1243](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1243)
15
+
16
+ ## [0.56.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.56.0...v0.56.1) (2025-08-31)
5
17
 
6
18
  ### Bug Fixes
7
19
 
8
- * **deps:** update dependency package-json-validator to ~0.30.0 ([#1241](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1241)) ([c3d247c](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/c3d247cc416d4bb0eee629fde3440224fe39eb59))
20
+ - **deps:** update dependency package-json-validator to ~0.30.0 ([#1241](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1241)) ([c3d247c](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/c3d247cc416d4bb0eee629fde3440224fe39eb59))
9
21
 
10
22
  # [0.56.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.55.0...v0.56.0) (2025-08-25)
11
23
 
package/README.md CHANGED
@@ -153,50 +153,50 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
153
153
  πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\
154
154
  ❌ Deprecated.
155
155
 
156
- | NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | πŸ”§ | πŸ’‘ | ❌ |
157
- | :------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------ | :--- | :- | :- | :- |
158
- | [no-empty-fields](docs/rules/no-empty-fields.md) | Reports on unnecessary empty arrays and objects. | βœ”οΈ βœ… | | πŸ’‘ | |
159
- | [no-redundant-files](docs/rules/no-redundant-files.md) | Prevents adding unnecessary / redundant files. | βœ”οΈ βœ… | | πŸ’‘ | |
160
- | [order-properties](docs/rules/order-properties.md) | Package properties must be declared in standard order | βœ”οΈ βœ… | πŸ”§ | | |
161
- | [repository-shorthand](docs/rules/repository-shorthand.md) | Enforce either object or shorthand declaration for repository. | βœ”οΈ βœ… | πŸ”§ | | |
162
- | [require-author](docs/rules/require-author.md) | Requires the `author` property to be present. | | | | |
163
- | [require-bugs](docs/rules/require-bugs.md) | Requires the `bugs` property to be present. | | | | |
164
- | [require-bundleDependencies](docs/rules/require-bundleDependencies.md) | Requires the `bundleDependencies` property to be present. | | | | |
165
- | [require-dependencies](docs/rules/require-dependencies.md) | Requires the `dependencies` property to be present. | | | | |
166
- | [require-description](docs/rules/require-description.md) | Requires the `description` property to be present. | βœ”οΈ βœ… | | | |
167
- | [require-devDependencies](docs/rules/require-devDependencies.md) | Requires the `devDependencies` property to be present. | | | | |
168
- | [require-engines](docs/rules/require-engines.md) | Requires the `engines` property to be present. | | | | |
169
- | [require-files](docs/rules/require-files.md) | Requires the `files` property to be present. | | | | |
170
- | [require-keywords](docs/rules/require-keywords.md) | Requires the `keywords` property to be present. | | | | |
171
- | [require-name](docs/rules/require-name.md) | Requires the `name` property to be present. | βœ”οΈ βœ… | | | |
172
- | [require-optionalDependencies](docs/rules/require-optionalDependencies.md) | Requires the `optionalDependencies` property to be present. | | | | |
173
- | [require-peerDependencies](docs/rules/require-peerDependencies.md) | Requires the `peerDependencies` property to be present. | | | | |
174
- | [require-type](docs/rules/require-type.md) | Requires the `type` property to be present. | βœ”οΈ βœ… | | | |
175
- | [require-types](docs/rules/require-types.md) | Requires the `types` property to be present. | | | | |
176
- | [require-version](docs/rules/require-version.md) | Requires the `version` property to be present. | βœ”οΈ βœ… | | | |
177
- | [restrict-dependency-ranges](docs/rules/restrict-dependency-ranges.md) | Restricts the range of dependencies to allow or disallow specific types of ranges. | | | πŸ’‘ | |
178
- | [sort-collections](docs/rules/sort-collections.md) | Dependencies, scripts, and configuration values must be declared in alphabetical order. | βœ”οΈ βœ… | πŸ”§ | | |
179
- | [unique-dependencies](docs/rules/unique-dependencies.md) | Checks a dependency isn't specified more than once (i.e. in `dependencies` and `devDependencies`) | βœ”οΈ βœ… | | πŸ’‘ | |
180
- | [valid-author](docs/rules/valid-author.md) | Enforce that the `author` property is valid. | βœ”οΈ βœ… | | | |
181
- | [valid-bin](docs/rules/valid-bin.md) | Enforce that the `bin` property is valid. | βœ”οΈ βœ… | | πŸ’‘ | |
182
- | [valid-bundleDependencies](docs/rules/valid-bundleDependencies.md) | Enforce that the `bundleDependencies` (also: `bundledDependencies`) property is valid. | βœ”οΈ βœ… | | | |
183
- | [valid-config](docs/rules/valid-config.md) | Enforce that the `config` property is valid. | βœ”οΈ βœ… | | | |
184
- | [valid-cpu](docs/rules/valid-cpu.md) | Enforce that the `cpu` property is valid. | βœ”οΈ βœ… | | | |
185
- | [valid-dependencies](docs/rules/valid-dependencies.md) | Enforce that the `dependencies` property is valid. | βœ”οΈ βœ… | | | |
186
- | [valid-description](docs/rules/valid-description.md) | Enforce that the `description` property is valid. | βœ”οΈ βœ… | | | |
187
- | [valid-devDependencies](docs/rules/valid-devDependencies.md) | Enforce that the `devDependencies` property is valid. | βœ”οΈ βœ… | | | |
188
- | [valid-directories](docs/rules/valid-directories.md) | Enforce that the `directories` property is valid. | βœ”οΈ βœ… | | | |
189
- | [valid-exports](docs/rules/valid-exports.md) | Enforce that the `exports` property is valid. | βœ”οΈ βœ… | | | |
190
- | [valid-license](docs/rules/valid-license.md) | Enforce that the `license` property is valid. | βœ”οΈ βœ… | | | |
191
- | [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json | | | | ❌ |
192
- | [valid-name](docs/rules/valid-name.md) | Enforce that package names are valid npm package names | βœ”οΈ βœ… | | | |
193
- | [valid-optionalDependencies](docs/rules/valid-optionalDependencies.md) | Enforce that the `optionalDependencies` property is valid. | βœ”οΈ βœ… | | | |
194
- | [valid-package-definition](docs/rules/valid-package-definition.md) | Enforce that package.json has all properties required by the npm spec | βœ”οΈ βœ… | | | |
195
- | [valid-peerDependencies](docs/rules/valid-peerDependencies.md) | Enforce that the `peerDependencies` property is valid. | βœ”οΈ βœ… | | | |
196
- | [valid-repository-directory](docs/rules/valid-repository-directory.md) | Enforce that if repository directory is specified, it matches the path to the package.json file | βœ”οΈ βœ… | | πŸ’‘ | |
197
- | [valid-scripts](docs/rules/valid-scripts.md) | Enforce that the `scripts` property is valid. | βœ”οΈ βœ… | | | |
198
- | [valid-type](docs/rules/valid-type.md) | Enforce that the `type` property is valid. | βœ”οΈ βœ… | | | |
199
- | [valid-version](docs/rules/valid-version.md) | Enforce that package versions are valid semver specifiers | βœ”οΈ βœ… | | | |
156
+ | NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | πŸ”§ | πŸ’‘ | ❌ |
157
+ | :------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------- | :--- | :- | :- | :- |
158
+ | [no-empty-fields](docs/rules/no-empty-fields.md) | Reports on unnecessary empty arrays and objects. | βœ”οΈ βœ… | | πŸ’‘ | |
159
+ | [no-redundant-files](docs/rules/no-redundant-files.md) | Prevents adding unnecessary / redundant files. | βœ”οΈ βœ… | | πŸ’‘ | |
160
+ | [order-properties](docs/rules/order-properties.md) | Package properties must be declared in standard order | βœ”οΈ βœ… | πŸ”§ | | |
161
+ | [repository-shorthand](docs/rules/repository-shorthand.md) | Enforce either object or shorthand declaration for repository. | βœ”οΈ βœ… | πŸ”§ | | |
162
+ | [require-author](docs/rules/require-author.md) | Requires the `author` property to be present. | | | | |
163
+ | [require-bugs](docs/rules/require-bugs.md) | Requires the `bugs` property to be present. | | | | |
164
+ | [require-bundleDependencies](docs/rules/require-bundleDependencies.md) | Requires the `bundleDependencies` property to be present. | | | | |
165
+ | [require-dependencies](docs/rules/require-dependencies.md) | Requires the `dependencies` property to be present. | | | | |
166
+ | [require-description](docs/rules/require-description.md) | Requires the `description` property to be present. | βœ”οΈ βœ… | | | |
167
+ | [require-devDependencies](docs/rules/require-devDependencies.md) | Requires the `devDependencies` property to be present. | | | | |
168
+ | [require-engines](docs/rules/require-engines.md) | Requires the `engines` property to be present. | | | | |
169
+ | [require-files](docs/rules/require-files.md) | Requires the `files` property to be present. | | | | |
170
+ | [require-keywords](docs/rules/require-keywords.md) | Requires the `keywords` property to be present. | | | | |
171
+ | [require-name](docs/rules/require-name.md) | Requires the `name` property to be present. | βœ”οΈ βœ… | | | |
172
+ | [require-optionalDependencies](docs/rules/require-optionalDependencies.md) | Requires the `optionalDependencies` property to be present. | | | | |
173
+ | [require-peerDependencies](docs/rules/require-peerDependencies.md) | Requires the `peerDependencies` property to be present. | | | | |
174
+ | [require-type](docs/rules/require-type.md) | Requires the `type` property to be present. | βœ”οΈ βœ… | | | |
175
+ | [require-types](docs/rules/require-types.md) | Requires the `types` property to be present. | | | | |
176
+ | [require-version](docs/rules/require-version.md) | Requires the `version` property to be present. | βœ”οΈ βœ… | | | |
177
+ | [restrict-dependency-ranges](docs/rules/restrict-dependency-ranges.md) | Restricts the range of dependencies to allow or disallow specific types of ranges. | | | πŸ’‘ | |
178
+ | [sort-collections](docs/rules/sort-collections.md) | Selected collections must be in a consistent order (lexicographical for most; lifecycle-aware for scripts). | βœ”οΈ βœ… | πŸ”§ | | |
179
+ | [unique-dependencies](docs/rules/unique-dependencies.md) | Checks a dependency isn't specified more than once (i.e. in `dependencies` and `devDependencies`) | βœ”οΈ βœ… | | πŸ’‘ | |
180
+ | [valid-author](docs/rules/valid-author.md) | Enforce that the `author` property is valid. | βœ”οΈ βœ… | | | |
181
+ | [valid-bin](docs/rules/valid-bin.md) | Enforce that the `bin` property is valid. | βœ”οΈ βœ… | | πŸ’‘ | |
182
+ | [valid-bundleDependencies](docs/rules/valid-bundleDependencies.md) | Enforce that the `bundleDependencies` (also: `bundledDependencies`) property is valid. | βœ”οΈ βœ… | | | |
183
+ | [valid-config](docs/rules/valid-config.md) | Enforce that the `config` property is valid. | βœ”οΈ βœ… | | | |
184
+ | [valid-cpu](docs/rules/valid-cpu.md) | Enforce that the `cpu` property is valid. | βœ”οΈ βœ… | | | |
185
+ | [valid-dependencies](docs/rules/valid-dependencies.md) | Enforce that the `dependencies` property is valid. | βœ”οΈ βœ… | | | |
186
+ | [valid-description](docs/rules/valid-description.md) | Enforce that the `description` property is valid. | βœ”οΈ βœ… | | | |
187
+ | [valid-devDependencies](docs/rules/valid-devDependencies.md) | Enforce that the `devDependencies` property is valid. | βœ”οΈ βœ… | | | |
188
+ | [valid-directories](docs/rules/valid-directories.md) | Enforce that the `directories` property is valid. | βœ”οΈ βœ… | | | |
189
+ | [valid-exports](docs/rules/valid-exports.md) | Enforce that the `exports` property is valid. | βœ”οΈ βœ… | | | |
190
+ | [valid-license](docs/rules/valid-license.md) | Enforce that the `license` property is valid. | βœ”οΈ βœ… | | | |
191
+ | [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json | | | | ❌ |
192
+ | [valid-name](docs/rules/valid-name.md) | Enforce that package names are valid npm package names | βœ”οΈ βœ… | | | |
193
+ | [valid-optionalDependencies](docs/rules/valid-optionalDependencies.md) | Enforce that the `optionalDependencies` property is valid. | βœ”οΈ βœ… | | | |
194
+ | [valid-package-definition](docs/rules/valid-package-definition.md) | Enforce that package.json has all properties required by the npm spec | βœ”οΈ βœ… | | | |
195
+ | [valid-peerDependencies](docs/rules/valid-peerDependencies.md) | Enforce that the `peerDependencies` property is valid. | βœ”οΈ βœ… | | | |
196
+ | [valid-repository-directory](docs/rules/valid-repository-directory.md) | Enforce that if repository directory is specified, it matches the path to the package.json file | βœ”οΈ βœ… | | πŸ’‘ | |
197
+ | [valid-scripts](docs/rules/valid-scripts.md) | Enforce that the `scripts` property is valid. | βœ”οΈ βœ… | | | |
198
+ | [valid-type](docs/rules/valid-type.md) | Enforce that the `type` property is valid. | βœ”οΈ βœ… | | | |
199
+ | [valid-version](docs/rules/valid-version.md) | Enforce that package versions are valid semver specifiers | βœ”οΈ βœ… | | | |
200
200
 
201
201
  <!-- end auto-generated rules list -->
202
202
  <!-- prettier-ignore-end -->
@@ -249,7 +249,7 @@ Thanks! πŸ—‚
249
249
  <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>
250
250
  <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>
251
251
  <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>
252
- <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></td>
252
+ <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></td>
253
253
  <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>
254
254
  <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>
255
255
  <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>
@@ -1,4 +1,4 @@
1
- import { AST, RuleListener } from "jsonc-eslint-parser";
1
+ import { AST } from "jsonc-eslint-parser";
2
2
  import * as ESTree from "estree";
3
3
  import { AST as AST$1, Rule, SourceCode } from "eslint";
4
4
 
@@ -32,7 +32,7 @@ interface PackageJsonRuleContext<Options extends unknown[] = unknown[]> extends
32
32
  sourceCode: PackageJsonSourceCode;
33
33
  }
34
34
  interface PackageJsonRuleModule<Options extends unknown[] = unknown[]> {
35
- create(context: PackageJsonRuleContext<Options>): RuleListener;
35
+ create(context: PackageJsonRuleContext<Options>): Rule.NodeListener;
36
36
  meta: Rule.RuleMetaData;
37
37
  }
38
38
  interface PackageJsonSourceCode extends SourceCode {
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PackageJsonPluginSettings, PackageJsonRuleModule } from "./createRule.js";
2
2
  import { plugin } from "./plugin.js";
3
3
  import * as jsonc_eslint_parser0 from "jsonc-eslint-parser";
4
+ import * as eslint0 from "eslint";
4
5
 
5
6
  //#region src/index.d.ts
6
7
  declare const rules: Record<string, PackageJsonRuleModule<unknown[]>>;
@@ -20,14 +21,7 @@ declare const configs: {
20
21
  };
21
22
  name: string;
22
23
  plugins: {
23
- readonly "package-json": {
24
- configs: /*elided*/any;
25
- meta: {
26
- name: string;
27
- version: string;
28
- };
29
- rules: Record<string, PackageJsonRuleModule<unknown[]>>;
30
- };
24
+ readonly "package-json": eslint0.ESLint.Plugin;
31
25
  };
32
26
  rules: {
33
27
  "package-json/valid-package-definition": ["error", {
package/lib/plugin.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { PackageJsonRuleModule } from "./createRule.js";
2
2
  import * as parserJsonc from "jsonc-eslint-parser";
3
+ import { ESLint } from "eslint";
3
4
 
4
5
  //#region src/plugin.d.ts
5
6
  declare const plugin: {
@@ -19,7 +20,7 @@ declare const plugin: {
19
20
  };
20
21
  name: string;
21
22
  plugins: {
22
- readonly "package-json": /*elided*/any;
23
+ readonly "package-json": ESLint.Plugin;
23
24
  };
24
25
  rules: {
25
26
  "package-json/valid-package-definition": ["error", {
package/lib/plugin.js CHANGED
@@ -17,8 +17,7 @@ import { createRequire } from "node:module";
17
17
  import * as parserJsonc from "jsonc-eslint-parser";
18
18
 
19
19
  //#region src/plugin.ts
20
- const require = createRequire(import.meta.url);
21
- const { name, version } = require("../package.json");
20
+ const { name, version } = createRequire(import.meta.url)("../package.json");
22
21
  const rules$2 = {
23
22
  "no-empty-fields": rule,
24
23
  "no-redundant-files": rule$1,
@@ -73,8 +73,7 @@ const rule = createRule({
73
73
  messageId: "unnecessaryBin"
74
74
  }];
75
75
  for (const validation of validations) for (const fileToCheck of validation.files) for (const [index, fileEntry] of files.entries()) if (isNotNullish(fileEntry) && isJSONStringLiteral(fileEntry)) {
76
- const regex = getCachedLocalFileRegex(fileEntry.value);
77
- if (regex?.test(fileToCheck)) report(files, index, validation.messageId);
76
+ if (getCachedLocalFileRegex(fileEntry.value)?.test(fileToCheck)) report(files, index, validation.messageId);
78
77
  }
79
78
  }
80
79
  };
@@ -49,8 +49,7 @@ const rule = createRule({
49
49
  const orderedKeys = Object.keys(orderedSource);
50
50
  const { properties } = ast.body[0].expression;
51
51
  for (let i = 0; i < properties.length; i += 1) {
52
- const property = properties[i].key;
53
- const { value } = property;
52
+ const { value } = properties[i].key;
54
53
  if (value === orderedKeys[i]) continue;
55
54
  context.report({
56
55
  data: { property: value },
@@ -73,8 +73,7 @@ const capitalize = (str) => {
73
73
  const rule = createRule({
74
74
  create(context) {
75
75
  if (!context.options[0]) return {};
76
- const optionsProvided = Array.isArray(context.options[0]) ? [...context.options[0]].reverse() : [context.options[0]];
77
- const optionsArray = optionsProvided.map((option) => ({
76
+ const optionsArray = (Array.isArray(context.options[0]) ? [...context.options[0]].reverse() : [context.options[0]]).map((option) => ({
78
77
  ...option,
79
78
  forPackages: option.forPackages?.map((pattern) => new RegExp(pattern)),
80
79
  rangeTypes: Array.isArray(option.rangeType) ? option.rangeType : [option.rangeType]
@@ -93,8 +92,7 @@ const rule = createRule({
93
92
  for (const options of optionsArray) {
94
93
  if (options.forDependencyTypes && !options.forDependencyTypes.includes(dependencyType)) continue;
95
94
  if (options.forPackages) {
96
- const isMatch = options.forPackages.some((packageNameRegex) => packageNameRegex.test(name));
97
- if (!isMatch) continue;
95
+ if (!options.forPackages.some((packageNameRegex) => packageNameRegex.test(name))) continue;
98
96
  }
99
97
  if (options.forVersions && (/^workspace:[^~*]?$/.test(version) || version !== "*" && !semver.satisfies(version.replace(/(?:workspace:)?[^~]?/, ""), options.forVersions))) continue;
100
98
  const rangeTypes = options.rangeTypes;
@@ -106,14 +104,13 @@ const rule = createRule({
106
104
  });
107
105
  break;
108
106
  }
109
- const rangeTypeMatch = rangeTypes.find((rangeType) => {
107
+ if (!rangeTypes.find((rangeType) => {
110
108
  switch (rangeType) {
111
109
  case "caret": return isCaretRange;
112
110
  case "pin": return isPinned;
113
111
  case "tilde": return isTildeRange;
114
112
  }
115
- });
116
- if (!rangeTypeMatch) context.report({
113
+ })) context.report({
117
114
  data: { rangeTypes: rangeTypes.join(", ") },
118
115
  messageId: "wrongRangeType",
119
116
  node: property.value,
@@ -47,7 +47,7 @@ const rule = createRule({
47
47
  }, {}), null, 2).split("\n").join("\n "));
48
48
  },
49
49
  loc: collection.loc,
50
- messageId: "notAlphabetized",
50
+ messageId: keyPartsReversed.at(-1) === "scripts" ? "unsortedScripts" : "unsortedKeys",
51
51
  node
52
52
  });
53
53
  } };
@@ -56,11 +56,14 @@ const rule = createRule({
56
56
  defaultOptions: [Array.from(defaultCollections)],
57
57
  docs: {
58
58
  category: "Best Practices",
59
- description: "Dependencies, scripts, and configuration values must be declared in alphabetical order.",
59
+ description: "Selected collections must be in a consistent order (lexicographical for most; lifecycle-aware for scripts).",
60
60
  recommended: true
61
61
  },
62
62
  fixable: "code",
63
- messages: { notAlphabetized: "Package {{ key }} are not alphabetized" },
63
+ messages: {
64
+ unsortedKeys: "Entries in '{{ key }}' are not in lexicographical order",
65
+ unsortedScripts: "Entries in 'scripts' are not in lexicographical order and grouped by lifecycles"
66
+ },
64
67
  schema: [{
65
68
  description: "Array of package properties to require sorting.",
66
69
  items: { type: "string" },
@@ -9,8 +9,7 @@ const linkRegex = /^link:/;
9
9
  const rule = createRule({
10
10
  create(context) {
11
11
  return { "Program:exit"() {
12
- const original = JSON.parse(context.sourceCode.text);
13
- const { dependencies, devDependencies, peerDependencies } = original;
12
+ const { dependencies, devDependencies, peerDependencies } = JSON.parse(context.sourceCode.text);
14
13
  const depObjs = [
15
14
  Object.entries(dependencies ?? {}),
16
15
  Object.entries(peerDependencies ?? {}),
@@ -12,8 +12,7 @@ const rule = createRule({
12
12
  create(context) {
13
13
  const ignoreProperties = context.options[0]?.ignoreProperties ?? [];
14
14
  return { "Program:exit"() {
15
- const validation = validate(context.sourceCode.text);
16
- const usableErrors = validation.errors?.filter((error) => {
15
+ const usableErrors = validate(context.sourceCode.text).errors?.filter((error) => {
17
16
  return isUsableError(error.message) && !ignoreProperties.includes(error.field);
18
17
  }) ?? [];
19
18
  for (const error of usableErrors) if (error.message) context.report({
@@ -10,39 +10,38 @@ import { isJSONStringLiteral } from "./predicates.js";
10
10
  */
11
11
  const createSimpleRequirePropertyRule = (propertyName, { ignorePrivateDefault = false, isRecommended } = {}) => {
12
12
  const ruleName = `require-${propertyName}`;
13
- const rule = createRule({
14
- create(context) {
15
- const enforceForPrivate = context.settings.packageJson?.enforceForPrivate;
16
- const ignorePrivate = context.options[0]?.ignorePrivate ?? (typeof enforceForPrivate === "boolean" ? !enforceForPrivate : ignorePrivateDefault);
17
- return { "Program > JSONExpressionStatement > JSONObjectExpression"(node) {
18
- if (ignorePrivate && node.properties.some((property) => isJSONStringLiteral(property.key) && property.key.value === "private" && property.value.type === "JSONLiteral" && property.value.value === true)) return;
19
- if (!node.properties.some((property) => isJSONStringLiteral(property.key) && property.key.value === propertyName)) context.report({
20
- data: { property: propertyName },
21
- messageId: "missing",
22
- node: context.sourceCode.ast
23
- });
24
- } };
25
- },
26
- meta: {
27
- docs: {
28
- description: `Requires the \`${propertyName}\` property to be present.`,
29
- recommended: isRecommended
30
- },
31
- messages: { missing: "Property '{{property}}' is required." },
32
- schema: [{
33
- additionalProperties: false,
34
- properties: { ignorePrivate: {
35
- default: ignorePrivateDefault,
36
- type: "boolean"
37
- } },
38
- type: "object"
39
- }],
40
- type: "suggestion"
41
- },
42
- name: ruleName
43
- });
44
13
  return {
45
- rule,
14
+ rule: createRule({
15
+ create(context) {
16
+ const enforceForPrivate = context.settings.packageJson?.enforceForPrivate;
17
+ const ignorePrivate = context.options[0]?.ignorePrivate ?? (typeof enforceForPrivate === "boolean" ? !enforceForPrivate : ignorePrivateDefault);
18
+ return { "Program > JSONExpressionStatement > JSONObjectExpression"(node) {
19
+ if (ignorePrivate && node.properties.some((property) => isJSONStringLiteral(property.key) && property.key.value === "private" && property.value.type === "JSONLiteral" && property.value.value === true)) return;
20
+ if (!node.properties.some((property) => isJSONStringLiteral(property.key) && property.key.value === propertyName)) context.report({
21
+ data: { property: propertyName },
22
+ messageId: "missing",
23
+ node: context.sourceCode.ast
24
+ });
25
+ } };
26
+ },
27
+ meta: {
28
+ docs: {
29
+ description: `Requires the \`${propertyName}\` property to be present.`,
30
+ recommended: isRecommended
31
+ },
32
+ messages: { missing: "Property '{{property}}' is required." },
33
+ schema: [{
34
+ additionalProperties: false,
35
+ properties: { ignorePrivate: {
36
+ default: ignorePrivateDefault,
37
+ type: "boolean"
38
+ } },
39
+ type: "object"
40
+ }],
41
+ type: "suggestion"
42
+ },
43
+ name: ruleName
44
+ }),
46
45
  ruleName
47
46
  };
48
47
  };
@@ -11,36 +11,35 @@ import { formatErrors } from "./formatErrors.js";
11
11
  const createSimpleValidPropertyRule = (propertyName, validationFunction, aliases = []) => {
12
12
  const ruleName = `valid-${propertyName}`;
13
13
  const propertyNames = [propertyName, ...aliases];
14
- const rule = createRule({
15
- create(context) {
16
- return propertyNames.reduce((acc, name) => {
17
- acc[`Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=${name}]`] = (node) => {
18
- const valueNode = node.value;
19
- const value = JSON.parse(context.sourceCode.getText(valueNode));
20
- const errors = validationFunction(value);
21
- if (errors.length) context.report({
22
- data: { errors: formatErrors(errors) },
23
- messageId: "validationError",
24
- node: valueNode
25
- });
26
- };
27
- return acc;
28
- }, {});
29
- },
30
- meta: {
31
- docs: {
32
- category: "Best Practices",
33
- description: `Enforce that the \`${propertyName}\`${aliases.length ? ` (also: ${aliases.map((alias) => `\`${alias}\``).join(", ")})` : ""} property is valid.`,
34
- recommended: true
35
- },
36
- messages: { validationError: `Invalid ${propertyName}: {{ errors }}` },
37
- schema: [],
38
- type: "problem"
39
- },
40
- name: ruleName
41
- });
42
14
  return {
43
- rule,
15
+ rule: createRule({
16
+ create(context) {
17
+ return propertyNames.reduce((acc, name) => {
18
+ acc[`Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=${name}]`] = (node) => {
19
+ const valueNode = node.value;
20
+ const value = JSON.parse(context.sourceCode.getText(valueNode));
21
+ const errors = validationFunction(value);
22
+ if (errors.length) context.report({
23
+ data: { errors: formatErrors(errors) },
24
+ messageId: "validationError",
25
+ node: valueNode
26
+ });
27
+ };
28
+ return acc;
29
+ }, {});
30
+ },
31
+ meta: {
32
+ docs: {
33
+ category: "Best Practices",
34
+ description: `Enforce that the \`${propertyName}\`${aliases.length ? ` (also: ${aliases.map((alias) => `\`${alias}\``).join(", ")})` : ""} property is valid.`,
35
+ recommended: true
36
+ },
37
+ messages: { validationError: `Invalid ${propertyName}: {{ errors }}` },
38
+ schema: [],
39
+ type: "problem"
40
+ },
41
+ name: ruleName
42
+ }),
44
43
  ruleName
45
44
  };
46
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-package-json",
3
- "version": "0.56.1",
3
+ "version": "0.56.3",
4
4
  "description": "Rules for consistent, readable, and valid package.json files. πŸ—‚οΈ",
5
5
  "homepage": "https://github.com/JoshuaKGoldberg/eslint-plugin-package-json#readme",
6
6
  "bugs": {
@@ -57,21 +57,21 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
60
- "@eslint/js": "9.34.0",
60
+ "@eslint/js": "9.35.0",
61
61
  "@release-it/conventional-changelog": "10.0.0",
62
62
  "@types/eslint-plugin-markdown": "2.0.2",
63
63
  "@types/estree": "1.0.7",
64
- "@types/node": "22.17.0",
64
+ "@types/node": "22.18.0",
65
65
  "@types/semver": "7.7.0",
66
66
  "@types/sort-object-keys": "1.1.3",
67
67
  "@types/validate-npm-package-name": "4.0.2",
68
68
  "@vitest/coverage-v8": "3.2.0",
69
69
  "@vitest/eslint-plugin": "1.3.3",
70
70
  "console-fail-test": "0.5.0",
71
- "eslint": "9.34.0",
71
+ "eslint": "9.35.0",
72
72
  "eslint-doc-generator": "2.2.0",
73
73
  "eslint-plugin-eslint-plugin": "7.0.0",
74
- "eslint-plugin-jsdoc": "54.1.0",
74
+ "eslint-plugin-jsdoc": "54.5.0",
75
75
  "eslint-plugin-jsonc": "2.20.0",
76
76
  "eslint-plugin-markdown": "5.1.0",
77
77
  "eslint-plugin-n": "17.21.0",
@@ -93,7 +93,7 @@
93
93
  "sentences-per-line": "0.3.0",
94
94
  "tsdown": "0.14.0",
95
95
  "typescript": "5.9.2",
96
- "typescript-eslint": "8.40.0",
96
+ "typescript-eslint": "8.41.0",
97
97
  "vitest": "3.2.0"
98
98
  },
99
99
  "peerDependencies": {