eslint-plugin-package-json 0.42.1 → 0.43.1
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/order-properties.js +1 -0
- package/lib/rules/repository-shorthand.js +1 -0
- package/lib/rules/valid-bin.js +1 -0
- package/lib/rules/valid-scripts.d.ts +11 -0
- package/lib/rules/valid-scripts.js +40 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.
|
|
3
|
+
## [0.43.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.43.0...v0.43.1) (2025-07-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* disallow extra properties in rule options ([#1156](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1156)) ([4186e96](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/4186e960c17a5397ac916184fc4341f9b26fc3d0))
|
|
4
9
|
|
|
10
|
+
# [0.43.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.42.1...v0.43.0) (2025-07-02)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **valid-scripts:** add new rule for validating scripts ([#1138](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1138)) ([99cc2a5](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/99cc2a5d069bfff53885f0717b8a635767cb2c19)), closes [#839](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/839)
|
|
15
|
+
|
|
16
|
+
## [0.42.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.42.0...v0.42.1) (2025-07-01)
|
|
5
17
|
|
|
6
18
|
### Bug Fixes
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- **deps:** update dependency package-json-validator to ~0.17.0 ([#1152](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1152)) ([16239d0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/16239d084c245836549071a4e8ac2879b4f53f3e))
|
|
9
21
|
|
|
10
22
|
# [0.42.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.41.0...v0.42.0) (2025-06-25)
|
|
11
23
|
|
package/README.md
CHANGED
|
@@ -143,6 +143,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
143
143
|
| [valid-name](docs/rules/valid-name.md) | Enforce that package names are valid npm package names | ✔️ ✅ | | | |
|
|
144
144
|
| [valid-package-definition](docs/rules/valid-package-definition.md) | Enforce that package.json has all properties required by the npm spec | ✔️ ✅ | | | |
|
|
145
145
|
| [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 | ✔️ ✅ | | 💡 | |
|
|
146
|
+
| [valid-scripts](docs/rules/valid-scripts.md) | Enforce that the `scripts` property is valid. | ✔️ ✅ | | | |
|
|
146
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
|
|
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 validScripts } from "./rules/valid-scripts.js";
|
|
17
18
|
import { rule as validType } from "./rules/valid-type.js";
|
|
18
19
|
import { rule as validVersion } from "./rules/valid-version.js";
|
|
19
20
|
const require2 = createRequire(import.meta.url);
|
|
@@ -33,6 +34,7 @@ const rules = {
|
|
|
33
34
|
"valid-name": validName,
|
|
34
35
|
"valid-package-definition": validPackageDefinition,
|
|
35
36
|
"valid-repository-directory": validRepositoryDirectory,
|
|
37
|
+
"valid-scripts": validScripts,
|
|
36
38
|
"valid-type": validType,
|
|
37
39
|
"valid-version": validVersion
|
|
38
40
|
};
|
package/lib/rules/valid-bin.js
CHANGED
|
@@ -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 { validateScripts } 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=scripts]"(node) {
|
|
8
|
+
const scriptValueNode = node.value;
|
|
9
|
+
const scriptValue = JSON.parse(
|
|
10
|
+
context.sourceCode.getText(scriptValueNode)
|
|
11
|
+
);
|
|
12
|
+
const errors = validateScripts(scriptValue);
|
|
13
|
+
if (errors.length) {
|
|
14
|
+
context.report({
|
|
15
|
+
data: {
|
|
16
|
+
errors: formatErrors(errors)
|
|
17
|
+
},
|
|
18
|
+
messageId: "validationError",
|
|
19
|
+
node: scriptValueNode
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
meta: {
|
|
26
|
+
docs: {
|
|
27
|
+
category: "Best Practices",
|
|
28
|
+
description: "Enforce that the `scripts` property is valid.",
|
|
29
|
+
recommended: true
|
|
30
|
+
},
|
|
31
|
+
messages: {
|
|
32
|
+
validationError: "Invalid scripts: {{ errors }}"
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
type: "problem"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
rule
|
|
40
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.1",
|
|
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": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@altano/repository-tools": "^1.0.0",
|
|
48
48
|
"change-case": "^5.4.4",
|
|
49
|
-
"detect-indent": "7.0.1",
|
|
50
|
-
"detect-newline": "4.0.1",
|
|
51
|
-
"eslint-fix-utils": "
|
|
49
|
+
"detect-indent": "^7.0.1",
|
|
50
|
+
"detect-newline": "^4.0.1",
|
|
51
|
+
"eslint-fix-utils": "~0.4.0",
|
|
52
52
|
"package-json-validator": "~0.17.0",
|
|
53
53
|
"semver": "^7.5.4",
|
|
54
54
|
"sort-object-keys": "^1.1.3",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@vitest/coverage-v8": "3.2.0",
|
|
69
69
|
"@vitest/eslint-plugin": "1.2.0",
|
|
70
70
|
"console-fail-test": "0.5.0",
|
|
71
|
-
"create-typescript-app": "2.
|
|
71
|
+
"create-typescript-app": "2.46.1",
|
|
72
72
|
"eslint": "9.29.0",
|
|
73
73
|
"eslint-doc-generator": "2.2.0",
|
|
74
74
|
"eslint-plugin-eslint-plugin": "6.5.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"prettier": "3.6.0",
|
|
90
90
|
"prettier-plugin-curly": "0.3.1",
|
|
91
91
|
"prettier-plugin-packagejson": "2.5.10",
|
|
92
|
-
"prettier-plugin-sh": "0.
|
|
92
|
+
"prettier-plugin-sh": "0.18.0",
|
|
93
93
|
"release-it": "19.0.1",
|
|
94
94
|
"sentences-per-line": "0.3.0",
|
|
95
95
|
"tsup": "8.5.0",
|