eslint-plugin-package-json 0.42.0 → 0.43.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 +21 -1
- package/lib/plugin.js +2 -0
- package/lib/rules/valid-scripts.d.ts +11 -0
- package/lib/rules/valid-scripts.js +40 -0
- package/package.json +10 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
# [0.
|
|
3
|
+
# [0.43.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.42.1...v0.43.0) (2025-07-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **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)
|
|
4
9
|
|
|
10
|
+
## [0.42.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.42.0...v0.42.1) (2025-07-01)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **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))
|
|
15
|
+
|
|
16
|
+
# [0.42.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.41.0...v0.42.0) (2025-06-25)
|
|
5
17
|
|
|
6
18
|
### Features
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- remove deprecated `valid-package-def` rule ([#1111](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1111)) ([946a585](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/946a585c2c9344ac227463cf234714fc204f1746)), closes [#1110](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1110) [#711](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/711)
|
|
9
21
|
|
|
10
22
|
# [0.41.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.40.5...v0.41.0) (2025-06-24)
|
|
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
|
|
|
@@ -152,6 +153,25 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
152
153
|
These rules only run on `package.json` files; they will ignore all other files being linted.
|
|
153
154
|
They can lint `package.json` files at project root and in any subfolder of the project, making this plugin great for monorepos.
|
|
154
155
|
|
|
156
|
+
## Deprecation Policy
|
|
157
|
+
|
|
158
|
+
We never _want_ to remove things, when we're building them!
|
|
159
|
+
But the reality is that libraries evolve and deprecations are a fact of life.
|
|
160
|
+
Following are the different timeframes that we've defined as it relates to deprecating APIs in this project.
|
|
161
|
+
|
|
162
|
+
### RFC Timeframe (6 weeks)
|
|
163
|
+
|
|
164
|
+
When some aspect of our API is going to be deprecated (and eventually removed), it must initially go through an RFC phase.
|
|
165
|
+
Whoever's motivating the removal of the api, should create an RFC issue explaining the proposal and inviting feedback from the community.
|
|
166
|
+
That RFC should remain active for at least 6 weeks.
|
|
167
|
+
The RFC text should make clear what the target date is for closing the RFC.
|
|
168
|
+
Once the RFC period is over, if the removal is still moving forward, the API(s) should be officially deprecated.
|
|
169
|
+
|
|
170
|
+
### Removal Timeframe (6 months)
|
|
171
|
+
|
|
172
|
+
Once an API has been marked as deprecated, it will remain intact for at least 6 months.
|
|
173
|
+
After 6 months from the date of deprecation, the API is subject to removal.
|
|
174
|
+
|
|
155
175
|
## Development
|
|
156
176
|
|
|
157
177
|
See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
|
|
@@ -197,7 +217,7 @@ Thanks! 🗂
|
|
|
197
217
|
<td align="center" valign="top" width="14.28%"><a href="https://ota-meshi.github.io/"><img src="https://avatars.githubusercontent.com/u/16508807?v=4?s=100" width="100px;" alt="Yosuke Ota"/><br /><sub><b>Yosuke Ota</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Aota-meshi" title="Bug reports">🐛</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=ota-meshi" title="Code">💻</a></td>
|
|
198
218
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/b3rnhard"><img src="https://avatars.githubusercontent.com/u/10774404?v=4?s=100" width="100px;" alt="b3rnhard"/><br /><sub><b>b3rnhard</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Ab3rnhard" title="Bug reports">🐛</a></td>
|
|
199
219
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chouchouji"><img src="https://avatars.githubusercontent.com/u/70570907?v=4?s=100" width="100px;" alt="chouchouji"/><br /><sub><b>chouchouji</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=chouchouji" title="Code">💻</a></td>
|
|
200
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/michaelfaith"><img src="https://avatars.githubusercontent.com/u/8071845?v=4?s=100" width="100px;" alt="michael faith"/><br /><sub><b>michael faith</b></sub></a><br /><a href="#infra-michaelfaith" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=michaelfaith" title="Code">💻</a> <a href="#maintenance-michaelfaith" title="Maintenance">🚧</a> <a href="#ideas-michaelfaith" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Amichaelfaith" title="Bug reports">🐛</a> <a href="#tool-michaelfaith" title="Tools">🔧</a></td>
|
|
220
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/michaelfaith"><img src="https://avatars.githubusercontent.com/u/8071845?v=4?s=100" width="100px;" alt="michael faith"/><br /><sub><b>michael faith</b></sub></a><br /><a href="#infra-michaelfaith" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=michaelfaith" title="Code">💻</a> <a href="#maintenance-michaelfaith" title="Maintenance">🚧</a> <a href="#ideas-michaelfaith" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Amichaelfaith" title="Bug reports">🐛</a> <a href="#tool-michaelfaith" title="Tools">🔧</a> <a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=michaelfaith" title="Documentation">📖</a></td>
|
|
201
221
|
<td align="center" valign="top" width="14.28%"><a href="https://roottool.vercel.app"><img src="https://avatars.githubusercontent.com/u/11808736?v=4?s=100" width="100px;" alt="roottool"/><br /><sub><b>roottool</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commits?author=roottool" title="Code">💻</a></td>
|
|
202
222
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sunnytsang1998"><img src="https://avatars.githubusercontent.com/u/207208443?v=4?s=100" width="100px;" alt="sunnytsang1998"/><br /><sub><b>sunnytsang1998</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=author%3Asunnytsang1998" title="Bug reports">🐛</a></td>
|
|
203
223
|
</tr>
|
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
|
};
|
|
@@ -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.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": {
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"lint:knip": "knip",
|
|
37
37
|
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
|
|
38
38
|
"lint:packages": "pnpm dedupe --check",
|
|
39
|
-
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
|
40
39
|
"prepare": "husky",
|
|
41
40
|
"test": "vitest",
|
|
42
41
|
"typecheck": "tsc"
|
|
@@ -47,10 +46,10 @@
|
|
|
47
46
|
"dependencies": {
|
|
48
47
|
"@altano/repository-tools": "^1.0.0",
|
|
49
48
|
"change-case": "^5.4.4",
|
|
50
|
-
"detect-indent": "7.0.1",
|
|
51
|
-
"detect-newline": "4.0.1",
|
|
52
|
-
"eslint-fix-utils": "
|
|
53
|
-
"package-json-validator": "~0.
|
|
49
|
+
"detect-indent": "^7.0.1",
|
|
50
|
+
"detect-newline": "^4.0.1",
|
|
51
|
+
"eslint-fix-utils": "~0.4.0",
|
|
52
|
+
"package-json-validator": "~0.17.0",
|
|
54
53
|
"semver": "^7.5.4",
|
|
55
54
|
"sort-object-keys": "^1.1.3",
|
|
56
55
|
"sort-package-json": "^3.0.0",
|
|
@@ -70,11 +69,10 @@
|
|
|
70
69
|
"@vitest/eslint-plugin": "1.2.0",
|
|
71
70
|
"console-fail-test": "0.5.0",
|
|
72
71
|
"create-typescript-app": "2.42.0",
|
|
73
|
-
"cspell": "9.1.1",
|
|
74
72
|
"eslint": "9.29.0",
|
|
75
|
-
"eslint-doc-generator": "2.
|
|
76
|
-
"eslint-plugin-eslint-plugin": "6.
|
|
77
|
-
"eslint-plugin-jsdoc": "51.
|
|
73
|
+
"eslint-doc-generator": "2.2.0",
|
|
74
|
+
"eslint-plugin-eslint-plugin": "6.5.0",
|
|
75
|
+
"eslint-plugin-jsdoc": "51.2.1",
|
|
78
76
|
"eslint-plugin-jsonc": "2.20.0",
|
|
79
77
|
"eslint-plugin-markdown": "5.1.0",
|
|
80
78
|
"eslint-plugin-n": "17.20.0",
|
|
@@ -88,7 +86,7 @@
|
|
|
88
86
|
"lint-staged": "16.1.0",
|
|
89
87
|
"markdownlint": "0.38.0",
|
|
90
88
|
"markdownlint-cli": "0.45.0",
|
|
91
|
-
"prettier": "3.
|
|
89
|
+
"prettier": "3.6.0",
|
|
92
90
|
"prettier-plugin-curly": "0.3.1",
|
|
93
91
|
"prettier-plugin-packagejson": "2.5.10",
|
|
94
92
|
"prettier-plugin-sh": "0.17.1",
|
|
@@ -96,7 +94,7 @@
|
|
|
96
94
|
"sentences-per-line": "0.3.0",
|
|
97
95
|
"tsup": "8.5.0",
|
|
98
96
|
"typescript": "5.8.2",
|
|
99
|
-
"typescript-eslint": "8.
|
|
97
|
+
"typescript-eslint": "8.35.0",
|
|
100
98
|
"vitest": "3.2.0"
|
|
101
99
|
},
|
|
102
100
|
"peerDependencies": {
|