eslint-plugin-package-json 1.8.0 → 1.9.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/README.md +2 -1
- package/dist/{createRule-29pC9RoP.d.mts → createRule-CSNxd7i2.d.mts} +2 -2
- package/dist/experimental/index.d.mts +7 -8
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.d.mts +10 -10
- package/dist/index.mjs +1 -1
- package/dist/{plugin-Ciw4gT9_.mjs → plugin-2AyGRwRO.mjs} +104 -27
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ See [Getting Started](https://eslint-plugin-package-json.dev/getting-started) fo
|
|
|
50
50
|
| [repository-shorthand](https://eslint-plugin-package-json.dev/rules/repository-shorthand) | Enforce either object or shorthand declaration for repository. | ✅ | 🔧 | |
|
|
51
51
|
| [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. | ✅ | | 💡 |
|
|
52
52
|
| [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. | | | 💡 |
|
|
53
|
+
| [restrict-dist-tags](https://eslint-plugin-package-json.dev/rules/restrict-dist-tags) | Restricts dependency dist-tags to an allowed list and selected dependency types. | | | |
|
|
53
54
|
| [restrict-private-properties](https://eslint-plugin-package-json.dev/rules/restrict-private-properties) | Disallows unnecessary properties in private packages. | | 🔧 | 💡 |
|
|
54
55
|
| [restrict-top-level-properties](https://eslint-plugin-package-json.dev/rules/restrict-top-level-properties) | Disallows specified top-level properties in package.json. | | | 💡 |
|
|
55
56
|
| [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). | 🎨 | | 💡 |
|
|
@@ -209,7 +210,7 @@ Thanks! 🍻
|
|
|
209
210
|
</tr>
|
|
210
211
|
<tr>
|
|
211
212
|
<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>
|
|
212
|
-
<td align="center" valign="top" width="14.28%"><a href="https://hirok.io"><img src="https://avatars.githubusercontent.com/u/1075694?v=4?s=100" width="100px;" alt="Hiroki Osame"/><br /><sub><b>Hiroki Osame</b></sub></a><br /><a href="#ideas-privatenumber" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=privatenumber" title="Code">💻</a></td>
|
|
213
|
+
<td align="center" valign="top" width="14.28%"><a href="https://hirok.io"><img src="https://avatars.githubusercontent.com/u/1075694?v=4?s=100" width="100px;" alt="Hiroki Osame"/><br /><sub><b>Hiroki Osame</b></sub></a><br /><a href="#ideas-privatenumber" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=privatenumber" title="Code">💻</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Aprivatenumber" title="Bug reports">🐛</a></td>
|
|
213
214
|
<td align="center" valign="top" width="14.28%"><a href="https://vanyauhalin.me/"><img src="https://avatars.githubusercontent.com/u/56481109?v=4?s=100" width="100px;" alt="Ivan Uhalin"/><br /><sub><b>Ivan Uhalin</b></sub></a><br /><a href="#ideas-vanyauhalin" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
214
215
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Zamiell"><img src="https://avatars.githubusercontent.com/u/5511220?v=4?s=100" width="100px;" alt="James"/><br /><sub><b>James</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=Zamiell" title="Code">💻</a> <a href="#ideas-Zamiell" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3AZamiell" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=Zamiell" title="Documentation">📖</a></td>
|
|
215
216
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zetlen"><img src="https://avatars.githubusercontent.com/u/1643758?v=4?s=100" width="100px;" alt="James Zetlen"/><br /><sub><b>James Zetlen</b></sub></a><br /><a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=zetlen" title="Code">💻</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/issues?q=author%3Azetlen" title="Bug reports">🐛</a> <a href="https://github.com/michaelfaith/eslint-plugin-package-json/commits?author=zetlen" title="Documentation">📖</a> <a href="#infra-zetlen" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-zetlen" title="Maintenance">🚧</a> <a href="#tool-zetlen" title="Tools">🔧</a></td>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AST, RuleListener } from "jsonc-eslint-parser";
|
|
2
2
|
import { AST as AST$1, Rule, SourceCode } from "eslint";
|
|
3
3
|
import * as ESTree from "estree";
|
|
4
|
-
|
|
5
4
|
//#region node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/definitions/jsonSchema.d.ts
|
|
6
5
|
declare const $JSONSchema: unique symbol;
|
|
7
6
|
type $JSONSchema = typeof $JSONSchema;
|
|
@@ -92,7 +91,8 @@ interface PackageJsonRuleModule<Options extends unknown[] = unknown[], Schema ex
|
|
|
92
91
|
meta: Omit<Rule.RuleMetaData, 'defaultOptions' | 'docs' | 'schema'> & {
|
|
93
92
|
defaultOptions?: NoInfer<Options>;
|
|
94
93
|
docs?: Rule.RuleMetaData['docs'] & {
|
|
95
|
-
category?: string;
|
|
94
|
+
category?: string;
|
|
95
|
+
/** An optional route segment to group this rule under */
|
|
96
96
|
ruleGroup?: string;
|
|
97
97
|
};
|
|
98
98
|
schema?: Schema;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as PackageJsonRuleModule, r as JSONSchema, t as PackageJsonPluginSettings } from "../createRule-
|
|
2
|
-
import { ESLint } from "eslint";
|
|
3
|
-
|
|
1
|
+
import { n as PackageJsonRuleModule, r as JSONSchema, t as PackageJsonPluginSettings } from "../createRule-CSNxd7i2.mjs";
|
|
2
|
+
import { ESLint as ESLint$1 } from "eslint";
|
|
4
3
|
//#region src/experimental/plugin.d.ts
|
|
5
4
|
declare const plugin: {
|
|
6
5
|
configs: {
|
|
@@ -9,7 +8,7 @@ declare const plugin: {
|
|
|
9
8
|
language: string;
|
|
10
9
|
name: string;
|
|
11
10
|
plugins: {
|
|
12
|
-
readonly 'package-json': ESLint.Plugin;
|
|
11
|
+
readonly 'package-json': ESLint$1.Plugin;
|
|
13
12
|
};
|
|
14
13
|
rules: {
|
|
15
14
|
[k: string]: "error";
|
|
@@ -20,7 +19,7 @@ declare const plugin: {
|
|
|
20
19
|
language: string;
|
|
21
20
|
name: string;
|
|
22
21
|
plugins: {
|
|
23
|
-
readonly 'package-json': ESLint.Plugin;
|
|
22
|
+
readonly 'package-json': ESLint$1.Plugin;
|
|
24
23
|
};
|
|
25
24
|
rules: {
|
|
26
25
|
[k: string]: "error";
|
|
@@ -37,7 +36,7 @@ declare const plugin: {
|
|
|
37
36
|
};
|
|
38
37
|
//#endregion
|
|
39
38
|
//#region src/experimental/index.d.ts
|
|
40
|
-
declare const configs: {
|
|
39
|
+
export declare const configs: {
|
|
41
40
|
recommended: {
|
|
42
41
|
files: string[];
|
|
43
42
|
language: string;
|
|
@@ -61,8 +60,8 @@ declare const configs: {
|
|
|
61
60
|
};
|
|
62
61
|
};
|
|
63
62
|
};
|
|
64
|
-
declare const rules: {
|
|
63
|
+
export declare const rules: {
|
|
65
64
|
[k: string]: PackageJsonRuleModule<unknown[], JSONSchema[]>;
|
|
66
65
|
};
|
|
67
66
|
//#endregion
|
|
68
|
-
export { type PackageJsonPluginSettings,
|
|
67
|
+
export { type PackageJsonPluginSettings, plugin as default };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as PackageJsonRuleModule, r as JSONSchema, t as PackageJsonPluginSettings } from "./createRule-
|
|
1
|
+
import { n as PackageJsonRuleModule, r as JSONSchema, t as PackageJsonPluginSettings } from "./createRule-CSNxd7i2.mjs";
|
|
2
2
|
import * as parserJsonc from "jsonc-eslint-parser";
|
|
3
|
-
import { ESLint } from "eslint";
|
|
4
|
-
|
|
3
|
+
import { ESLint as ESLint$1 } from "eslint";
|
|
5
4
|
//#region src/plugin.d.ts
|
|
6
5
|
declare const plugin: {
|
|
7
6
|
configs: {
|
|
@@ -12,12 +11,13 @@ declare const plugin: {
|
|
|
12
11
|
};
|
|
13
12
|
name: string;
|
|
14
13
|
plugins: {
|
|
15
|
-
readonly 'package-json': ESLint.Plugin;
|
|
14
|
+
readonly 'package-json': ESLint$1.Plugin;
|
|
16
15
|
};
|
|
17
16
|
rules: {
|
|
18
17
|
[k: string]: "error";
|
|
19
18
|
};
|
|
20
|
-
};
|
|
19
|
+
};
|
|
20
|
+
/** @deprecated use the recommended config instead. this config will be removed in a future major release */
|
|
21
21
|
'recommended-publishable': {
|
|
22
22
|
files: string[];
|
|
23
23
|
languageOptions: {
|
|
@@ -25,7 +25,7 @@ declare const plugin: {
|
|
|
25
25
|
};
|
|
26
26
|
name: string;
|
|
27
27
|
plugins: {
|
|
28
|
-
readonly 'package-json': ESLint.Plugin;
|
|
28
|
+
readonly 'package-json': ESLint$1.Plugin;
|
|
29
29
|
};
|
|
30
30
|
rules: {
|
|
31
31
|
[x: string]: "error";
|
|
@@ -38,7 +38,7 @@ declare const plugin: {
|
|
|
38
38
|
};
|
|
39
39
|
name: string;
|
|
40
40
|
plugins: {
|
|
41
|
-
readonly 'package-json': ESLint.Plugin;
|
|
41
|
+
readonly 'package-json': ESLint$1.Plugin;
|
|
42
42
|
};
|
|
43
43
|
rules: {
|
|
44
44
|
[k: string]: "error";
|
|
@@ -53,8 +53,8 @@ declare const plugin: {
|
|
|
53
53
|
};
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/index.d.ts
|
|
56
|
-
declare const rules: Record<string, PackageJsonRuleModule<unknown[], JSONSchema[]>>;
|
|
57
|
-
declare const configs: {
|
|
56
|
+
export declare const rules: Record<string, PackageJsonRuleModule<unknown[], JSONSchema[]>>;
|
|
57
|
+
export declare const configs: {
|
|
58
58
|
recommended: {
|
|
59
59
|
files: string[];
|
|
60
60
|
languageOptions: {
|
|
@@ -96,4 +96,4 @@ declare const configs: {
|
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
98
|
//#endregion
|
|
99
|
-
export { type PackageJsonPluginSettings,
|
|
99
|
+
export { type PackageJsonPluginSettings, plugin as default };
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,11 @@ import path from "node:path";
|
|
|
14
14
|
import process from "node:process";
|
|
15
15
|
import { sep } from "node:path/posix";
|
|
16
16
|
import { findRootSync } from "@altano/repository-tools";
|
|
17
|
+
//#region src/utils/predicates/isJSONNullLiteral.ts
|
|
18
|
+
function isJSONNullLiteral(node) {
|
|
19
|
+
return node.type === "JSONLiteral" && node.value === null;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
17
22
|
//#region src/utils/predicates/isJSONStringLiteral.ts
|
|
18
23
|
function isJSONStringLiteral(node) {
|
|
19
24
|
return node.type === "JSONLiteral" && typeof node.value === "string";
|
|
@@ -50,7 +55,7 @@ function createRule(rule) {
|
|
|
50
55
|
}
|
|
51
56
|
//#endregion
|
|
52
57
|
//#region src/rules/bin-name-casing.ts
|
|
53
|
-
const rule$
|
|
58
|
+
const rule$20 = createRule({
|
|
54
59
|
create(context) {
|
|
55
60
|
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=bin]"(node) {
|
|
56
61
|
if (node.value.type === "JSONObjectExpression") for (const property of node.value.properties) {
|
|
@@ -92,11 +97,12 @@ function isImplicitFormat(node) {
|
|
|
92
97
|
if (node.type === "JSONLiteral") return true;
|
|
93
98
|
return node.properties.every((property) => !isJSONStringLiteral(property.key) || !property.key.value.startsWith("."));
|
|
94
99
|
}
|
|
95
|
-
const rule$
|
|
100
|
+
const rule$19 = createRule({
|
|
96
101
|
create(context) {
|
|
97
102
|
const [{ prefer = "explicit" } = {}] = context.options;
|
|
98
103
|
function validateForExplicit(node) {
|
|
99
104
|
const { value } = node;
|
|
105
|
+
if (isJSONNullLiteral(value)) return;
|
|
100
106
|
if (value.type !== "JSONLiteral" && value.type !== "JSONObjectExpression" || !isImplicitFormat(value)) return;
|
|
101
107
|
context.report({
|
|
102
108
|
fix(fixer) {
|
|
@@ -113,6 +119,7 @@ const rule$18 = createRule({
|
|
|
113
119
|
if (value.type !== "JSONObjectExpression") return;
|
|
114
120
|
if (value.properties.length !== 1 || !isJSONStringLiteral(value.properties[0].key) || value.properties[0].key.value !== ".") return;
|
|
115
121
|
const dotProperty = value.properties[0];
|
|
122
|
+
if (isJSONNullLiteral(dotProperty.value)) return;
|
|
116
123
|
context.report({
|
|
117
124
|
fix(fixer) {
|
|
118
125
|
const valueText = context.sourceCode.getText(dotProperty.value);
|
|
@@ -193,7 +200,7 @@ const getTopLevelProperty = (node) => {
|
|
|
193
200
|
return n.type === "JSONProperty" ? n.key : void 0;
|
|
194
201
|
};
|
|
195
202
|
const defaultIgnoreProperties = ["files"];
|
|
196
|
-
const rule$
|
|
203
|
+
const rule$18 = createRule({
|
|
197
204
|
create(context) {
|
|
198
205
|
const ignoreProperties = new Set(context.options[0]?.ignoreProperties ?? defaultIgnoreProperties);
|
|
199
206
|
return {
|
|
@@ -249,7 +256,7 @@ const getBundledDependencyNames = (value) => {
|
|
|
249
256
|
if (value?.type === "JSONArrayExpression") for (const element of value.elements.filter(isNotNullish).filter(isJSONStringLiteral)) names.add(element.value);
|
|
250
257
|
return names;
|
|
251
258
|
};
|
|
252
|
-
const rule$
|
|
259
|
+
const rule$17 = createRule({
|
|
253
260
|
create(context) {
|
|
254
261
|
const ignorePrivate = context.options[0]?.ignorePrivate ?? true;
|
|
255
262
|
let isPrivate = false;
|
|
@@ -320,7 +327,7 @@ const getCachedLocalFileRegex = (filename) => {
|
|
|
320
327
|
return regex;
|
|
321
328
|
}
|
|
322
329
|
};
|
|
323
|
-
const rule$
|
|
330
|
+
const rule$16 = createRule({
|
|
324
331
|
create(context) {
|
|
325
332
|
const entryCache = {
|
|
326
333
|
bin: [],
|
|
@@ -397,7 +404,7 @@ const rule$15 = createRule({
|
|
|
397
404
|
});
|
|
398
405
|
//#endregion
|
|
399
406
|
//#region src/rules/no-redundant-publishConfig.ts
|
|
400
|
-
const rule$
|
|
407
|
+
const rule$15 = createRule({
|
|
401
408
|
create(context) {
|
|
402
409
|
let packageName;
|
|
403
410
|
let publishConfigAccessProperty;
|
|
@@ -443,7 +450,7 @@ const rule$14 = createRule({
|
|
|
443
450
|
});
|
|
444
451
|
//#endregion
|
|
445
452
|
//#region src/rules/order-properties.ts
|
|
446
|
-
const rule$
|
|
453
|
+
const rule$14 = createRule({
|
|
447
454
|
create(context) {
|
|
448
455
|
return { "Program:exit"() {
|
|
449
456
|
const { ast, text } = context.sourceCode;
|
|
@@ -503,7 +510,7 @@ const rule$13 = createRule({
|
|
|
503
510
|
//#region src/rules/prefer-rolling-workspace-spec.ts
|
|
504
511
|
const rollingWorkspaceSpecRegex = /^workspace:[*^~]?$/;
|
|
505
512
|
const convertibleSpecRegex = /^(workspace:[~^])/;
|
|
506
|
-
const rule$
|
|
513
|
+
const rule$13 = createRule({
|
|
507
514
|
create(context) {
|
|
508
515
|
const { ignoreDependencies = [], ignorePatterns = [] } = context.options[0] ?? {};
|
|
509
516
|
const ignoreRegexes = ignorePatterns.map((pattern) => new RegExp(pattern));
|
|
@@ -601,7 +608,7 @@ const createUrl = (shorthand) => {
|
|
|
601
608
|
}
|
|
602
609
|
return `${providerUrls.github}${shorthand}`;
|
|
603
610
|
};
|
|
604
|
-
const rule$
|
|
611
|
+
const rule$12 = createRule({
|
|
605
612
|
create(context) {
|
|
606
613
|
const [{ form = "object" } = {}] = context.options;
|
|
607
614
|
function validateRepositoryForObject(node) {
|
|
@@ -680,7 +687,7 @@ const rule$11 = createRule({
|
|
|
680
687
|
});
|
|
681
688
|
//#endregion
|
|
682
689
|
//#region src/rules/require-attribution.ts
|
|
683
|
-
const rule$
|
|
690
|
+
const rule$11 = createRule({
|
|
684
691
|
create(context) {
|
|
685
692
|
const preferContributorsOnly = context.options[0]?.preferContributorsOnly ?? false;
|
|
686
693
|
const ignorePrivate = context.options[0]?.ignorePrivate ?? true;
|
|
@@ -922,7 +929,7 @@ const rules$2 = Object.fromEntries([
|
|
|
922
929
|
}));
|
|
923
930
|
//#endregion
|
|
924
931
|
//#region src/rules/restrict-dependency-ranges.ts
|
|
925
|
-
const DEPENDENCY_TYPES = [
|
|
932
|
+
const DEPENDENCY_TYPES$1 = [
|
|
926
933
|
"dependencies",
|
|
927
934
|
"devDependencies",
|
|
928
935
|
"optionalDependencies",
|
|
@@ -968,7 +975,7 @@ const schemaOptions = {
|
|
|
968
975
|
properties: {
|
|
969
976
|
forDependencyTypes: {
|
|
970
977
|
description: "Apply a range type restriction for an entire group of dependencies by which type of dependencies they belong to.",
|
|
971
|
-
items: { enum: DEPENDENCY_TYPES },
|
|
978
|
+
items: { enum: DEPENDENCY_TYPES$1 },
|
|
972
979
|
type: "array"
|
|
973
980
|
},
|
|
974
981
|
forPackages: {
|
|
@@ -1022,7 +1029,7 @@ const isVersionSupported = (version) => {
|
|
|
1022
1029
|
return !!semver.validRange(rawVersion);
|
|
1023
1030
|
};
|
|
1024
1031
|
const POSSIBLE_WORKSPACE_SPEC_REGEX = /(?:workspace:)?[^~]?/;
|
|
1025
|
-
const rule$
|
|
1032
|
+
const rule$10 = createRule({
|
|
1026
1033
|
create(context) {
|
|
1027
1034
|
if (!context.options[0]) return {};
|
|
1028
1035
|
const optionsArray = (Array.isArray(context.options[0]) ? context.options[0].toReversed() : [context.options[0]]).map((option) => ({
|
|
@@ -1032,7 +1039,7 @@ const rule$9 = createRule({
|
|
|
1032
1039
|
}));
|
|
1033
1040
|
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.type=JSONLiteral][value.type=JSONObjectExpression]"(node) {
|
|
1034
1041
|
const dependencyType = node.key.value;
|
|
1035
|
-
if (!DEPENDENCY_TYPES.includes(dependencyType)) return;
|
|
1042
|
+
if (!DEPENDENCY_TYPES$1.includes(dependencyType)) return;
|
|
1036
1043
|
for (const property of node.value.properties) {
|
|
1037
1044
|
if (!isJSONStringLiteral(property.key) || !isJSONStringLiteral(property.value)) continue;
|
|
1038
1045
|
const name = property.key.value;
|
|
@@ -1099,6 +1106,73 @@ const rule$9 = createRule({
|
|
|
1099
1106
|
name: "restrict-dependency-ranges"
|
|
1100
1107
|
});
|
|
1101
1108
|
//#endregion
|
|
1109
|
+
//#region src/rules/restrict-dist-tags.ts
|
|
1110
|
+
const DEPENDENCY_TYPES = [
|
|
1111
|
+
"dependencies",
|
|
1112
|
+
"devDependencies",
|
|
1113
|
+
"optionalDependencies",
|
|
1114
|
+
"peerDependencies"
|
|
1115
|
+
];
|
|
1116
|
+
const DEFAULT_ALLOWED_TAGS = [
|
|
1117
|
+
"latest",
|
|
1118
|
+
"dev",
|
|
1119
|
+
"next",
|
|
1120
|
+
"alpha",
|
|
1121
|
+
"beta",
|
|
1122
|
+
"canary",
|
|
1123
|
+
"rc"
|
|
1124
|
+
];
|
|
1125
|
+
const distTagPattern = /^[A-Z0-9][\w.-]*$/i;
|
|
1126
|
+
function isDistTag(value) {
|
|
1127
|
+
return !semver.validRange(value) && distTagPattern.test(value);
|
|
1128
|
+
}
|
|
1129
|
+
const rule$9 = createRule({
|
|
1130
|
+
create(context) {
|
|
1131
|
+
const { allowed = DEFAULT_ALLOWED_TAGS, allowedFor } = context.options[0] ?? {};
|
|
1132
|
+
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.type=JSONLiteral][value.type=JSONObjectExpression]"(node) {
|
|
1133
|
+
const dependencyType = node.key.value;
|
|
1134
|
+
if (!DEPENDENCY_TYPES.includes(dependencyType)) return;
|
|
1135
|
+
for (const property of node.value.properties) {
|
|
1136
|
+
if (!isJSONStringLiteral(property.key) || !isJSONStringLiteral(property.value)) continue;
|
|
1137
|
+
const spec = property.value.value;
|
|
1138
|
+
if (!isDistTag(spec)) continue;
|
|
1139
|
+
if ((allowedFor === void 0 || allowedFor.includes(dependencyType)) && allowed.includes(spec)) continue;
|
|
1140
|
+
context.report({
|
|
1141
|
+
data: {
|
|
1142
|
+
dependencyType,
|
|
1143
|
+
tag: spec
|
|
1144
|
+
},
|
|
1145
|
+
messageId: "disallowedDistTag",
|
|
1146
|
+
node: property.value
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
} };
|
|
1150
|
+
},
|
|
1151
|
+
meta: {
|
|
1152
|
+
defaultOptions: [{ allowed: DEFAULT_ALLOWED_TAGS }],
|
|
1153
|
+
docs: { description: "Restricts dependency dist-tags to an allowed list and selected dependency types." },
|
|
1154
|
+
messages: { disallowedDistTag: "The \"{{ tag }}\" dist-tag is not allowed for {{ dependencyType }}." },
|
|
1155
|
+
schema: [{
|
|
1156
|
+
type: "object",
|
|
1157
|
+
properties: {
|
|
1158
|
+
allowed: {
|
|
1159
|
+
description: "Dist-tags allowed in dependency specifications.",
|
|
1160
|
+
type: "array",
|
|
1161
|
+
items: { type: "string" }
|
|
1162
|
+
},
|
|
1163
|
+
allowedFor: {
|
|
1164
|
+
description: "Dependency sections where the allowed dist-tags may be used.",
|
|
1165
|
+
type: "array",
|
|
1166
|
+
items: { enum: DEPENDENCY_TYPES }
|
|
1167
|
+
}
|
|
1168
|
+
},
|
|
1169
|
+
additionalProperties: false
|
|
1170
|
+
}],
|
|
1171
|
+
type: "problem"
|
|
1172
|
+
},
|
|
1173
|
+
name: "restrict-dist-tags"
|
|
1174
|
+
});
|
|
1175
|
+
//#endregion
|
|
1102
1176
|
//#region src/rules/restrict-private-properties.ts
|
|
1103
1177
|
const defaultBlockedProperties = ["files", "publishConfig"];
|
|
1104
1178
|
const rule$8 = createRule({
|
|
@@ -1306,7 +1380,8 @@ const rule$5 = createRule({
|
|
|
1306
1380
|
let naturalCompare;
|
|
1307
1381
|
if (isScripts) {
|
|
1308
1382
|
const scriptsSource = context.sourceCode.getText(node);
|
|
1309
|
-
const
|
|
1383
|
+
const minimalJson = JSON.parse(`{${scriptsSource}}`);
|
|
1384
|
+
const { scripts: sortedScripts } = sortPackageJson(minimalJson);
|
|
1310
1385
|
const lifecycleIndex = new Map(Object.keys(sortedScripts).map((k, i) => [k, i]));
|
|
1311
1386
|
naturalCompare = (a, b) => (lifecycleIndex.get(a) ?? 0) - (lifecycleIndex.get(b) ?? 0);
|
|
1312
1387
|
} else naturalCompare = (a, b) => a > b ? 1 : -1;
|
|
@@ -1561,7 +1636,8 @@ const rule$2 = createRule({
|
|
|
1561
1636
|
};
|
|
1562
1637
|
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=author]"(node) {
|
|
1563
1638
|
const valueNode = node.value;
|
|
1564
|
-
const
|
|
1639
|
+
const value = JSON.parse(context.sourceCode.getText(valueNode));
|
|
1640
|
+
const result = validateAuthor(value);
|
|
1565
1641
|
reportIssues(result, valueNode, "author");
|
|
1566
1642
|
} };
|
|
1567
1643
|
},
|
|
@@ -1931,18 +2007,19 @@ const rule = createRule({
|
|
|
1931
2007
|
//#region src/plugin.ts
|
|
1932
2008
|
const require = createRequire(import.meta.url);
|
|
1933
2009
|
const rules = {
|
|
1934
|
-
"bin-name-casing": rule$
|
|
1935
|
-
"exports-subpaths-style": rule$
|
|
1936
|
-
"no-empty-fields": rule$
|
|
1937
|
-
"no-local-dependencies": rule$
|
|
1938
|
-
"no-redundant-files": rule$
|
|
1939
|
-
"no-redundant-publishConfig": rule$
|
|
1940
|
-
"order-properties": rule$
|
|
1941
|
-
"prefer-rolling-workspace-spec": rule$
|
|
1942
|
-
"require-attribution": rule$
|
|
2010
|
+
"bin-name-casing": rule$20,
|
|
2011
|
+
"exports-subpaths-style": rule$19,
|
|
2012
|
+
"no-empty-fields": rule$18,
|
|
2013
|
+
"no-local-dependencies": rule$17,
|
|
2014
|
+
"no-redundant-files": rule$16,
|
|
2015
|
+
"no-redundant-publishConfig": rule$15,
|
|
2016
|
+
"order-properties": rule$14,
|
|
2017
|
+
"prefer-rolling-workspace-spec": rule$13,
|
|
2018
|
+
"require-attribution": rule$11,
|
|
1943
2019
|
...rules$2,
|
|
1944
|
-
"repository-shorthand": rule$
|
|
1945
|
-
"restrict-dependency-ranges": rule$
|
|
2020
|
+
"repository-shorthand": rule$12,
|
|
2021
|
+
"restrict-dependency-ranges": rule$10,
|
|
2022
|
+
"restrict-dist-tags": rule$9,
|
|
1946
2023
|
"restrict-private-properties": rule$8,
|
|
1947
2024
|
"restrict-top-level-properties": rule$7,
|
|
1948
2025
|
"scripts-name-casing": rule$6,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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": {
|
|
@@ -57,51 +57,51 @@
|
|
|
57
57
|
"sort-package-json": "^4.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@astrojs/check": "0.9.
|
|
61
|
-
"@astrojs/markdown-satteri": "0.
|
|
62
|
-
"@astrojs/starlight": "0.
|
|
60
|
+
"@astrojs/check": "0.9.10",
|
|
61
|
+
"@astrojs/markdown-satteri": "0.4.1",
|
|
62
|
+
"@astrojs/starlight": "0.42.0",
|
|
63
63
|
"@catppuccin/starlight": "2.1.0",
|
|
64
|
-
"@eslint-community/eslint-plugin-eslint-comments": "4.
|
|
64
|
+
"@eslint-community/eslint-plugin-eslint-comments": "4.8.1",
|
|
65
65
|
"@eslint/js": "10.0.1",
|
|
66
|
-
"@eslint/json": "2.
|
|
67
|
-
"@eslint/markdown": "8.0.
|
|
66
|
+
"@eslint/json": "2.1.0",
|
|
67
|
+
"@eslint/markdown": "8.0.3",
|
|
68
68
|
"@ianvs/prettier-plugin-sort-imports": "4.7.1",
|
|
69
|
-
"@types/node": "24.13.
|
|
69
|
+
"@types/node": "24.13.4",
|
|
70
70
|
"@types/semver": "7.8.0",
|
|
71
71
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
72
|
-
"@vitest/coverage-v8": "
|
|
73
|
-
"@vitest/eslint-plugin": "1.6.
|
|
74
|
-
"astro": "7.2
|
|
75
|
-
"astro-og-canvas": "0.13.
|
|
72
|
+
"@vitest/coverage-v8": "5.0.1",
|
|
73
|
+
"@vitest/eslint-plugin": "1.6.27",
|
|
74
|
+
"astro": "7.3.2",
|
|
75
|
+
"astro-og-canvas": "0.13.1",
|
|
76
76
|
"canvaskit-wasm": "0.42.0",
|
|
77
|
-
"console-fail-test": "0.6.
|
|
78
|
-
"eslint": "10.
|
|
79
|
-
"eslint-doc-generator": "3.7.
|
|
80
|
-
"eslint-plugin-eslint-plugin": "7.6.
|
|
81
|
-
"eslint-plugin-jsdoc": "64.
|
|
82
|
-
"eslint-plugin-jsonc": "3.4.
|
|
77
|
+
"console-fail-test": "0.6.1",
|
|
78
|
+
"eslint": "10.10.0",
|
|
79
|
+
"eslint-doc-generator": "3.7.1",
|
|
80
|
+
"eslint-plugin-eslint-plugin": "7.6.2",
|
|
81
|
+
"eslint-plugin-jsdoc": "64.4.0",
|
|
82
|
+
"eslint-plugin-jsonc": "3.4.2",
|
|
83
83
|
"eslint-plugin-n": "18.3.0",
|
|
84
84
|
"eslint-plugin-node-dependencies": "2.2.0",
|
|
85
|
-
"eslint-plugin-perfectionist": "5.
|
|
86
|
-
"eslint-plugin-regexp": "3.
|
|
87
|
-
"eslint-plugin-unicorn": "
|
|
88
|
-
"eslint-plugin-yml": "3.8.
|
|
85
|
+
"eslint-plugin-perfectionist": "5.11.0",
|
|
86
|
+
"eslint-plugin-regexp": "3.3.0",
|
|
87
|
+
"eslint-plugin-unicorn": "74.0.0",
|
|
88
|
+
"eslint-plugin-yml": "3.8.1",
|
|
89
89
|
"jiti": "2.7.0",
|
|
90
90
|
"json-schema-to-ts": "3.1.1",
|
|
91
|
-
"knip": "6.
|
|
92
|
-
"pkg-pr-new": "0.0.
|
|
93
|
-
"prettier": "3.9.
|
|
91
|
+
"knip": "6.35.1",
|
|
92
|
+
"pkg-pr-new": "0.0.88",
|
|
93
|
+
"prettier": "3.9.6",
|
|
94
94
|
"prettier-plugin-curly": "0.4.1",
|
|
95
95
|
"prettier-plugin-packagejson": "3.0.2",
|
|
96
96
|
"prettier-plugin-sh": "0.19.0",
|
|
97
97
|
"pretty-quick": "4.2.2",
|
|
98
|
-
"sharp": "0.35.
|
|
99
|
-
"simple-git-hooks": "2.
|
|
100
|
-
"starlight-auto-sidebar": "0.4.
|
|
101
|
-
"tsdown": "0.
|
|
98
|
+
"sharp": "0.35.4",
|
|
99
|
+
"simple-git-hooks": "2.14.0",
|
|
100
|
+
"starlight-auto-sidebar": "0.4.1",
|
|
101
|
+
"tsdown": "0.23.0",
|
|
102
102
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
103
|
-
"typescript-eslint": "8.
|
|
104
|
-
"vitest": "
|
|
103
|
+
"typescript-eslint": "8.70.0",
|
|
104
|
+
"vitest": "5.0.1"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
107
|
"@eslint/json": ">=1.0.0",
|