eslint-plugin-package-json 0.40.4 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -2
- package/README.md +1 -0
- package/lib/plugin.js +2 -0
- package/lib/rules/valid-author.js +1 -3
- package/lib/rules/valid-type.d.ts +11 -0
- package/lib/rules/valid-type.js +40 -0
- package/lib/types/estree.d.d.ts +7 -0
- package/lib/types/estree.d.js +0 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# [0.41.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.40.5...v0.41.0) (2025-06-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **valid-type:** add new rule ([#1120](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1120)) ([7425f27](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/7425f2796560e94420a85fa6494996cb052c06c4)), closes [#842](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/842)
|
|
4
9
|
|
|
10
|
+
## [0.40.5](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.40.4...v0.40.5) (2025-06-23)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **deps:** update dependency package-json-validator to ~0.16.0 ([#1135](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1135)) ([4a4a2a0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/4a4a2a07fdfef6b1869a51824a6697bbb2c34ecb))
|
|
15
|
+
|
|
16
|
+
## [0.40.4](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.40.3...v0.40.4) (2025-06-20)
|
|
5
17
|
|
|
6
18
|
### Bug Fixes
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- **deps:** update dependency package-json-validator to ~0.15.0 ([#1131](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1131)) ([4bf7d9c](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/4bf7d9cd091faf9ac0fb286b5968d6417328c79c))
|
|
9
21
|
|
|
10
22
|
## [0.40.3](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.40.2...v0.40.3) (2025-06-19)
|
|
11
23
|
|
package/README.md
CHANGED
|
@@ -144,6 +144,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
144
144
|
| [valid-package-def](docs/rules/valid-package-def.md) | Enforce that package.json has all properties required by the npm spec | | | | ❌ |
|
|
145
145
|
| [valid-package-definition](docs/rules/valid-package-definition.md) | Enforce that package.json has all properties required by the npm spec | ✔️ ✅ | | | |
|
|
146
146
|
| [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 | ✔️ ✅ | | 💡 | |
|
|
147
|
+
| [valid-type](docs/rules/valid-type.md) | Enforce that the `type` property is valid. | ✔️ ✅ | | | |
|
|
147
148
|
| [valid-version](docs/rules/valid-version.md) | Enforce that package versions are valid semver specifiers | ✔️ ✅ | | | |
|
|
148
149
|
|
|
149
150
|
<!-- end auto-generated rules list -->
|
package/lib/plugin.js
CHANGED
|
@@ -14,6 +14,7 @@ import { rule as validLocalDependency } from "./rules/valid-local-dependency.js"
|
|
|
14
14
|
import { rule as validName } from "./rules/valid-name.js";
|
|
15
15
|
import { rule as validPackageDefinition } from "./rules/valid-package-definition.js";
|
|
16
16
|
import { rule as validRepositoryDirectory } from "./rules/valid-repository-directory.js";
|
|
17
|
+
import { rule as validType } from "./rules/valid-type.js";
|
|
17
18
|
import { rule as validVersion } from "./rules/valid-version.js";
|
|
18
19
|
const require2 = createRequire(import.meta.url);
|
|
19
20
|
const { name, version } = require2("../package.json");
|
|
@@ -32,6 +33,7 @@ const rules = {
|
|
|
32
33
|
"valid-name": validName,
|
|
33
34
|
"valid-package-definition": validPackageDefinition,
|
|
34
35
|
"valid-repository-directory": validRepositoryDirectory,
|
|
36
|
+
"valid-type": validType,
|
|
35
37
|
"valid-version": validVersion,
|
|
36
38
|
/** @deprecated use 'valid-package-definition' instead */
|
|
37
39
|
"valid-package-def": {
|
|
@@ -6,9 +6,7 @@ const rule = createRule({
|
|
|
6
6
|
return {
|
|
7
7
|
"Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=author]"(node) {
|
|
8
8
|
const authorValue = JSON.parse(
|
|
9
|
-
context.sourceCode.getText(
|
|
10
|
-
node.value
|
|
11
|
-
)
|
|
9
|
+
context.sourceCode.getText(node.value)
|
|
12
10
|
);
|
|
13
11
|
const errors = validateAuthor(authorValue);
|
|
14
12
|
if (errors.length > 0) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
import * as jsonc_eslint_parser from 'jsonc-eslint-parser';
|
|
3
|
+
import { PackageJsonRuleContext } from '../createRule.js';
|
|
4
|
+
import 'estree';
|
|
5
|
+
|
|
6
|
+
declare const rule: {
|
|
7
|
+
create(context: PackageJsonRuleContext<unknown[]>): jsonc_eslint_parser.RuleListener;
|
|
8
|
+
meta: eslint.Rule.RuleMetaData;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { rule };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { validateType } from "package-json-validator";
|
|
2
|
+
import { createRule } from "../createRule.js";
|
|
3
|
+
import { formatErrors } from "../utils/formatErrors.js";
|
|
4
|
+
const rule = createRule({
|
|
5
|
+
create(context) {
|
|
6
|
+
return {
|
|
7
|
+
"Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=type]"(node) {
|
|
8
|
+
const typeValueNode = node.value;
|
|
9
|
+
const typeValue = JSON.parse(
|
|
10
|
+
context.sourceCode.getText(typeValueNode)
|
|
11
|
+
);
|
|
12
|
+
const errors = validateType(typeValue);
|
|
13
|
+
if (errors.length) {
|
|
14
|
+
context.report({
|
|
15
|
+
data: {
|
|
16
|
+
errors: formatErrors(errors)
|
|
17
|
+
},
|
|
18
|
+
messageId: "validationError",
|
|
19
|
+
node: typeValueNode
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
meta: {
|
|
26
|
+
docs: {
|
|
27
|
+
category: "Best Practices",
|
|
28
|
+
description: "Enforce that the `type` property is valid.",
|
|
29
|
+
recommended: true
|
|
30
|
+
},
|
|
31
|
+
messages: {
|
|
32
|
+
validationError: "Invalid type: {{ errors }}"
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
type: "problem"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
rule
|
|
40
|
+
};
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Rules for consistent, readable, and valid package.json files. 🗂️",
|
|
5
5
|
"homepage": "https://github.com/JoshuaKGoldberg/eslint-plugin-package-json#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"detect-indent": "7.0.1",
|
|
51
51
|
"detect-newline": "4.0.1",
|
|
52
52
|
"eslint-fix-utils": "^0.4.0",
|
|
53
|
-
"package-json-validator": "~0.
|
|
53
|
+
"package-json-validator": "~0.16.0",
|
|
54
54
|
"semver": "^7.5.4",
|
|
55
55
|
"sort-object-keys": "^1.1.3",
|
|
56
56
|
"sort-package-json": "^3.0.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
|
|
61
|
-
"@eslint/js": "9.
|
|
61
|
+
"@eslint/js": "9.29.0",
|
|
62
62
|
"@release-it/conventional-changelog": "10.0.0",
|
|
63
63
|
"@types/eslint-plugin-markdown": "2.0.2",
|
|
64
64
|
"@types/estree": "1.0.7",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"@vitest/eslint-plugin": "1.2.0",
|
|
71
71
|
"console-fail-test": "0.5.0",
|
|
72
72
|
"create-typescript-app": "2.42.0",
|
|
73
|
-
"cspell": "9.
|
|
74
|
-
"eslint": "9.
|
|
73
|
+
"cspell": "9.1.1",
|
|
74
|
+
"eslint": "9.29.0",
|
|
75
75
|
"eslint-doc-generator": "2.1.2",
|
|
76
76
|
"eslint-plugin-eslint-plugin": "6.4.0",
|
|
77
|
-
"eslint-plugin-jsdoc": "
|
|
77
|
+
"eslint-plugin-jsdoc": "51.0.1",
|
|
78
78
|
"eslint-plugin-jsonc": "2.20.0",
|
|
79
79
|
"eslint-plugin-markdown": "5.1.0",
|
|
80
80
|
"eslint-plugin-n": "17.20.0",
|