npm-pkg-lint 3.6.8 → 3.7.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/README.md +2 -0
- package/dist/index.js +44 -15
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -218,6 +218,8 @@ Examples of obsolete packages:
|
|
|
218
218
|
- `mkdirp` - `fs#mkdir` supports the `recursive` flag since NodeJS v10.
|
|
219
219
|
- `stable` - `Array#sort` is stable since NodeJS v12.
|
|
220
220
|
|
|
221
|
+
If needed, `--allow-dependency` can be used to ignore one or more dependencies.
|
|
222
|
+
|
|
221
223
|
## Shebang
|
|
222
224
|
|
|
223
225
|
Require all binaries to have UNIX-style shebang at the beginning of the file.
|
package/dist/index.js
CHANGED
|
@@ -19792,43 +19792,72 @@ async function npmInfo(pkg, options = { ignoreUnpublished: false }) {
|
|
|
19792
19792
|
|
|
19793
19793
|
// src/rules/deprecated-dependency.ts
|
|
19794
19794
|
var ruleId2 = "no-deprecated-dependency";
|
|
19795
|
+
function createEntry(key, version3, source) {
|
|
19796
|
+
if (version3.startsWith("npm:")) {
|
|
19797
|
+
const [newKey, newVersion] = version3.slice("npm:".length).split("@", 2);
|
|
19798
|
+
key = newKey;
|
|
19799
|
+
version3 = newVersion;
|
|
19800
|
+
}
|
|
19801
|
+
if (key === "@types/node") {
|
|
19802
|
+
return null;
|
|
19803
|
+
}
|
|
19804
|
+
const minVersion = import_semver.default.minVersion(version3);
|
|
19805
|
+
return {
|
|
19806
|
+
name: key,
|
|
19807
|
+
version: version3,
|
|
19808
|
+
spec: `${key}@${minVersion ? minVersion.version : version3}`,
|
|
19809
|
+
source
|
|
19810
|
+
};
|
|
19811
|
+
}
|
|
19795
19812
|
function* getDependencies(pkg) {
|
|
19796
19813
|
const { dependencies = {}, devDependencies = {}, peerDependencies = {} } = pkg;
|
|
19797
|
-
const
|
|
19798
|
-
|
|
19799
|
-
if (
|
|
19800
|
-
|
|
19801
|
-
key = newKey;
|
|
19802
|
-
version3 = newVersion;
|
|
19814
|
+
for (const [key, version3] of Object.entries(dependencies)) {
|
|
19815
|
+
const entry = createEntry(key, version3, "dependencies");
|
|
19816
|
+
if (entry) {
|
|
19817
|
+
yield entry;
|
|
19803
19818
|
}
|
|
19804
|
-
|
|
19805
|
-
|
|
19819
|
+
}
|
|
19820
|
+
for (const [key, version3] of Object.entries(devDependencies)) {
|
|
19821
|
+
const entry = createEntry(key, version3, "devDependencies");
|
|
19822
|
+
if (entry) {
|
|
19823
|
+
yield entry;
|
|
19824
|
+
}
|
|
19825
|
+
}
|
|
19826
|
+
for (const [key, version3] of Object.entries(peerDependencies)) {
|
|
19827
|
+
const entry = createEntry(key, version3, "peerDependencies");
|
|
19828
|
+
if (entry) {
|
|
19829
|
+
yield entry;
|
|
19806
19830
|
}
|
|
19807
|
-
const minVersion = import_semver.default.minVersion(version3);
|
|
19808
|
-
yield `${key}@${minVersion ? minVersion.version : version3}`;
|
|
19809
19831
|
}
|
|
19810
19832
|
}
|
|
19811
|
-
async function deprecatedDependency(pkg) {
|
|
19833
|
+
async function deprecatedDependency(pkg, options) {
|
|
19834
|
+
const { allowedDependencies: allowedDependencies2 } = options;
|
|
19812
19835
|
const messages = [];
|
|
19813
19836
|
for await (const dependency of getDependencies(pkg)) {
|
|
19837
|
+
if (allowedDependencies2.has(dependency.name)) {
|
|
19838
|
+
continue;
|
|
19839
|
+
}
|
|
19814
19840
|
try {
|
|
19815
|
-
const { deprecated } = await npmInfo(dependency);
|
|
19841
|
+
const { deprecated } = await npmInfo(dependency.spec);
|
|
19816
19842
|
if (!deprecated) {
|
|
19817
19843
|
continue;
|
|
19818
19844
|
}
|
|
19819
19845
|
messages.push({
|
|
19820
19846
|
ruleId: ruleId2,
|
|
19821
19847
|
severity: 2,
|
|
19822
|
-
message: `"${dependency}" is deprecated and must not be used`,
|
|
19848
|
+
message: `"${dependency.spec}" is deprecated and must not be used`,
|
|
19823
19849
|
line: 1,
|
|
19824
19850
|
column: 1
|
|
19825
19851
|
});
|
|
19826
19852
|
} catch (err) {
|
|
19827
19853
|
if (isNpmInfoError(err) && err.code === "E404") {
|
|
19854
|
+
if (dependency.source === "devDependencies") {
|
|
19855
|
+
continue;
|
|
19856
|
+
}
|
|
19828
19857
|
messages.push({
|
|
19829
19858
|
ruleId: ruleId2,
|
|
19830
19859
|
severity: 1,
|
|
19831
|
-
message: `the dependency "${dependency}" is not published to the NPM registry`,
|
|
19860
|
+
message: `the dependency "${dependency.spec}" is not published to the NPM registry`,
|
|
19832
19861
|
line: 1,
|
|
19833
19862
|
column: 1
|
|
19834
19863
|
});
|
|
@@ -20264,7 +20293,7 @@ function verifyDependencies(pkg, options) {
|
|
|
20264
20293
|
async function verifyPackageJson(pkg, filePath, options = { allowedDependencies: /* @__PURE__ */ new Set(), ignoreNodeVersion: false }) {
|
|
20265
20294
|
const { ignoreNodeVersion } = options;
|
|
20266
20295
|
const messages = [
|
|
20267
|
-
...await deprecatedDependency(pkg),
|
|
20296
|
+
...await deprecatedDependency(pkg, options),
|
|
20268
20297
|
...await verifyEngineConstraint(pkg),
|
|
20269
20298
|
...exportsTypesOrder(pkg),
|
|
20270
20299
|
...verifyFields(pkg, options),
|