@storm-software/eslint 0.169.93 → 0.169.95
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 +1 -1
- package/dist/chunk-4CXNUMUG.js +2 -39
- package/dist/chunk-A32JZBPO.js +2 -6
- package/dist/chunk-DJ2ZXQYV.js +4 -10
- package/dist/chunk-FXLMJ2Y5.js +3 -9
- package/dist/{chunk-DPTIR64R.js → chunk-IWQLEJ77.js} +11 -19
- package/dist/chunk-O5CGESKJ.js +20 -29
- package/dist/chunk-PWQ34SJ2.js +4 -10
- package/dist/chunk-T4LUMNGJ.js +3 -21
- package/dist/chunk-UVJN4TQE.js +5 -12
- package/dist/preset.cjs +9387 -0
- package/dist/preset.d.cts +34 -0
- package/dist/preset.js +128 -329
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +18781 -0
- package/dist/types.js +1 -3
- package/dist/utils/banner-plugin.cjs +454 -0
- package/dist/utils/banner-plugin.d.cts +6 -0
- package/dist/utils/banner-plugin.js +4 -9
- package/dist/utils/combine.cjs +9 -0
- package/dist/utils/combine.d.cts +14 -0
- package/dist/utils/combine.js +3 -6
- package/dist/utils/constants.cjs +206 -0
- package/dist/utils/constants.d.cts +36 -0
- package/dist/utils/constants.js +2 -73
- package/dist/utils/correct-paths.cjs +232 -0
- package/dist/utils/correct-paths.d.cts +30 -0
- package/dist/utils/correct-paths.js +2 -33
- package/dist/utils/find-workspace-root.cjs +201 -0
- package/dist/utils/find-workspace-root.d.cts +16 -0
- package/dist/utils/find-workspace-root.js +3 -10
- package/dist/utils/format-config.cjs +20 -0
- package/dist/utils/format-config.d.cts +5 -0
- package/dist/utils/format-config.js +2 -7
- package/dist/utils/get-file-banner.cjs +103 -0
- package/dist/utils/get-file-banner.d.cts +12 -0
- package/dist/utils/get-file-banner.js +3 -8
- package/dist/utils/helpers.cjs +87 -0
- package/dist/utils/helpers.d.cts +55 -0
- package/dist/utils/helpers.js +2 -19
- package/dist/utils/index.cjs +224 -0
- package/dist/utils/index.d.cts +3 -0
- package/dist/utils/index.js +3 -79
- package/dist/utils/tsconfig-path.cjs +152 -0
- package/dist/utils/tsconfig-path.d.cts +3 -0
- package/dist/utils/tsconfig-path.js +3 -8
- package/package.json +46 -48
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
|
|
6
|
+
// src/utils/find-workspace-root.ts
|
|
7
|
+
|
|
8
|
+
// src/utils/correct-paths.ts
|
|
9
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
10
|
+
function normalizeWindowsPath(input = "") {
|
|
11
|
+
if (!input) {
|
|
12
|
+
return input;
|
|
13
|
+
}
|
|
14
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
15
|
+
}
|
|
16
|
+
var _UNC_REGEX = /^[/\\]{2}/;
|
|
17
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
18
|
+
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
19
|
+
var correctPaths = function(path) {
|
|
20
|
+
if (!path || path.length === 0) {
|
|
21
|
+
return ".";
|
|
22
|
+
}
|
|
23
|
+
path = normalizeWindowsPath(path);
|
|
24
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
25
|
+
const isPathAbsolute = isAbsolute(path);
|
|
26
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
27
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
28
|
+
if (path.length === 0) {
|
|
29
|
+
if (isPathAbsolute) {
|
|
30
|
+
return "/";
|
|
31
|
+
}
|
|
32
|
+
return trailingSeparator ? "./" : ".";
|
|
33
|
+
}
|
|
34
|
+
if (trailingSeparator) {
|
|
35
|
+
path += "/";
|
|
36
|
+
}
|
|
37
|
+
if (_DRIVE_LETTER_RE.test(path)) {
|
|
38
|
+
path += "/";
|
|
39
|
+
}
|
|
40
|
+
if (isUNCPath) {
|
|
41
|
+
if (!isPathAbsolute) {
|
|
42
|
+
return `//./${path}`;
|
|
43
|
+
}
|
|
44
|
+
return `//${path}`;
|
|
45
|
+
}
|
|
46
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
47
|
+
};
|
|
48
|
+
function normalizeString(path, allowAboveRoot) {
|
|
49
|
+
let res = "";
|
|
50
|
+
let lastSegmentLength = 0;
|
|
51
|
+
let lastSlash = -1;
|
|
52
|
+
let dots = 0;
|
|
53
|
+
let char = null;
|
|
54
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
55
|
+
if (index < path.length) {
|
|
56
|
+
char = path[index];
|
|
57
|
+
} else if (char === "/") {
|
|
58
|
+
break;
|
|
59
|
+
} else {
|
|
60
|
+
char = "/";
|
|
61
|
+
}
|
|
62
|
+
if (char === "/") {
|
|
63
|
+
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
64
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
65
|
+
if (res.length > 2) {
|
|
66
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
67
|
+
if (lastSlashIndex === -1) {
|
|
68
|
+
res = "";
|
|
69
|
+
lastSegmentLength = 0;
|
|
70
|
+
} else {
|
|
71
|
+
res = res.slice(0, lastSlashIndex);
|
|
72
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
73
|
+
}
|
|
74
|
+
lastSlash = index;
|
|
75
|
+
dots = 0;
|
|
76
|
+
continue;
|
|
77
|
+
} else if (res.length > 0) {
|
|
78
|
+
res = "";
|
|
79
|
+
lastSegmentLength = 0;
|
|
80
|
+
lastSlash = index;
|
|
81
|
+
dots = 0;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (allowAboveRoot) {
|
|
86
|
+
res += res.length > 0 ? "/.." : "..";
|
|
87
|
+
lastSegmentLength = 2;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
if (res.length > 0) {
|
|
91
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
92
|
+
} else {
|
|
93
|
+
res = path.slice(lastSlash + 1, index);
|
|
94
|
+
}
|
|
95
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
96
|
+
}
|
|
97
|
+
lastSlash = index;
|
|
98
|
+
dots = 0;
|
|
99
|
+
} else if (char === "." && dots !== -1) {
|
|
100
|
+
++dots;
|
|
101
|
+
} else {
|
|
102
|
+
dots = -1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return res;
|
|
106
|
+
}
|
|
107
|
+
var isAbsolute = function(p) {
|
|
108
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// src/utils/find-workspace-root.ts
|
|
112
|
+
var MAX_PATH_SEARCH_DEPTH = 30;
|
|
113
|
+
var depth = 0;
|
|
114
|
+
function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
115
|
+
const _startPath = startPath ?? process.cwd();
|
|
116
|
+
if (endDirectoryNames.some(
|
|
117
|
+
(endDirName) => fs.existsSync(path.join(_startPath, endDirName))
|
|
118
|
+
)) {
|
|
119
|
+
return _startPath;
|
|
120
|
+
}
|
|
121
|
+
if (endFileNames.some((endFileName) => fs.existsSync(path.join(_startPath, endFileName)))) {
|
|
122
|
+
return _startPath;
|
|
123
|
+
}
|
|
124
|
+
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
125
|
+
const parent = path.join(_startPath, "..");
|
|
126
|
+
return findFolderUp(parent, endFileNames, endDirectoryNames);
|
|
127
|
+
}
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
var rootFiles = [
|
|
131
|
+
"storm-workspace.json",
|
|
132
|
+
"storm-workspace.json",
|
|
133
|
+
"storm-workspace.yaml",
|
|
134
|
+
"storm-workspace.yml",
|
|
135
|
+
"storm-workspace.js",
|
|
136
|
+
"storm-workspace.ts",
|
|
137
|
+
".storm-workspace.json",
|
|
138
|
+
".storm-workspace.yaml",
|
|
139
|
+
".storm-workspace.yml",
|
|
140
|
+
".storm-workspace.js",
|
|
141
|
+
".storm-workspace.ts",
|
|
142
|
+
"lerna.json",
|
|
143
|
+
"nx.json",
|
|
144
|
+
"turbo.json",
|
|
145
|
+
"npm-workspace.json",
|
|
146
|
+
"yarn-workspace.json",
|
|
147
|
+
"pnpm-workspace.json",
|
|
148
|
+
"npm-workspace.yaml",
|
|
149
|
+
"yarn-workspace.yaml",
|
|
150
|
+
"pnpm-workspace.yaml",
|
|
151
|
+
"npm-workspace.yml",
|
|
152
|
+
"yarn-workspace.yml",
|
|
153
|
+
"pnpm-workspace.yml",
|
|
154
|
+
"npm-lock.json",
|
|
155
|
+
"yarn-lock.json",
|
|
156
|
+
"pnpm-lock.json",
|
|
157
|
+
"npm-lock.yaml",
|
|
158
|
+
"yarn-lock.yaml",
|
|
159
|
+
"pnpm-lock.yaml",
|
|
160
|
+
"npm-lock.yml",
|
|
161
|
+
"yarn-lock.yml",
|
|
162
|
+
"pnpm-lock.yml",
|
|
163
|
+
"bun.lockb"
|
|
164
|
+
];
|
|
165
|
+
var rootDirectories = [
|
|
166
|
+
".storm-workspace",
|
|
167
|
+
".nx",
|
|
168
|
+
".github",
|
|
169
|
+
".vscode",
|
|
170
|
+
".verdaccio"
|
|
171
|
+
];
|
|
172
|
+
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
173
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
174
|
+
return correctPaths(
|
|
175
|
+
process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return correctPaths(
|
|
179
|
+
findFolderUp(
|
|
180
|
+
pathInsideMonorepo ?? process.cwd(),
|
|
181
|
+
rootFiles,
|
|
182
|
+
rootDirectories
|
|
183
|
+
)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
187
|
+
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
188
|
+
if (!result) {
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
191
|
+
${rootFiles.join(
|
|
192
|
+
"\n"
|
|
193
|
+
)}
|
|
194
|
+
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
exports.findWorkspaceRoot = findWorkspaceRoot;
|
|
201
|
+
exports.findWorkspaceRootSafe = findWorkspaceRootSafe;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the monorepo root directory, searching upwards from `path`.
|
|
3
|
+
*
|
|
4
|
+
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
5
|
+
* @returns The monorepo root directory
|
|
6
|
+
*/
|
|
7
|
+
declare function findWorkspaceRootSafe(pathInsideMonorepo?: string): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Find the monorepo root directory, searching upwards from `path`.
|
|
10
|
+
*
|
|
11
|
+
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
12
|
+
* @returns The monorepo root directory
|
|
13
|
+
*/
|
|
14
|
+
declare function findWorkspaceRoot(pathInsideMonorepo?: string): string;
|
|
15
|
+
|
|
16
|
+
export { findWorkspaceRoot, findWorkspaceRootSafe };
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../chunk-UVJN4TQE.js";
|
|
5
|
-
import "../chunk-T4LUMNGJ.js";
|
|
6
|
-
import "../chunk-PWQ34SJ2.js";
|
|
7
|
-
export {
|
|
8
|
-
findWorkspaceRoot,
|
|
9
|
-
findWorkspaceRootSafe
|
|
10
|
-
};
|
|
1
|
+
export { findWorkspaceRoot, findWorkspaceRootSafe } from '../chunk-UVJN4TQE.js';
|
|
2
|
+
import '../chunk-T4LUMNGJ.js';
|
|
3
|
+
import '../chunk-PWQ34SJ2.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/format-config.ts
|
|
4
|
+
var formatConfig = (name, config = []) => {
|
|
5
|
+
return config.map((config2, index) => {
|
|
6
|
+
if (!config2 || config2.name) {
|
|
7
|
+
return config2 ?? {};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
...config2,
|
|
11
|
+
name: `Storm Software (${config2.name ? config2.name : name}) #${index + 1}`,
|
|
12
|
+
settings: {
|
|
13
|
+
"import/resolver": "node",
|
|
14
|
+
...config2.settings ?? {}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.formatConfig = formatConfig;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/constants.ts
|
|
4
|
+
var ACRONYMS_LIST = [
|
|
5
|
+
"API",
|
|
6
|
+
"ASCII",
|
|
7
|
+
"CPU",
|
|
8
|
+
"CSS",
|
|
9
|
+
"DNS",
|
|
10
|
+
"EOF",
|
|
11
|
+
"GUID",
|
|
12
|
+
"HTML",
|
|
13
|
+
"HTTP",
|
|
14
|
+
"HTTPS",
|
|
15
|
+
"ID",
|
|
16
|
+
"IP",
|
|
17
|
+
"JSON",
|
|
18
|
+
"LHS",
|
|
19
|
+
"OEM",
|
|
20
|
+
"PP",
|
|
21
|
+
"QA",
|
|
22
|
+
"RAM",
|
|
23
|
+
"RHS",
|
|
24
|
+
"RPC",
|
|
25
|
+
"RSS",
|
|
26
|
+
"SLA",
|
|
27
|
+
"SMTP",
|
|
28
|
+
"SQL",
|
|
29
|
+
"SSH",
|
|
30
|
+
"SSL",
|
|
31
|
+
"TCP",
|
|
32
|
+
"TLS",
|
|
33
|
+
"TTL",
|
|
34
|
+
"UDP",
|
|
35
|
+
"UI",
|
|
36
|
+
"UID",
|
|
37
|
+
"UUID",
|
|
38
|
+
"URI",
|
|
39
|
+
"URL",
|
|
40
|
+
"UTF",
|
|
41
|
+
"VM",
|
|
42
|
+
"XML",
|
|
43
|
+
"XSS"
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
// src/utils/get-file-banner.ts
|
|
47
|
+
var getFileBanner = (name = "", workspaceConfig) => {
|
|
48
|
+
if (!name) {
|
|
49
|
+
name = process.env.STORM_NAME || "";
|
|
50
|
+
}
|
|
51
|
+
let padding = " ";
|
|
52
|
+
for (let i = 0; i < name.length + 2 && padding.length > 4; i++) {
|
|
53
|
+
padding = padding.slice(0, -1);
|
|
54
|
+
}
|
|
55
|
+
let titleName = name || workspaceConfig?.name;
|
|
56
|
+
if (titleName) {
|
|
57
|
+
if (titleName?.startsWith("@")) {
|
|
58
|
+
titleName = titleName.slice(1);
|
|
59
|
+
}
|
|
60
|
+
titleName = (titleName.charAt(0).toUpperCase() + titleName.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
|
|
61
|
+
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
|
|
62
|
+
return word.toUpperCase();
|
|
63
|
+
}
|
|
64
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
65
|
+
}).join(" ");
|
|
66
|
+
}
|
|
67
|
+
const license = (process.env.STORM_LICENSE || workspaceConfig?.license || "Apache-2.0").split(" ").filter((word) => word && word.toLowerCase() !== "license").join(" ");
|
|
68
|
+
const organization = process.env.STORM_ORG_NAME || process.env.STORM_ORGANIZATION_NAME || process.env.STORM_ORG || process.env.STORM_ORGANIZATION || (workspaceConfig?.organization && (typeof workspaceConfig.organization === "string" || typeof workspaceConfig.organization.name === "string") ? typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization.name : void 0) || "storm-software";
|
|
69
|
+
return ` -------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
${padding}\u26A1 ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
|
|
72
|
+
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
|
|
73
|
+
return word.toUpperCase();
|
|
74
|
+
}
|
|
75
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
76
|
+
}).join(" ")} ${titleName ? `- ${titleName}` : ""}
|
|
77
|
+
|
|
78
|
+
This code was released as part of ${titleName ? `the ${titleName}` : `a ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
|
|
79
|
+
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
|
|
80
|
+
return word.toUpperCase();
|
|
81
|
+
}
|
|
82
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
83
|
+
}).join(" ")}`} project. ${titleName ? titleName : "The project"}
|
|
84
|
+
is maintained by ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
|
|
85
|
+
if (ACRONYMS_LIST.includes(word.toUpperCase())) {
|
|
86
|
+
return word.toUpperCase();
|
|
87
|
+
}
|
|
88
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
89
|
+
}).join(" ")} under the ${license} license, and is
|
|
90
|
+
free for commercial and private use. For more information, please visit
|
|
91
|
+
our licensing page at ${process.env.STORM_LICENSING?.replace(/\/$/, "") || workspaceConfig?.licensing?.replace(/\/$/, "") || "https://stormsoftware.com/licenses"}/${name ? `projects/${name}` : ""}.
|
|
92
|
+
|
|
93
|
+
Website: ${process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com"}
|
|
94
|
+
Repository: ${process.env.STORM_REPOSITORY || workspaceConfig?.repository || `https://github.com/${organization}${name ? `/${name}` : ""}`}
|
|
95
|
+
Documentation: ${process.env.STORM_DOCS || workspaceConfig?.docs || `https://docs.stormsoftware.com${name ? `/projects/${name}` : ""}`}
|
|
96
|
+
Contact: ${(process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com").endsWith("/") ? (process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com").slice(-1) : process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com"}/contact
|
|
97
|
+
|
|
98
|
+
SPDX-License-Identifier: ${license}
|
|
99
|
+
|
|
100
|
+
------------------------------------------------------------------- `;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
exports.getFileBanner = getFileBanner;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StormWorkspaceConfig } from '@storm-software/config';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get a banner header to display at the top of a file
|
|
5
|
+
*
|
|
6
|
+
* @param name - The name to use in the display
|
|
7
|
+
* @param workspaceConfig - The workspace config to use for additional information
|
|
8
|
+
* @returns The banner header
|
|
9
|
+
*/
|
|
10
|
+
declare const getFileBanner: (name?: string, workspaceConfig?: StormWorkspaceConfig) => string;
|
|
11
|
+
|
|
12
|
+
export { getFileBanner };
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "../chunk-4CXNUMUG.js";
|
|
5
|
-
import "../chunk-PWQ34SJ2.js";
|
|
6
|
-
export {
|
|
7
|
-
getFileBanner
|
|
8
|
-
};
|
|
1
|
+
export { getFileBanner } from '../chunk-FXLMJ2Y5.js';
|
|
2
|
+
import '../chunk-4CXNUMUG.js';
|
|
3
|
+
import '../chunk-PWQ34SJ2.js';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var localPkg = require('local-pkg');
|
|
4
|
+
var process = require('process');
|
|
5
|
+
var url = require('url');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
10
|
+
|
|
11
|
+
// ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__62048a4dc615a7ea5da4008534e42c0e/node_modules/tsup/assets/cjs_shims.js
|
|
12
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
13
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
14
|
+
var scopeUrl = url.fileURLToPath(new URL(".", importMetaUrl));
|
|
15
|
+
var isCwdInScope = localPkg.isPackageExists("@storm-software/eslint");
|
|
16
|
+
var parserPlain = {
|
|
17
|
+
meta: {
|
|
18
|
+
name: "parser-plain"
|
|
19
|
+
},
|
|
20
|
+
parseForESLint: (code) => ({
|
|
21
|
+
ast: {
|
|
22
|
+
body: [],
|
|
23
|
+
comments: [],
|
|
24
|
+
loc: { end: code.length, start: 0 },
|
|
25
|
+
range: [0, code.length],
|
|
26
|
+
tokens: [],
|
|
27
|
+
type: "Program"
|
|
28
|
+
},
|
|
29
|
+
scopeManager: null,
|
|
30
|
+
services: { isPlain: true },
|
|
31
|
+
visitorKeys: {
|
|
32
|
+
Program: []
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
function isInGitHooksOrLintStaged() {
|
|
37
|
+
return !!(process__default.default.env.GIT_PARAMS || process__default.default.env.VSCODE_GIT_COMMAND || process__default.default.env.npm_lifecycle_script?.startsWith("lint-staged") || process__default.default.env.npm_lifecycle_script?.startsWith("lefthook") || process__default.default.env.npm_lifecycle_script === "push");
|
|
38
|
+
}
|
|
39
|
+
function isInEditorEnv() {
|
|
40
|
+
if (process__default.default.env.CI) return false;
|
|
41
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
42
|
+
return !!(process__default.default.env.VSCODE_PID || process__default.default.env.VSCODE_CWD || process__default.default.env.JETBRAINS_IDE || process__default.default.env.VIM || process__default.default.env.NVIM);
|
|
43
|
+
}
|
|
44
|
+
async function interopDefault(m) {
|
|
45
|
+
const resolved = await m;
|
|
46
|
+
return resolved.default || resolved;
|
|
47
|
+
}
|
|
48
|
+
function isPackageInScope(name) {
|
|
49
|
+
return localPkg.isPackageExists(name, { paths: [scopeUrl] });
|
|
50
|
+
}
|
|
51
|
+
async function ensurePackages(packages) {
|
|
52
|
+
if (process__default.default.env.CI || process__default.default.stdout.isTTY === false || isCwdInScope === false)
|
|
53
|
+
return;
|
|
54
|
+
const nonExistingPackages = packages.filter(
|
|
55
|
+
(i) => i && !isPackageInScope(i)
|
|
56
|
+
);
|
|
57
|
+
if (nonExistingPackages.length === 0) return;
|
|
58
|
+
const p = await import('@clack/prompts');
|
|
59
|
+
const result = await p.confirm({
|
|
60
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(
|
|
61
|
+
", "
|
|
62
|
+
)}. Do you want to install them?`
|
|
63
|
+
});
|
|
64
|
+
if (result)
|
|
65
|
+
await import('@antfu/install-pkg').then(
|
|
66
|
+
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
function renameRules(rules, map) {
|
|
70
|
+
return Object.fromEntries(
|
|
71
|
+
Object.entries(rules).map(([key, value]) => {
|
|
72
|
+
for (const [from, to] of Object.entries(map)) {
|
|
73
|
+
if (key.startsWith(`${from}/`))
|
|
74
|
+
return [to + key.slice(from.length), value];
|
|
75
|
+
}
|
|
76
|
+
return [key, value];
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.ensurePackages = ensurePackages;
|
|
82
|
+
exports.interopDefault = interopDefault;
|
|
83
|
+
exports.isInEditorEnv = isInEditorEnv;
|
|
84
|
+
exports.isInGitHooksOrLintStaged = isInGitHooksOrLintStaged;
|
|
85
|
+
exports.isPackageInScope = isPackageInScope;
|
|
86
|
+
exports.parserPlain = parserPlain;
|
|
87
|
+
exports.renameRules = renameRules;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Awaitable } from 'eslint-flat-config-utils';
|
|
2
|
+
|
|
3
|
+
declare const parserPlain: {
|
|
4
|
+
meta: {
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
parseForESLint: (code: string) => {
|
|
8
|
+
ast: {
|
|
9
|
+
body: never[];
|
|
10
|
+
comments: never[];
|
|
11
|
+
loc: {
|
|
12
|
+
end: number;
|
|
13
|
+
start: number;
|
|
14
|
+
};
|
|
15
|
+
range: number[];
|
|
16
|
+
tokens: never[];
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
scopeManager: null;
|
|
20
|
+
services: {
|
|
21
|
+
isPlain: boolean;
|
|
22
|
+
};
|
|
23
|
+
visitorKeys: {
|
|
24
|
+
Program: never[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
declare function isInGitHooksOrLintStaged(): boolean;
|
|
29
|
+
declare function isInEditorEnv(): boolean;
|
|
30
|
+
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
31
|
+
default: infer U;
|
|
32
|
+
} ? U : T>;
|
|
33
|
+
declare function isPackageInScope(name: string): boolean;
|
|
34
|
+
declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Rename plugin prefixes in a rule object.
|
|
37
|
+
* Accepts a map of prefixes to rename.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { renameRules } from '@storm-software/eslint'
|
|
42
|
+
*
|
|
43
|
+
* export default [{
|
|
44
|
+
* rules: renameRules(
|
|
45
|
+
* {
|
|
46
|
+
* '@typescript-eslint/indent': 'error'
|
|
47
|
+
* },
|
|
48
|
+
* { '@typescript-eslint': 'ts' }
|
|
49
|
+
* )
|
|
50
|
+
* }]
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
|
|
54
|
+
|
|
55
|
+
export { ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, renameRules };
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interopDefault,
|
|
4
|
-
isInEditorEnv,
|
|
5
|
-
isInGitHooksOrLintStaged,
|
|
6
|
-
isPackageInScope,
|
|
7
|
-
parserPlain,
|
|
8
|
-
renameRules
|
|
9
|
-
} from "../chunk-DPTIR64R.js";
|
|
10
|
-
import "../chunk-PWQ34SJ2.js";
|
|
11
|
-
export {
|
|
12
|
-
ensurePackages,
|
|
13
|
-
interopDefault,
|
|
14
|
-
isInEditorEnv,
|
|
15
|
-
isInGitHooksOrLintStaged,
|
|
16
|
-
isPackageInScope,
|
|
17
|
-
parserPlain,
|
|
18
|
-
renameRules
|
|
19
|
-
};
|
|
1
|
+
export { ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, renameRules } from '../chunk-IWQLEJ77.js';
|
|
2
|
+
import '../chunk-PWQ34SJ2.js';
|