eslint-plugin-node-dependencies 0.11.2 → 0.13.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/README.md +32 -3
- package/dist/configs/flat/recommended.d.ts +17 -0
- package/dist/configs/flat/recommended.js +57 -0
- package/dist/configs/recommended.d.ts +9 -0
- package/dist/configs/recommended.js +5 -5
- package/dist/configs/rules/recommended.d.ts +5 -0
- package/dist/configs/rules/recommended.js +9 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +19 -7
- package/dist/meta.d.ts +1 -0
- package/dist/rules/absolute-version.d.ts +2 -0
- package/dist/rules/compat-engines.d.ts +2 -0
- package/dist/rules/compat-engines.js +1 -1
- package/dist/rules/no-deprecated.d.ts +2 -0
- package/dist/rules/no-dupe-deps.d.ts +2 -0
- package/dist/rules/no-restricted-deps.d.ts +2 -0
- package/dist/rules/prefer-caret-range-version.d.ts +2 -0
- package/dist/rules/prefer-tilde-range-version.d.ts +2 -0
- package/dist/rules/valid-engines.d.ts +2 -0
- package/dist/rules/valid-semver.d.ts +2 -0
- package/dist/types.d.ts +51 -0
- package/dist/utils/ast-utils.d.ts +3 -0
- package/dist/utils/ast-utils.js +2 -3
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +3 -4
- package/dist/utils/meta.d.ts +25 -0
- package/dist/utils/meta.js +23 -14
- package/dist/utils/package-json/index.d.ts +4 -0
- package/dist/utils/package-json/index.js +11 -1
- package/dist/utils/package-json/worker.d.ts +1 -0
- package/dist/utils/regexp.d.ts +3 -0
- package/dist/utils/regexp.js +1 -2
- package/dist/utils/rules.d.ts +2 -0
- package/dist/utils/semver-range.d.ts +7 -0
- package/dist/utils/semver-range.js +1 -2
- package/dist/utils/semver.d.ts +7 -0
- package/dist/utils/semver.js +5 -6
- package/package.json +3 -70
package/README.md
CHANGED
|
@@ -41,13 +41,27 @@ npm install --save-dev eslint eslint-plugin-node-dependencies
|
|
|
41
41
|
|
|
42
42
|
<!--USAGE_SECTION_START-->
|
|
43
43
|
|
|
44
|
-
Add `node-dependencies` to the plugins section of your `.eslintrc` configuration file (you can omit the `eslint-plugin-` prefix)
|
|
44
|
+
Add `node-dependencies` to the plugins section of your `eslint.config.js` or `.eslintrc` configuration file (you can omit the `eslint-plugin-` prefix)
|
|
45
45
|
and either use one of the two configurations available (`recommended`) or configure the rules you want:
|
|
46
46
|
|
|
47
|
-
### The recommended configuration
|
|
47
|
+
### The recommended configuration (New Config)
|
|
48
|
+
|
|
49
|
+
The `plugin.configs["flat/recommended"]` config enables a subset of [the rules](#white_check_mark-rules) that should be most useful to most users.
|
|
50
|
+
*See [lib/configs/rules/recommended.ts](https://github.com/ota-meshi/eslint-plugin-node-dependencies/blob/main/lib/configs/rules/recommended.ts) for more details.*
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
// eslint.config.js
|
|
54
|
+
import * as nodeDependenciesPlugin from "eslint-plugin-node-dependencies"
|
|
55
|
+
|
|
56
|
+
export default [
|
|
57
|
+
...nodeDependenciesPlugin.configs["flat/recommended"],
|
|
58
|
+
];
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### The recommended configuration (Legacy Config)
|
|
48
62
|
|
|
49
63
|
The `plugin:node-dependencies/recommended` config enables a subset of [the rules](#white_check_mark-rules) that should be most useful to most users.
|
|
50
|
-
*See [lib/configs/recommended.ts](https://github.com/ota-meshi/eslint-plugin-node-dependencies/blob/main/lib/configs/recommended.ts) for more details.*
|
|
64
|
+
*See [lib/configs/rules/recommended.ts](https://github.com/ota-meshi/eslint-plugin-node-dependencies/blob/main/lib/configs/rules/recommended.ts) for more details.*
|
|
51
65
|
|
|
52
66
|
```js
|
|
53
67
|
// .eslintrc.js
|
|
@@ -67,6 +81,21 @@ module.exports = {
|
|
|
67
81
|
|
|
68
82
|
Override/add specific rules configurations. *See also: [http://eslint.org/docs/user-guide/configuring](http://eslint.org/docs/user-guide/configuring)*.
|
|
69
83
|
|
|
84
|
+
```js
|
|
85
|
+
// eslint.config.js
|
|
86
|
+
import * as nodeDependenciesPlugin from "eslint-plugin-node-dependencies"
|
|
87
|
+
|
|
88
|
+
export default [
|
|
89
|
+
{
|
|
90
|
+
plugins: { "node-dependencies": nodeDependenciesPlugin }
|
|
91
|
+
rules: {
|
|
92
|
+
// Override/add rules settings here, such as:
|
|
93
|
+
"node-dependencies/rule-name": "error"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
```
|
|
98
|
+
|
|
70
99
|
```js
|
|
71
100
|
// .eslintrc.js
|
|
72
101
|
module.exports = {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ESLint, Linter } from "eslint";
|
|
2
|
+
import * as jsonParser from "jsonc-eslint-parser";
|
|
3
|
+
export declare const recommendedConfig: ({
|
|
4
|
+
plugins: {
|
|
5
|
+
readonly "node-dependencies": ESLint.Plugin;
|
|
6
|
+
};
|
|
7
|
+
files?: undefined;
|
|
8
|
+
languageOptions?: undefined;
|
|
9
|
+
rules?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
files: string[];
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parser: typeof jsonParser;
|
|
14
|
+
};
|
|
15
|
+
rules: Linter.RulesRecord;
|
|
16
|
+
plugins?: undefined;
|
|
17
|
+
})[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.recommendedConfig = void 0;
|
|
40
|
+
const recommended_1 = __importDefault(require("../rules/recommended"));
|
|
41
|
+
const jsonParser = __importStar(require("jsonc-eslint-parser"));
|
|
42
|
+
exports.recommendedConfig = [
|
|
43
|
+
{
|
|
44
|
+
plugins: {
|
|
45
|
+
get "node-dependencies"() {
|
|
46
|
+
return require("../../index");
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
files: ["**/package.json", "package.json"],
|
|
52
|
+
languageOptions: {
|
|
53
|
+
parser: jsonParser,
|
|
54
|
+
},
|
|
55
|
+
rules: recommended_1.default.rules,
|
|
56
|
+
},
|
|
57
|
+
];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const recommended_1 = __importDefault(require("./rules/recommended"));
|
|
2
6
|
module.exports = {
|
|
3
7
|
plugins: ["node-dependencies"],
|
|
4
8
|
overrides: [
|
|
5
9
|
{
|
|
6
10
|
files: ["package.json"],
|
|
7
11
|
parser: require.resolve("jsonc-eslint-parser"),
|
|
8
|
-
rules:
|
|
9
|
-
"node-dependencies/compat-engines": "error",
|
|
10
|
-
"node-dependencies/no-dupe-deps": "error",
|
|
11
|
-
"node-dependencies/valid-semver": "error",
|
|
12
|
-
},
|
|
12
|
+
rules: recommended_1.default.rules,
|
|
13
13
|
},
|
|
14
14
|
],
|
|
15
15
|
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RuleModule } from "./types";
|
|
2
|
+
import * as meta from "./meta";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
meta: typeof meta;
|
|
5
|
+
configs: {
|
|
6
|
+
recommended: {
|
|
7
|
+
plugins: string[];
|
|
8
|
+
overrides: {
|
|
9
|
+
files: string[];
|
|
10
|
+
parser: string;
|
|
11
|
+
rules: import("eslint").Linter.RulesRecord;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
"flat/recommended": ({
|
|
15
|
+
plugins: {
|
|
16
|
+
readonly "node-dependencies": import("eslint").ESLint.Plugin;
|
|
17
|
+
};
|
|
18
|
+
files?: undefined;
|
|
19
|
+
languageOptions?: undefined;
|
|
20
|
+
rules?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
files: string[];
|
|
23
|
+
languageOptions: {
|
|
24
|
+
parser: typeof import("jsonc-eslint-parser");
|
|
25
|
+
};
|
|
26
|
+
rules: import("eslint").Linter.RulesRecord;
|
|
27
|
+
plugins?: undefined;
|
|
28
|
+
})[];
|
|
29
|
+
};
|
|
30
|
+
rules: {
|
|
31
|
+
[key: string]: RuleModule;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export = _default;
|
package/dist/index.js
CHANGED
|
@@ -15,21 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
const rules_1 = require("./utils/rules");
|
|
29
39
|
const recommended_1 = __importDefault(require("./configs/recommended"));
|
|
40
|
+
const recommended_2 = require("./configs/flat/recommended");
|
|
30
41
|
const meta = __importStar(require("./meta"));
|
|
31
42
|
const configs = {
|
|
32
43
|
recommended: recommended_1.default,
|
|
44
|
+
"flat/recommended": recommended_2.recommendedConfig,
|
|
33
45
|
};
|
|
34
46
|
const rules = rules_1.rules.reduce((obj, r) => {
|
|
35
47
|
obj[r.meta.docs.ruleName] = r;
|
package/dist/meta.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const name: any, version: any;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { JSONSchema4 } from "json-schema";
|
|
2
|
+
import type { Rule } from "eslint";
|
|
3
|
+
export interface RuleListener {
|
|
4
|
+
[key: string]: ((node: never) => void) | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface RuleModule {
|
|
7
|
+
meta: RuleMetaData;
|
|
8
|
+
create: (context: Rule.RuleContext) => RuleListener;
|
|
9
|
+
}
|
|
10
|
+
export type RuleCategory = "Possible Errors" | "Best Practices" | "Stylistic Issues";
|
|
11
|
+
export interface RuleMetaData {
|
|
12
|
+
docs: {
|
|
13
|
+
description: string;
|
|
14
|
+
category: RuleCategory;
|
|
15
|
+
recommended: boolean;
|
|
16
|
+
url: string;
|
|
17
|
+
ruleId: string;
|
|
18
|
+
ruleName: string;
|
|
19
|
+
default?: "error" | "warn";
|
|
20
|
+
};
|
|
21
|
+
messages: {
|
|
22
|
+
[messageId: string]: string;
|
|
23
|
+
};
|
|
24
|
+
fixable?: "code" | "whitespace";
|
|
25
|
+
hasSuggestions?: boolean;
|
|
26
|
+
schema: JSONSchema4 | JSONSchema4[];
|
|
27
|
+
deprecated?: boolean;
|
|
28
|
+
replacedBy?: string[];
|
|
29
|
+
type: "problem" | "suggestion" | "layout";
|
|
30
|
+
}
|
|
31
|
+
export interface PartialRuleModule {
|
|
32
|
+
meta: PartialRuleMetaData;
|
|
33
|
+
create: (context: Rule.RuleContext) => RuleListener;
|
|
34
|
+
}
|
|
35
|
+
export interface PartialRuleMetaData {
|
|
36
|
+
docs: {
|
|
37
|
+
description: string;
|
|
38
|
+
category: RuleCategory;
|
|
39
|
+
recommended: boolean;
|
|
40
|
+
default?: "error" | "warn";
|
|
41
|
+
};
|
|
42
|
+
messages: {
|
|
43
|
+
[messageId: string]: string;
|
|
44
|
+
};
|
|
45
|
+
fixable?: "code" | "whitespace";
|
|
46
|
+
hasSuggestions?: boolean;
|
|
47
|
+
schema: JSONSchema4 | JSONSchema4[];
|
|
48
|
+
deprecated?: boolean;
|
|
49
|
+
replacedBy?: string[];
|
|
50
|
+
type: "problem" | "suggestion" | "layout";
|
|
51
|
+
}
|
package/dist/utils/ast-utils.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getKeyFromJSONProperty = getKeyFromJSONProperty;
|
|
4
|
+
exports.getKey = getKey;
|
|
4
5
|
function getKeyFromJSONProperty(node) {
|
|
5
6
|
if (node.key.type === "JSONIdentifier") {
|
|
6
7
|
return node.key.name;
|
|
7
8
|
}
|
|
8
9
|
return node.key.value;
|
|
9
10
|
}
|
|
10
|
-
exports.getKeyFromJSONProperty = getKeyFromJSONProperty;
|
|
11
11
|
function getKey(node) {
|
|
12
12
|
let parent = node.parent;
|
|
13
13
|
while (parent.type === "JSONUnaryExpression" ||
|
|
@@ -22,4 +22,3 @@ function getKey(node) {
|
|
|
22
22
|
}
|
|
23
23
|
return getKeyFromJSONProperty(parent);
|
|
24
24
|
}
|
|
25
|
-
exports.getKey = getKey;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RuleModule, PartialRuleModule, RuleListener } from "../types";
|
|
2
|
+
import type { AST } from "jsonc-eslint-parser";
|
|
3
|
+
export declare function createRule(ruleName: string, rule: PartialRuleModule): RuleModule;
|
|
4
|
+
export declare function defineJsonVisitor(visitor: Record<string, ((node: AST.JSONProperty) => void) | undefined>): RuleListener;
|
|
5
|
+
export declare function compositingVisitors(visitor: RuleListener, ...visitors: RuleListener[]): RuleListener;
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createRule = createRule;
|
|
4
|
+
exports.defineJsonVisitor = defineJsonVisitor;
|
|
5
|
+
exports.compositingVisitors = compositingVisitors;
|
|
4
6
|
const ast_utils_1 = require("./ast-utils");
|
|
5
7
|
function createRule(ruleName, rule) {
|
|
6
8
|
return {
|
|
@@ -8,7 +10,6 @@ function createRule(ruleName, rule) {
|
|
|
8
10
|
create: rule.create,
|
|
9
11
|
};
|
|
10
12
|
}
|
|
11
|
-
exports.createRule = createRule;
|
|
12
13
|
function defineJsonVisitor(visitor) {
|
|
13
14
|
let stack = null;
|
|
14
15
|
const visitors = [];
|
|
@@ -52,7 +53,6 @@ function defineJsonVisitor(visitor) {
|
|
|
52
53
|
},
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
exports.defineJsonVisitor = defineJsonVisitor;
|
|
56
56
|
function compositingVisitors(visitor, ...visitors) {
|
|
57
57
|
for (const v of visitors) {
|
|
58
58
|
for (const key in v) {
|
|
@@ -70,4 +70,3 @@ function compositingVisitors(visitor, ...visitors) {
|
|
|
70
70
|
}
|
|
71
71
|
return visitor;
|
|
72
72
|
}
|
|
73
|
-
exports.compositingVisitors = compositingVisitors;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
export type PackageMeta = {
|
|
3
|
+
engines: Record<string, string | undefined> | undefined;
|
|
4
|
+
dependencies: Record<string, string | undefined> | undefined;
|
|
5
|
+
peerDependencies: Record<string, string | undefined> | undefined;
|
|
6
|
+
optionalDependencies: Record<string, string | undefined> | undefined;
|
|
7
|
+
version: string | undefined;
|
|
8
|
+
_where?: string;
|
|
9
|
+
};
|
|
10
|
+
export type NpmPackageMeta = PackageMeta & {
|
|
11
|
+
deprecated: string | undefined;
|
|
12
|
+
"dist-tags": {
|
|
13
|
+
[key: string]: string | void;
|
|
14
|
+
} | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare function getMetaFromNodeModules(name: string, ver: string, options: {
|
|
17
|
+
context: Rule.RuleContext;
|
|
18
|
+
ownerPackageJsonPath?: string;
|
|
19
|
+
}): PackageMeta | null;
|
|
20
|
+
export declare function getMetaFromNpm(name: string, ver: string): {
|
|
21
|
+
cache: NpmPackageMeta[];
|
|
22
|
+
get: () => NpmPackageMeta[] | null;
|
|
23
|
+
};
|
|
24
|
+
export declare function getEngines(meta: unknown): Map<string, string>;
|
|
25
|
+
export declare function getDependencies(meta: unknown, kind: "dependencies" | "peerDependencies" | "optionalDependencies"): Map<string, string>;
|
package/dist/utils/meta.js
CHANGED
|
@@ -15,18 +15,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.getMetaFromNodeModules = getMetaFromNodeModules;
|
|
40
|
+
exports.getMetaFromNpm = getMetaFromNpm;
|
|
41
|
+
exports.getEngines = getEngines;
|
|
42
|
+
exports.getDependencies = getDependencies;
|
|
30
43
|
const module_1 = __importDefault(require("module"));
|
|
31
44
|
const path_1 = __importStar(require("path"));
|
|
32
45
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -54,11 +67,10 @@ function getMetaFromNodeModules(name, ver, options) {
|
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
|
-
catch (
|
|
70
|
+
catch (_a) {
|
|
58
71
|
}
|
|
59
72
|
return null;
|
|
60
73
|
}
|
|
61
|
-
exports.getMetaFromNodeModules = getMetaFromNodeModules;
|
|
62
74
|
function getMetaFromNpm(name, ver) {
|
|
63
75
|
var _a;
|
|
64
76
|
const trimmed = ver.trim();
|
|
@@ -81,7 +93,6 @@ function getMetaFromNpm(name, ver) {
|
|
|
81
93
|
}
|
|
82
94
|
return getMetaFromNameAndSpec(name, ver.trim());
|
|
83
95
|
}
|
|
84
|
-
exports.getMetaFromNpm = getMetaFromNpm;
|
|
85
96
|
function getMetaFromNameAndSpec(name, verOrTag) {
|
|
86
97
|
const cachedFilePath = path_1.default.join(CACHED_META_ROOT, `${name}.json`);
|
|
87
98
|
const { cache, get } = getMetaFromName(name, cachedFilePath);
|
|
@@ -196,7 +207,7 @@ function getMetaFromNameWithoutCache(name, cachedFilePath) {
|
|
|
196
207
|
};
|
|
197
208
|
});
|
|
198
209
|
}
|
|
199
|
-
catch (
|
|
210
|
+
catch (_a) {
|
|
200
211
|
return null;
|
|
201
212
|
}
|
|
202
213
|
const timestamp = Date.now();
|
|
@@ -215,14 +226,12 @@ function getEngines(meta) {
|
|
|
215
226
|
}
|
|
216
227
|
return getStrMap(meta.engines);
|
|
217
228
|
}
|
|
218
|
-
exports.getEngines = getEngines;
|
|
219
229
|
function getDependencies(meta, kind) {
|
|
220
230
|
if (!maybeMeta(meta)) {
|
|
221
231
|
return new Map();
|
|
222
232
|
}
|
|
223
233
|
return getStrMap(meta[kind]);
|
|
224
234
|
}
|
|
225
|
-
exports.getDependencies = getDependencies;
|
|
226
235
|
function getStrMap(maybeObject) {
|
|
227
236
|
const map = new Map();
|
|
228
237
|
if (typeof maybeObject !== "object" ||
|
|
@@ -2,4 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.syncPackageJson = void 0;
|
|
4
4
|
const synckit_1 = require("synckit");
|
|
5
|
-
|
|
5
|
+
const module_1 = require("module");
|
|
6
|
+
exports.syncPackageJson = (0, synckit_1.createSyncFn)(getWorkerPath());
|
|
7
|
+
function getWorkerPath() {
|
|
8
|
+
try {
|
|
9
|
+
return require.resolve("./worker");
|
|
10
|
+
}
|
|
11
|
+
catch (_a) {
|
|
12
|
+
}
|
|
13
|
+
const r = (0, module_1.createRequire)(__filename);
|
|
14
|
+
return r.resolve(`./worker.ts`);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/regexp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toRegExp =
|
|
3
|
+
exports.toRegExp = toRegExp;
|
|
4
4
|
function toRegExp(str) {
|
|
5
5
|
const regexp = parseRegExp(str);
|
|
6
6
|
if (regexp) {
|
|
@@ -8,7 +8,6 @@ function toRegExp(str) {
|
|
|
8
8
|
}
|
|
9
9
|
return { test: (s) => s === str };
|
|
10
10
|
}
|
|
11
|
-
exports.toRegExp = toRegExp;
|
|
12
11
|
function parseRegExp(str) {
|
|
13
12
|
if (!str.startsWith("/")) {
|
|
14
13
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.iterateSemverRanges =
|
|
3
|
+
exports.iterateSemverRanges = iterateSemverRanges;
|
|
4
4
|
const semver_1 = require("./semver");
|
|
5
5
|
function* iterateSemverRanges(versionRanges) {
|
|
6
6
|
let startOffset = 0;
|
|
@@ -12,7 +12,6 @@ function* iterateSemverRanges(versionRanges) {
|
|
|
12
12
|
startOffset += strRange.length + 2;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
exports.iterateSemverRanges = iterateSemverRanges;
|
|
16
15
|
function toRangeResult(strRange, startOffset) {
|
|
17
16
|
let start = 0;
|
|
18
17
|
while (strRange.length > start && !strRange[start].trim()) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Comparator } from "semver";
|
|
2
|
+
import { Range, SemVer } from "semver";
|
|
3
|
+
export declare function getSemverRange(value: string | undefined | null): Range | null;
|
|
4
|
+
export declare function normalizeVer(ver: Range): string;
|
|
5
|
+
export declare function normalizeSemverRange(...values: Range[]): Range | null;
|
|
6
|
+
export declare function maxNextVersion(range: Range): SemVer | null;
|
|
7
|
+
export declare function isAnyComparator(comparator: Comparator): boolean;
|
package/dist/utils/semver.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getSemverRange = getSemverRange;
|
|
4
|
+
exports.normalizeVer = normalizeVer;
|
|
5
|
+
exports.normalizeSemverRange = normalizeSemverRange;
|
|
6
|
+
exports.maxNextVersion = maxNextVersion;
|
|
7
|
+
exports.isAnyComparator = isAnyComparator;
|
|
4
8
|
const semver_1 = require("semver");
|
|
5
9
|
function getSemverRange(value) {
|
|
6
10
|
if (value == null) {
|
|
@@ -13,7 +17,6 @@ function getSemverRange(value) {
|
|
|
13
17
|
return null;
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
|
-
exports.getSemverRange = getSemverRange;
|
|
17
20
|
function normalizeVer(ver) {
|
|
18
21
|
const n = normalizeSemverRange(ver);
|
|
19
22
|
if (n) {
|
|
@@ -21,7 +24,6 @@ function normalizeVer(ver) {
|
|
|
21
24
|
}
|
|
22
25
|
return ver.raw;
|
|
23
26
|
}
|
|
24
|
-
exports.normalizeVer = normalizeVer;
|
|
25
27
|
function normalizeSemverRange(...values) {
|
|
26
28
|
const map = new Map();
|
|
27
29
|
for (const ver of values) {
|
|
@@ -79,7 +81,6 @@ function normalizeSemverRange(...values) {
|
|
|
79
81
|
return min;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
exports.normalizeSemverRange = normalizeSemverRange;
|
|
83
84
|
function normalizeComparators(comparators) {
|
|
84
85
|
const rangeComparator = toRangeComparator(comparators);
|
|
85
86
|
if (rangeComparator && rangeComparator.min && rangeComparator.max) {
|
|
@@ -198,8 +199,6 @@ function maxNextVersion(range) {
|
|
|
198
199
|
}
|
|
199
200
|
return maxVer;
|
|
200
201
|
}
|
|
201
|
-
exports.maxNextVersion = maxNextVersion;
|
|
202
202
|
function isAnyComparator(comparator) {
|
|
203
203
|
return !comparator.semver.version;
|
|
204
204
|
}
|
|
205
|
-
exports.isAnyComparator = isAnyComparator;
|
package/package.json
CHANGED
|
@@ -1,36 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-node-dependencies",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "ESLint plugin to check Node.js dependencies.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.17.0"
|
|
7
7
|
},
|
|
8
8
|
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
9
10
|
"files": [
|
|
10
11
|
"dist"
|
|
11
12
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"prebuild": "npm run -s clean",
|
|
14
|
-
"build": "tsc --project ./tsconfig.build.json",
|
|
15
|
-
"clean": "rimraf .nyc_output dist coverage",
|
|
16
|
-
"lint": "eslint . --ext .js,.vue,.ts,.json,.yaml,.yml",
|
|
17
|
-
"eslint-fix": "eslint . --ext .js,.vue,.ts,.json,.yaml,.yml --fix",
|
|
18
|
-
"pretest": "npm run build",
|
|
19
|
-
"test:base": "mocha --require ts-node/register \"tests/**/*.ts\" --reporter dot --timeout 60000",
|
|
20
|
-
"test": "npm run test:nyc",
|
|
21
|
-
"test:nyc": "nyc --reporter=lcov npm run test:base",
|
|
22
|
-
"test:debug": "mocha --require ts-node/register/transpile-only \"tests/**/*.ts\" --reporter dot --timeout 60000",
|
|
23
|
-
"test:watch": "npm run test:base -- --watch",
|
|
24
|
-
"update": "ts-node --transpile-only ./tools/update.ts && npm run eslint-fix",
|
|
25
|
-
"new": "ts-node ./tools/new-rule.ts",
|
|
26
|
-
"docs:watch": "export NODE_OPTIONS=--openssl-legacy-provider && vuepress dev --debug docs",
|
|
27
|
-
"docs:build": "export NODE_OPTIONS=--openssl-legacy-provider && npm run build && vuepress build docs --no-cache",
|
|
28
|
-
"prerelease": "npm run test && npm run build",
|
|
29
|
-
"release": "changeset publish",
|
|
30
|
-
"preversion": "npm test && git add .",
|
|
31
|
-
"version": "env-cmd -e version npm run update && git add .",
|
|
32
|
-
"version:ci": "env-cmd -e version-ci npm run update && changeset version"
|
|
33
|
-
},
|
|
34
13
|
"repository": {
|
|
35
14
|
"type": "git",
|
|
36
15
|
"url": "git+https://github.com/ota-meshi/eslint-plugin-node-dependencies.git"
|
|
@@ -53,52 +32,6 @@
|
|
|
53
32
|
"peerDependencies": {
|
|
54
33
|
"eslint": ">=6.0.0"
|
|
55
34
|
},
|
|
56
|
-
"devDependencies": {
|
|
57
|
-
"@changesets/changelog-github": "^0.5.0",
|
|
58
|
-
"@changesets/cli": "^2.24.2",
|
|
59
|
-
"@ota-meshi/eslint-plugin": "^0.15.0",
|
|
60
|
-
"@types/chai": "^4.2.18",
|
|
61
|
-
"@types/eslint": "^8.0.0",
|
|
62
|
-
"@types/eslint-scope": "^3.7.0",
|
|
63
|
-
"@types/eslint-visitor-keys": "^1.0.0",
|
|
64
|
-
"@types/estree": "^1.0.0",
|
|
65
|
-
"@types/mocha": "^10.0.0",
|
|
66
|
-
"@types/node": "^20.0.0",
|
|
67
|
-
"@types/npm-package-arg": "^6.1.1",
|
|
68
|
-
"@types/semver": "^7.3.8",
|
|
69
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
70
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
71
|
-
"chai": "^5.0.0",
|
|
72
|
-
"env-cmd": "^10.1.0",
|
|
73
|
-
"eslint": "^8.0.0",
|
|
74
|
-
"eslint-compat-utils": "^0.4.0",
|
|
75
|
-
"eslint-config-prettier": "^9.0.0",
|
|
76
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
77
|
-
"eslint-plugin-eslint-plugin": "^5.0.0",
|
|
78
|
-
"eslint-plugin-json-schema-validator": "^4.0.0",
|
|
79
|
-
"eslint-plugin-jsonc": "^2.0.0",
|
|
80
|
-
"eslint-plugin-n": "^16.0.0",
|
|
81
|
-
"eslint-plugin-node-dependencies": "^0.11.0",
|
|
82
|
-
"eslint-plugin-prettier": "^5.0.0",
|
|
83
|
-
"eslint-plugin-regexp": "^2.0.0",
|
|
84
|
-
"eslint-plugin-vue": "^9.0.0",
|
|
85
|
-
"eslint-plugin-yml": "^1.0.0",
|
|
86
|
-
"eslint4b": "^7.3.1",
|
|
87
|
-
"mocha": "^10.0.0",
|
|
88
|
-
"mocha-chai-jest-snapshot": "^1.1.2",
|
|
89
|
-
"nyc": "^15.1.0",
|
|
90
|
-
"prettier": "^3.0.0",
|
|
91
|
-
"raw-loader": "^4.0.1",
|
|
92
|
-
"stylelint": "^16.0.0",
|
|
93
|
-
"stylelint-config-recommended-vue": "^1.0.0",
|
|
94
|
-
"stylelint-config-standard": "^36.0.0",
|
|
95
|
-
"stylelint-stylus": "^1.0.0",
|
|
96
|
-
"ts-node": "^10.0.0",
|
|
97
|
-
"typescript": "^5.0.0",
|
|
98
|
-
"vue-eslint-editor": "^1.1.0",
|
|
99
|
-
"vue-eslint-parser": "^9.0.0",
|
|
100
|
-
"vuepress": "^1.5.2"
|
|
101
|
-
},
|
|
102
35
|
"dependencies": {
|
|
103
36
|
"jsonc-eslint-parser": "^2.0.2",
|
|
104
37
|
"npm-package-arg": "^10.0.0",
|
|
@@ -110,4 +43,4 @@
|
|
|
110
43
|
"publishConfig": {
|
|
111
44
|
"access": "public"
|
|
112
45
|
}
|
|
113
|
-
}
|
|
46
|
+
}
|