eslint-plugin-package-json 0.44.1 → 0.45.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 +2 -1
- package/lib/plugin.js +2 -0
- package/lib/rules/valid-license.d.ts +11 -0
- package/lib/rules/valid-license.js +40 -0
- package/lib/rules/valid-repository-directory.js +2 -4
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.
|
|
3
|
+
## [0.45.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.45.0...v0.45.1) (2025-07-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **valid-repository-directory:** use correct path separator when on windows ([#1177](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1177)) ([0688419](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/06884197a028a258c31db0104d8db1dc86f53345)), closes [#1175](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1175)
|
|
4
9
|
|
|
10
|
+
# [0.45.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.44.1...v0.45.0) (2025-07-17)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **valid-license:** add new rule for validating `license` ([#1174](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1174)) ([df450a1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/df450a121067793af25890eb15e4120911a8cfa7)), closes [#830](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/830)
|
|
15
|
+
|
|
16
|
+
## [0.44.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.44.0...v0.44.1) (2025-07-10)
|
|
5
17
|
|
|
6
18
|
### Bug Fixes
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- **deps:** update dependency package-json-validator to ~0.20.0 ([#1170](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1170)) ([941cf73](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/941cf734557db103da915d36de5adc18083a22a1))
|
|
9
21
|
|
|
10
22
|
# [0.44.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.43.4...v0.44.0) (2025-07-09)
|
|
11
23
|
|
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
140
140
|
| [valid-author](docs/rules/valid-author.md) | Enforce that the author field is a valid npm author specification | ✔️ ✅ | | | |
|
|
141
141
|
| [valid-bin](docs/rules/valid-bin.md) | Enforce that the `bin` property is valid. | ✔️ ✅ | | 💡 | |
|
|
142
142
|
| [valid-bundleDependencies](docs/rules/valid-bundleDependencies.md) | Enforce that the `bundleDependencies` (or `bundledDependencies`) property is valid. | ✔️ ✅ | | | |
|
|
143
|
+
| [valid-license](docs/rules/valid-license.md) | Enforce that the `license` property is valid. | ✔️ ✅ | | | |
|
|
143
144
|
| [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json | | | | ❌ |
|
|
144
145
|
| [valid-name](docs/rules/valid-name.md) | Enforce that package names are valid npm package names | ✔️ ✅ | | | |
|
|
145
146
|
| [valid-package-definition](docs/rules/valid-package-definition.md) | Enforce that package.json has all properties required by the npm spec | ✔️ ✅ | | | |
|
|
@@ -197,7 +198,7 @@ Thanks! 🗂
|
|
|
197
198
|
</tr>
|
|
198
199
|
<tr>
|
|
199
200
|
<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>
|
|
200
|
-
<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></td>
|
|
201
|
+
<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>
|
|
201
202
|
<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>
|
|
202
203
|
<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></td>
|
|
203
204
|
<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>
|
package/lib/plugin.js
CHANGED
|
@@ -11,6 +11,7 @@ import { rule as uniqueDependencies } from "./rules/unique-dependencies.js";
|
|
|
11
11
|
import { rule as validAuthor } from "./rules/valid-author.js";
|
|
12
12
|
import { rule as validBin } from "./rules/valid-bin.js";
|
|
13
13
|
import { rule as validBundleDependencies } from "./rules/valid-bundleDependencies.js";
|
|
14
|
+
import { rule as validLicense } from "./rules/valid-license.js";
|
|
14
15
|
import { rule as validLocalDependency } from "./rules/valid-local-dependency.js";
|
|
15
16
|
import { rule as validName } from "./rules/valid-name.js";
|
|
16
17
|
import { rule as validPackageDefinition } from "./rules/valid-package-definition.js";
|
|
@@ -32,6 +33,7 @@ const rules = {
|
|
|
32
33
|
"valid-author": validAuthor,
|
|
33
34
|
"valid-bin": validBin,
|
|
34
35
|
"valid-bundleDependencies": validBundleDependencies,
|
|
36
|
+
"valid-license": validLicense,
|
|
35
37
|
"valid-local-dependency": validLocalDependency,
|
|
36
38
|
"valid-name": validName,
|
|
37
39
|
"valid-package-definition": validPackageDefinition,
|
|
@@ -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 { validateLicense } 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=license]"(node) {
|
|
8
|
+
const valueNode = node.value;
|
|
9
|
+
const value = JSON.parse(
|
|
10
|
+
context.sourceCode.getText(valueNode)
|
|
11
|
+
);
|
|
12
|
+
const errors = validateLicense(value);
|
|
13
|
+
if (errors.length) {
|
|
14
|
+
context.report({
|
|
15
|
+
data: {
|
|
16
|
+
errors: formatErrors(errors)
|
|
17
|
+
},
|
|
18
|
+
messageId: "validationError",
|
|
19
|
+
node: valueNode
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
meta: {
|
|
26
|
+
docs: {
|
|
27
|
+
category: "Best Practices",
|
|
28
|
+
description: "Enforce that the `license` property is valid.",
|
|
29
|
+
recommended: true
|
|
30
|
+
},
|
|
31
|
+
messages: {
|
|
32
|
+
validationError: "Invalid license: {{ errors }}"
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
type: "problem"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
rule
|
|
40
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { findRootSync } from "@altano/repository-tools";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { sep as posixSep } from "node:path/posix";
|
|
3
4
|
import { createRule } from "../createRule.js";
|
|
4
5
|
import { findPropertyWithKeyValue } from "../utils/findPropertyWithKeyValue.js";
|
|
5
6
|
function pathEndsWith(parent, child) {
|
|
@@ -42,10 +43,7 @@ const rule = createRule({
|
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
} else {
|
|
45
|
-
const expected = path.relative(
|
|
46
|
-
repositoryRoot,
|
|
47
|
-
fileDirectory
|
|
48
|
-
);
|
|
46
|
+
const expected = path.relative(repositoryRoot, fileDirectory).replaceAll(path.sep, posixSep);
|
|
49
47
|
if (expected !== directoryValue) {
|
|
50
48
|
context.report({
|
|
51
49
|
messageId: "mismatched",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.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": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"detect-indent": "^7.0.1",
|
|
50
50
|
"detect-newline": "^4.0.1",
|
|
51
51
|
"eslint-fix-utils": "~0.4.0",
|
|
52
|
-
"package-json-validator": "~0.
|
|
52
|
+
"package-json-validator": "~0.22.0",
|
|
53
53
|
"semver": "^7.5.4",
|
|
54
54
|
"sort-object-keys": "^1.1.3",
|
|
55
55
|
"sort-package-json": "^3.0.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"eslint-plugin-jsdoc": "51.3.1",
|
|
76
76
|
"eslint-plugin-jsonc": "2.20.0",
|
|
77
77
|
"eslint-plugin-markdown": "5.1.0",
|
|
78
|
-
"eslint-plugin-n": "17.
|
|
78
|
+
"eslint-plugin-n": "17.21.0",
|
|
79
79
|
"eslint-plugin-perfectionist": "4.15.0",
|
|
80
80
|
"eslint-plugin-regexp": "2.9.0",
|
|
81
81
|
"eslint-plugin-yml": "1.18.0",
|
|
@@ -94,14 +94,14 @@
|
|
|
94
94
|
"sentences-per-line": "0.3.0",
|
|
95
95
|
"tsup": "8.5.0",
|
|
96
96
|
"typescript": "5.8.2",
|
|
97
|
-
"typescript-eslint": "8.
|
|
97
|
+
"typescript-eslint": "8.36.0",
|
|
98
98
|
"vitest": "3.2.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
101
|
"eslint": ">=8.0.0",
|
|
102
102
|
"jsonc-eslint-parser": "^2.0.0"
|
|
103
103
|
},
|
|
104
|
-
"packageManager": "pnpm@10.
|
|
104
|
+
"packageManager": "pnpm@10.13.0",
|
|
105
105
|
"engines": {
|
|
106
106
|
"node": "^=20.19.0 || >=22.12.0"
|
|
107
107
|
},
|