react-doctor 0.2.0-beta.4 → 0.2.0-beta.6
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 +140 -8
- package/dist/cli.js +2102 -152
- package/dist/index.d.ts +149 -0
- package/dist/index.js +2035 -133
- package/dist/skills/react-doctor/SKILL.md +4 -4
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2,9 +2,52 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { spawn, spawnSync } from "node:child_process";
|
|
5
|
-
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES } from "oxlint-plugin-react-doctor";
|
|
5
|
+
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, BUILTIN_A11Y_RULES, BUILTIN_REACT_RULES, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, YOU_MIGHT_NOT_NEED_EFFECT_RULES } from "oxlint-plugin-react-doctor";
|
|
6
6
|
import os from "node:os";
|
|
7
7
|
import * as ts from "typescript";
|
|
8
|
+
//#region \0rolldown/runtime.js
|
|
9
|
+
var __create$1 = Object.create;
|
|
10
|
+
var __defProp$1 = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames$1 = Object.getOwnPropertyNames;
|
|
13
|
+
var __getProtoOf$1 = Object.getPrototypeOf;
|
|
14
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __commonJSMin$1 = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
16
|
+
var __copyProps$1 = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$1(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
18
|
+
key = keys[i];
|
|
19
|
+
if (!__hasOwnProp$1.call(to, key) && key !== except) __defProp$1(to, key, {
|
|
20
|
+
get: ((k) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$1(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
|
|
27
|
+
value: mod,
|
|
28
|
+
enumerable: true
|
|
29
|
+
}) : target, mod));
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region ../types/dist/index.js
|
|
33
|
+
const REACT_NATIVE_DEPENDENCY_NAMES = new Set([
|
|
34
|
+
"react-native",
|
|
35
|
+
"react-native-tvos",
|
|
36
|
+
"expo",
|
|
37
|
+
"expo-router",
|
|
38
|
+
"@expo/cli",
|
|
39
|
+
"@expo/metro-config",
|
|
40
|
+
"@expo/metro-runtime",
|
|
41
|
+
"react-native-windows",
|
|
42
|
+
"react-native-macos"
|
|
43
|
+
]);
|
|
44
|
+
const REACT_NATIVE_DEPENDENCY_PREFIXES = ["@react-native/", "@react-native-"];
|
|
45
|
+
const isReactNativeDependencyName = (dependencyName) => {
|
|
46
|
+
if (REACT_NATIVE_DEPENDENCY_NAMES.has(dependencyName)) return true;
|
|
47
|
+
for (const prefix of REACT_NATIVE_DEPENDENCY_PREFIXES) if (dependencyName.startsWith(prefix)) return true;
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
8
51
|
//#region ../project-info/dist/index.js
|
|
9
52
|
var ReactDoctorError = class extends Error {
|
|
10
53
|
name = "ReactDoctorError";
|
|
@@ -225,6 +268,18 @@ const FRAMEWORK_PACKAGES = {
|
|
|
225
268
|
expo: "expo",
|
|
226
269
|
"react-native": "react-native"
|
|
227
270
|
};
|
|
271
|
+
const FRAMEWORK_DISPLAY_NAMES = {
|
|
272
|
+
nextjs: "Next.js",
|
|
273
|
+
"tanstack-start": "TanStack Start",
|
|
274
|
+
vite: "Vite",
|
|
275
|
+
cra: "Create React App",
|
|
276
|
+
remix: "Remix",
|
|
277
|
+
gatsby: "Gatsby",
|
|
278
|
+
expo: "Expo",
|
|
279
|
+
"react-native": "React Native",
|
|
280
|
+
unknown: "React"
|
|
281
|
+
};
|
|
282
|
+
const formatFrameworkName = (framework) => FRAMEWORK_DISPLAY_NAMES[framework];
|
|
228
283
|
const detectFramework = (dependencies) => {
|
|
229
284
|
for (const [packageName, frameworkName] of Object.entries(FRAMEWORK_PACKAGES)) if (dependencies[packageName]) return frameworkName;
|
|
230
285
|
return "unknown";
|
|
@@ -651,6 +706,34 @@ const findDependencyInfoFromMonorepoRoot = (directory) => {
|
|
|
651
706
|
framework: rootInfo.framework !== "unknown" ? rootInfo.framework : workspaceInfo.framework
|
|
652
707
|
};
|
|
653
708
|
};
|
|
709
|
+
const containsAnyReactNativeDependency = (section) => {
|
|
710
|
+
if (!section) return false;
|
|
711
|
+
for (const dependencyName of Object.keys(section)) if (isReactNativeDependencyName(dependencyName)) return true;
|
|
712
|
+
return false;
|
|
713
|
+
};
|
|
714
|
+
const isPackageJsonReactNativeAware = (packageJson) => {
|
|
715
|
+
if (typeof packageJson["react-native"] === "string") return true;
|
|
716
|
+
if (containsAnyReactNativeDependency(packageJson.dependencies)) return true;
|
|
717
|
+
if (containsAnyReactNativeDependency(packageJson.devDependencies)) return true;
|
|
718
|
+
if (containsAnyReactNativeDependency(packageJson.peerDependencies)) return true;
|
|
719
|
+
if (containsAnyReactNativeDependency(packageJson.optionalDependencies)) return true;
|
|
720
|
+
return false;
|
|
721
|
+
};
|
|
722
|
+
const hasReactNativeWorkspaceAnywhere = (rootDirectory, rootPackageJson) => {
|
|
723
|
+
if (isPackageJsonReactNativeAware(rootPackageJson)) return true;
|
|
724
|
+
const patterns = getWorkspacePatterns(rootDirectory, rootPackageJson);
|
|
725
|
+
if (patterns.length === 0) return false;
|
|
726
|
+
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
727
|
+
for (const pattern of patterns) {
|
|
728
|
+
const directories = resolveWorkspaceDirectories(rootDirectory, pattern);
|
|
729
|
+
for (const workspaceDirectory of directories) {
|
|
730
|
+
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
731
|
+
visitedDirectories.add(workspaceDirectory);
|
|
732
|
+
if (isPackageJsonReactNativeAware(readPackageJson(path.join(workspaceDirectory, "package.json")))) return true;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return false;
|
|
736
|
+
};
|
|
654
737
|
const TANSTACK_QUERY_PACKAGES = new Set([
|
|
655
738
|
"@tanstack/react-query",
|
|
656
739
|
"@tanstack/query-core",
|
|
@@ -826,6 +909,7 @@ const discoverProject = (directory) => {
|
|
|
826
909
|
const projectName = packageJson.name ?? path.basename(directory);
|
|
827
910
|
const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
|
|
828
911
|
const sourceFileCount = countSourceFiles(directory);
|
|
912
|
+
const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
|
|
829
913
|
const projectInfo = {
|
|
830
914
|
rootDirectory: directory,
|
|
831
915
|
projectName,
|
|
@@ -836,6 +920,7 @@ const discoverProject = (directory) => {
|
|
|
836
920
|
hasTypeScript,
|
|
837
921
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
838
922
|
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
923
|
+
hasReactNativeWorkspace,
|
|
839
924
|
sourceFileCount
|
|
840
925
|
};
|
|
841
926
|
cachedProjectInfos.set(directory, projectInfo);
|
|
@@ -871,7 +956,1661 @@ const isTailwindAtLeast = (detected, required) => {
|
|
|
871
956
|
return detected.minor >= required.minor;
|
|
872
957
|
};
|
|
873
958
|
//#endregion
|
|
959
|
+
//#region ../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js
|
|
960
|
+
var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
961
|
+
const path$3 = __require("path");
|
|
962
|
+
const WIN_SLASH = "\\\\/";
|
|
963
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
964
|
+
/**
|
|
965
|
+
* Posix glob regex
|
|
966
|
+
*/
|
|
967
|
+
const DOT_LITERAL = "\\.";
|
|
968
|
+
const PLUS_LITERAL = "\\+";
|
|
969
|
+
const QMARK_LITERAL = "\\?";
|
|
970
|
+
const SLASH_LITERAL = "\\/";
|
|
971
|
+
const ONE_CHAR = "(?=.)";
|
|
972
|
+
const QMARK = "[^/]";
|
|
973
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
974
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
975
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
976
|
+
const POSIX_CHARS = {
|
|
977
|
+
DOT_LITERAL,
|
|
978
|
+
PLUS_LITERAL,
|
|
979
|
+
QMARK_LITERAL,
|
|
980
|
+
SLASH_LITERAL,
|
|
981
|
+
ONE_CHAR,
|
|
982
|
+
QMARK,
|
|
983
|
+
END_ANCHOR,
|
|
984
|
+
DOTS_SLASH,
|
|
985
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
986
|
+
NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`,
|
|
987
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`,
|
|
988
|
+
NO_DOTS_SLASH: `(?!${DOTS_SLASH})`,
|
|
989
|
+
QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`,
|
|
990
|
+
STAR: `${QMARK}*?`,
|
|
991
|
+
START_ANCHOR
|
|
992
|
+
};
|
|
993
|
+
/**
|
|
994
|
+
* Windows glob regex
|
|
995
|
+
*/
|
|
996
|
+
const WINDOWS_CHARS = {
|
|
997
|
+
...POSIX_CHARS,
|
|
998
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
999
|
+
QMARK: WIN_NO_SLASH,
|
|
1000
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
1001
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
1002
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
1003
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
1004
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
1005
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
1006
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
1007
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
1008
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
1009
|
+
};
|
|
1010
|
+
module.exports = {
|
|
1011
|
+
MAX_LENGTH: 1024 * 64,
|
|
1012
|
+
POSIX_REGEX_SOURCE: {
|
|
1013
|
+
alnum: "a-zA-Z0-9",
|
|
1014
|
+
alpha: "a-zA-Z",
|
|
1015
|
+
ascii: "\\x00-\\x7F",
|
|
1016
|
+
blank: " \\t",
|
|
1017
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
1018
|
+
digit: "0-9",
|
|
1019
|
+
graph: "\\x21-\\x7E",
|
|
1020
|
+
lower: "a-z",
|
|
1021
|
+
print: "\\x20-\\x7E ",
|
|
1022
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
1023
|
+
space: " \\t\\r\\n\\v\\f",
|
|
1024
|
+
upper: "A-Z",
|
|
1025
|
+
word: "A-Za-z0-9_",
|
|
1026
|
+
xdigit: "A-Fa-f0-9"
|
|
1027
|
+
},
|
|
1028
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
1029
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
1030
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
1031
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
1032
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
1033
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
1034
|
+
REPLACEMENTS: {
|
|
1035
|
+
"***": "*",
|
|
1036
|
+
"**/**": "**",
|
|
1037
|
+
"**/**/**": "**"
|
|
1038
|
+
},
|
|
1039
|
+
CHAR_0: 48,
|
|
1040
|
+
CHAR_9: 57,
|
|
1041
|
+
CHAR_UPPERCASE_A: 65,
|
|
1042
|
+
CHAR_LOWERCASE_A: 97,
|
|
1043
|
+
CHAR_UPPERCASE_Z: 90,
|
|
1044
|
+
CHAR_LOWERCASE_Z: 122,
|
|
1045
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
1046
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
1047
|
+
CHAR_ASTERISK: 42,
|
|
1048
|
+
CHAR_AMPERSAND: 38,
|
|
1049
|
+
CHAR_AT: 64,
|
|
1050
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
1051
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
1052
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
1053
|
+
CHAR_COLON: 58,
|
|
1054
|
+
CHAR_COMMA: 44,
|
|
1055
|
+
CHAR_DOT: 46,
|
|
1056
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
1057
|
+
CHAR_EQUAL: 61,
|
|
1058
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
1059
|
+
CHAR_FORM_FEED: 12,
|
|
1060
|
+
CHAR_FORWARD_SLASH: 47,
|
|
1061
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
1062
|
+
CHAR_HASH: 35,
|
|
1063
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
1064
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
1065
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
1066
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
1067
|
+
CHAR_LINE_FEED: 10,
|
|
1068
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
1069
|
+
CHAR_PERCENT: 37,
|
|
1070
|
+
CHAR_PLUS: 43,
|
|
1071
|
+
CHAR_QUESTION_MARK: 63,
|
|
1072
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
1073
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
1074
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
1075
|
+
CHAR_SEMICOLON: 59,
|
|
1076
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
1077
|
+
CHAR_SPACE: 32,
|
|
1078
|
+
CHAR_TAB: 9,
|
|
1079
|
+
CHAR_UNDERSCORE: 95,
|
|
1080
|
+
CHAR_VERTICAL_LINE: 124,
|
|
1081
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
1082
|
+
SEP: path$3.sep,
|
|
1083
|
+
/**
|
|
1084
|
+
* Create EXTGLOB_CHARS
|
|
1085
|
+
*/
|
|
1086
|
+
extglobChars(chars) {
|
|
1087
|
+
return {
|
|
1088
|
+
"!": {
|
|
1089
|
+
type: "negate",
|
|
1090
|
+
open: "(?:(?!(?:",
|
|
1091
|
+
close: `))${chars.STAR})`
|
|
1092
|
+
},
|
|
1093
|
+
"?": {
|
|
1094
|
+
type: "qmark",
|
|
1095
|
+
open: "(?:",
|
|
1096
|
+
close: ")?"
|
|
1097
|
+
},
|
|
1098
|
+
"+": {
|
|
1099
|
+
type: "plus",
|
|
1100
|
+
open: "(?:",
|
|
1101
|
+
close: ")+"
|
|
1102
|
+
},
|
|
1103
|
+
"*": {
|
|
1104
|
+
type: "star",
|
|
1105
|
+
open: "(?:",
|
|
1106
|
+
close: ")*"
|
|
1107
|
+
},
|
|
1108
|
+
"@": {
|
|
1109
|
+
type: "at",
|
|
1110
|
+
open: "(?:",
|
|
1111
|
+
close: ")"
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
},
|
|
1115
|
+
/**
|
|
1116
|
+
* Create GLOB_CHARS
|
|
1117
|
+
*/
|
|
1118
|
+
globChars(win32) {
|
|
1119
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
}));
|
|
1123
|
+
//#endregion
|
|
1124
|
+
//#region ../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js
|
|
1125
|
+
var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports) => {
|
|
1126
|
+
const path$2 = __require("path");
|
|
1127
|
+
const win32 = process.platform === "win32";
|
|
1128
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
1129
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1130
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
1131
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
1132
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
1133
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
1134
|
+
exports.removeBackslashes = (str) => {
|
|
1135
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
1136
|
+
return match === "\\" ? "" : match;
|
|
1137
|
+
});
|
|
1138
|
+
};
|
|
1139
|
+
exports.supportsLookbehinds = () => {
|
|
1140
|
+
const segs = process.version.slice(1).split(".").map(Number);
|
|
1141
|
+
if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) return true;
|
|
1142
|
+
return false;
|
|
1143
|
+
};
|
|
1144
|
+
exports.isWindows = (options) => {
|
|
1145
|
+
if (options && typeof options.windows === "boolean") return options.windows;
|
|
1146
|
+
return win32 === true || path$2.sep === "\\";
|
|
1147
|
+
};
|
|
1148
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
1149
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
1150
|
+
if (idx === -1) return input;
|
|
1151
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
1152
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
1153
|
+
};
|
|
1154
|
+
exports.removePrefix = (input, state = {}) => {
|
|
1155
|
+
let output = input;
|
|
1156
|
+
if (output.startsWith("./")) {
|
|
1157
|
+
output = output.slice(2);
|
|
1158
|
+
state.prefix = "./";
|
|
1159
|
+
}
|
|
1160
|
+
return output;
|
|
1161
|
+
};
|
|
1162
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
1163
|
+
let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`;
|
|
1164
|
+
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
1165
|
+
return output;
|
|
1166
|
+
};
|
|
1167
|
+
}));
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region ../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/scan.js
|
|
1170
|
+
var require_scan = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
1171
|
+
const utils = require_utils();
|
|
1172
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
1173
|
+
const isPathSeparator = (code) => {
|
|
1174
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1175
|
+
};
|
|
1176
|
+
const depth = (token) => {
|
|
1177
|
+
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
|
|
1178
|
+
};
|
|
1179
|
+
/**
|
|
1180
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
1181
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
1182
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
1183
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
1184
|
+
*
|
|
1185
|
+
* ```js
|
|
1186
|
+
* const pm = require('picomatch');
|
|
1187
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
1188
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
1189
|
+
* ```
|
|
1190
|
+
* @param {String} `str`
|
|
1191
|
+
* @param {Object} `options`
|
|
1192
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
1193
|
+
* @api public
|
|
1194
|
+
*/
|
|
1195
|
+
const scan = (input, options) => {
|
|
1196
|
+
const opts = options || {};
|
|
1197
|
+
const length = input.length - 1;
|
|
1198
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
1199
|
+
const slashes = [];
|
|
1200
|
+
const tokens = [];
|
|
1201
|
+
const parts = [];
|
|
1202
|
+
let str = input;
|
|
1203
|
+
let index = -1;
|
|
1204
|
+
let start = 0;
|
|
1205
|
+
let lastIndex = 0;
|
|
1206
|
+
let isBrace = false;
|
|
1207
|
+
let isBracket = false;
|
|
1208
|
+
let isGlob = false;
|
|
1209
|
+
let isExtglob = false;
|
|
1210
|
+
let isGlobstar = false;
|
|
1211
|
+
let braceEscaped = false;
|
|
1212
|
+
let backslashes = false;
|
|
1213
|
+
let negated = false;
|
|
1214
|
+
let negatedExtglob = false;
|
|
1215
|
+
let finished = false;
|
|
1216
|
+
let braces = 0;
|
|
1217
|
+
let prev;
|
|
1218
|
+
let code;
|
|
1219
|
+
let token = {
|
|
1220
|
+
value: "",
|
|
1221
|
+
depth: 0,
|
|
1222
|
+
isGlob: false
|
|
1223
|
+
};
|
|
1224
|
+
const eos = () => index >= length;
|
|
1225
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
1226
|
+
const advance = () => {
|
|
1227
|
+
prev = code;
|
|
1228
|
+
return str.charCodeAt(++index);
|
|
1229
|
+
};
|
|
1230
|
+
while (index < length) {
|
|
1231
|
+
code = advance();
|
|
1232
|
+
let next;
|
|
1233
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1234
|
+
backslashes = token.backslashes = true;
|
|
1235
|
+
code = advance();
|
|
1236
|
+
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1240
|
+
braces++;
|
|
1241
|
+
while (eos() !== true && (code = advance())) {
|
|
1242
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1243
|
+
backslashes = token.backslashes = true;
|
|
1244
|
+
advance();
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1248
|
+
braces++;
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1252
|
+
isBrace = token.isBrace = true;
|
|
1253
|
+
isGlob = token.isGlob = true;
|
|
1254
|
+
finished = true;
|
|
1255
|
+
if (scanToEnd === true) continue;
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
1259
|
+
isBrace = token.isBrace = true;
|
|
1260
|
+
isGlob = token.isGlob = true;
|
|
1261
|
+
finished = true;
|
|
1262
|
+
if (scanToEnd === true) continue;
|
|
1263
|
+
break;
|
|
1264
|
+
}
|
|
1265
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1266
|
+
braces--;
|
|
1267
|
+
if (braces === 0) {
|
|
1268
|
+
braceEscaped = false;
|
|
1269
|
+
isBrace = token.isBrace = true;
|
|
1270
|
+
finished = true;
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (scanToEnd === true) continue;
|
|
1276
|
+
break;
|
|
1277
|
+
}
|
|
1278
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
1279
|
+
slashes.push(index);
|
|
1280
|
+
tokens.push(token);
|
|
1281
|
+
token = {
|
|
1282
|
+
value: "",
|
|
1283
|
+
depth: 0,
|
|
1284
|
+
isGlob: false
|
|
1285
|
+
};
|
|
1286
|
+
if (finished === true) continue;
|
|
1287
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
1288
|
+
start += 2;
|
|
1289
|
+
continue;
|
|
1290
|
+
}
|
|
1291
|
+
lastIndex = index + 1;
|
|
1292
|
+
continue;
|
|
1293
|
+
}
|
|
1294
|
+
if (opts.noext !== true) {
|
|
1295
|
+
if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1296
|
+
isGlob = token.isGlob = true;
|
|
1297
|
+
isExtglob = token.isExtglob = true;
|
|
1298
|
+
finished = true;
|
|
1299
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
1300
|
+
if (scanToEnd === true) {
|
|
1301
|
+
while (eos() !== true && (code = advance())) {
|
|
1302
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1303
|
+
backslashes = token.backslashes = true;
|
|
1304
|
+
code = advance();
|
|
1305
|
+
continue;
|
|
1306
|
+
}
|
|
1307
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1308
|
+
isGlob = token.isGlob = true;
|
|
1309
|
+
finished = true;
|
|
1310
|
+
break;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
continue;
|
|
1314
|
+
}
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
if (code === CHAR_ASTERISK) {
|
|
1319
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1320
|
+
isGlob = token.isGlob = true;
|
|
1321
|
+
finished = true;
|
|
1322
|
+
if (scanToEnd === true) continue;
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
1326
|
+
isGlob = token.isGlob = true;
|
|
1327
|
+
finished = true;
|
|
1328
|
+
if (scanToEnd === true) continue;
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1332
|
+
while (eos() !== true && (next = advance())) {
|
|
1333
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
1334
|
+
backslashes = token.backslashes = true;
|
|
1335
|
+
advance();
|
|
1336
|
+
continue;
|
|
1337
|
+
}
|
|
1338
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1339
|
+
isBracket = token.isBracket = true;
|
|
1340
|
+
isGlob = token.isGlob = true;
|
|
1341
|
+
finished = true;
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
if (scanToEnd === true) continue;
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1349
|
+
negated = token.negated = true;
|
|
1350
|
+
start++;
|
|
1351
|
+
continue;
|
|
1352
|
+
}
|
|
1353
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
1354
|
+
isGlob = token.isGlob = true;
|
|
1355
|
+
if (scanToEnd === true) {
|
|
1356
|
+
while (eos() !== true && (code = advance())) {
|
|
1357
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1358
|
+
backslashes = token.backslashes = true;
|
|
1359
|
+
code = advance();
|
|
1360
|
+
continue;
|
|
1361
|
+
}
|
|
1362
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1363
|
+
finished = true;
|
|
1364
|
+
break;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
break;
|
|
1370
|
+
}
|
|
1371
|
+
if (isGlob === true) {
|
|
1372
|
+
finished = true;
|
|
1373
|
+
if (scanToEnd === true) continue;
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
if (opts.noext === true) {
|
|
1378
|
+
isExtglob = false;
|
|
1379
|
+
isGlob = false;
|
|
1380
|
+
}
|
|
1381
|
+
let base = str;
|
|
1382
|
+
let prefix = "";
|
|
1383
|
+
let glob = "";
|
|
1384
|
+
if (start > 0) {
|
|
1385
|
+
prefix = str.slice(0, start);
|
|
1386
|
+
str = str.slice(start);
|
|
1387
|
+
lastIndex -= start;
|
|
1388
|
+
}
|
|
1389
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
1390
|
+
base = str.slice(0, lastIndex);
|
|
1391
|
+
glob = str.slice(lastIndex);
|
|
1392
|
+
} else if (isGlob === true) {
|
|
1393
|
+
base = "";
|
|
1394
|
+
glob = str;
|
|
1395
|
+
} else base = str;
|
|
1396
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
1397
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
1398
|
+
}
|
|
1399
|
+
if (opts.unescape === true) {
|
|
1400
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
1401
|
+
if (base && backslashes === true) base = utils.removeBackslashes(base);
|
|
1402
|
+
}
|
|
1403
|
+
const state = {
|
|
1404
|
+
prefix,
|
|
1405
|
+
input,
|
|
1406
|
+
start,
|
|
1407
|
+
base,
|
|
1408
|
+
glob,
|
|
1409
|
+
isBrace,
|
|
1410
|
+
isBracket,
|
|
1411
|
+
isGlob,
|
|
1412
|
+
isExtglob,
|
|
1413
|
+
isGlobstar,
|
|
1414
|
+
negated,
|
|
1415
|
+
negatedExtglob
|
|
1416
|
+
};
|
|
1417
|
+
if (opts.tokens === true) {
|
|
1418
|
+
state.maxDepth = 0;
|
|
1419
|
+
if (!isPathSeparator(code)) tokens.push(token);
|
|
1420
|
+
state.tokens = tokens;
|
|
1421
|
+
}
|
|
1422
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
1423
|
+
let prevIndex;
|
|
1424
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1425
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
1426
|
+
const i = slashes[idx];
|
|
1427
|
+
const value = input.slice(n, i);
|
|
1428
|
+
if (opts.tokens) {
|
|
1429
|
+
if (idx === 0 && start !== 0) {
|
|
1430
|
+
tokens[idx].isPrefix = true;
|
|
1431
|
+
tokens[idx].value = prefix;
|
|
1432
|
+
} else tokens[idx].value = value;
|
|
1433
|
+
depth(tokens[idx]);
|
|
1434
|
+
state.maxDepth += tokens[idx].depth;
|
|
1435
|
+
}
|
|
1436
|
+
if (idx !== 0 || value !== "") parts.push(value);
|
|
1437
|
+
prevIndex = i;
|
|
1438
|
+
}
|
|
1439
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1440
|
+
const value = input.slice(prevIndex + 1);
|
|
1441
|
+
parts.push(value);
|
|
1442
|
+
if (opts.tokens) {
|
|
1443
|
+
tokens[tokens.length - 1].value = value;
|
|
1444
|
+
depth(tokens[tokens.length - 1]);
|
|
1445
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
state.slashes = slashes;
|
|
1449
|
+
state.parts = parts;
|
|
1450
|
+
}
|
|
1451
|
+
return state;
|
|
1452
|
+
};
|
|
1453
|
+
module.exports = scan;
|
|
1454
|
+
}));
|
|
1455
|
+
//#endregion
|
|
1456
|
+
//#region ../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/parse.js
|
|
1457
|
+
var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
1458
|
+
const constants = require_constants();
|
|
1459
|
+
const utils = require_utils();
|
|
1460
|
+
/**
|
|
1461
|
+
* Constants
|
|
1462
|
+
*/
|
|
1463
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
1464
|
+
/**
|
|
1465
|
+
* Helpers
|
|
1466
|
+
*/
|
|
1467
|
+
const expandRange = (args, options) => {
|
|
1468
|
+
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
|
|
1469
|
+
args.sort();
|
|
1470
|
+
const value = `[${args.join("-")}]`;
|
|
1471
|
+
try {
|
|
1472
|
+
new RegExp(value);
|
|
1473
|
+
} catch (ex) {
|
|
1474
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
1475
|
+
}
|
|
1476
|
+
return value;
|
|
1477
|
+
};
|
|
1478
|
+
/**
|
|
1479
|
+
* Create the message for a syntax error
|
|
1480
|
+
*/
|
|
1481
|
+
const syntaxError = (type, char) => {
|
|
1482
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1483
|
+
};
|
|
1484
|
+
/**
|
|
1485
|
+
* Parse the given input string.
|
|
1486
|
+
* @param {String} input
|
|
1487
|
+
* @param {Object} options
|
|
1488
|
+
* @return {Object}
|
|
1489
|
+
*/
|
|
1490
|
+
const parse = (input, options) => {
|
|
1491
|
+
if (typeof input !== "string") throw new TypeError("Expected a string");
|
|
1492
|
+
input = REPLACEMENTS[input] || input;
|
|
1493
|
+
const opts = { ...options };
|
|
1494
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1495
|
+
let len = input.length;
|
|
1496
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1497
|
+
const bos = {
|
|
1498
|
+
type: "bos",
|
|
1499
|
+
value: "",
|
|
1500
|
+
output: opts.prepend || ""
|
|
1501
|
+
};
|
|
1502
|
+
const tokens = [bos];
|
|
1503
|
+
const capture = opts.capture ? "" : "?:";
|
|
1504
|
+
const win32 = utils.isWindows(options);
|
|
1505
|
+
const PLATFORM_CHARS = constants.globChars(win32);
|
|
1506
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
1507
|
+
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
1508
|
+
const globstar = (opts) => {
|
|
1509
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1510
|
+
};
|
|
1511
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
1512
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
1513
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
1514
|
+
if (opts.capture) star = `(${star})`;
|
|
1515
|
+
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
|
|
1516
|
+
const state = {
|
|
1517
|
+
input,
|
|
1518
|
+
index: -1,
|
|
1519
|
+
start: 0,
|
|
1520
|
+
dot: opts.dot === true,
|
|
1521
|
+
consumed: "",
|
|
1522
|
+
output: "",
|
|
1523
|
+
prefix: "",
|
|
1524
|
+
backtrack: false,
|
|
1525
|
+
negated: false,
|
|
1526
|
+
brackets: 0,
|
|
1527
|
+
braces: 0,
|
|
1528
|
+
parens: 0,
|
|
1529
|
+
quotes: 0,
|
|
1530
|
+
globstar: false,
|
|
1531
|
+
tokens
|
|
1532
|
+
};
|
|
1533
|
+
input = utils.removePrefix(input, state);
|
|
1534
|
+
len = input.length;
|
|
1535
|
+
const extglobs = [];
|
|
1536
|
+
const braces = [];
|
|
1537
|
+
const stack = [];
|
|
1538
|
+
let prev = bos;
|
|
1539
|
+
let value;
|
|
1540
|
+
/**
|
|
1541
|
+
* Tokenizing helpers
|
|
1542
|
+
*/
|
|
1543
|
+
const eos = () => state.index === len - 1;
|
|
1544
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1545
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
1546
|
+
const remaining = () => input.slice(state.index + 1);
|
|
1547
|
+
const consume = (value = "", num = 0) => {
|
|
1548
|
+
state.consumed += value;
|
|
1549
|
+
state.index += num;
|
|
1550
|
+
};
|
|
1551
|
+
const append = (token) => {
|
|
1552
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1553
|
+
consume(token.value);
|
|
1554
|
+
};
|
|
1555
|
+
const negate = () => {
|
|
1556
|
+
let count = 1;
|
|
1557
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
1558
|
+
advance();
|
|
1559
|
+
state.start++;
|
|
1560
|
+
count++;
|
|
1561
|
+
}
|
|
1562
|
+
if (count % 2 === 0) return false;
|
|
1563
|
+
state.negated = true;
|
|
1564
|
+
state.start++;
|
|
1565
|
+
return true;
|
|
1566
|
+
};
|
|
1567
|
+
const increment = (type) => {
|
|
1568
|
+
state[type]++;
|
|
1569
|
+
stack.push(type);
|
|
1570
|
+
};
|
|
1571
|
+
const decrement = (type) => {
|
|
1572
|
+
state[type]--;
|
|
1573
|
+
stack.pop();
|
|
1574
|
+
};
|
|
1575
|
+
/**
|
|
1576
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
1577
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
1578
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
1579
|
+
* characters are plain text. This improves performance and simplifies
|
|
1580
|
+
* lookbehinds.
|
|
1581
|
+
*/
|
|
1582
|
+
const push = (tok) => {
|
|
1583
|
+
if (prev.type === "globstar") {
|
|
1584
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
1585
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
1586
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
1587
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1588
|
+
prev.type = "star";
|
|
1589
|
+
prev.value = "*";
|
|
1590
|
+
prev.output = star;
|
|
1591
|
+
state.output += prev.output;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
|
|
1595
|
+
if (tok.value || tok.output) append(tok);
|
|
1596
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
1597
|
+
prev.value += tok.value;
|
|
1598
|
+
prev.output = (prev.output || "") + tok.value;
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
tok.prev = prev;
|
|
1602
|
+
tokens.push(tok);
|
|
1603
|
+
prev = tok;
|
|
1604
|
+
};
|
|
1605
|
+
const extglobOpen = (type, value) => {
|
|
1606
|
+
const token = {
|
|
1607
|
+
...EXTGLOB_CHARS[value],
|
|
1608
|
+
conditions: 1,
|
|
1609
|
+
inner: ""
|
|
1610
|
+
};
|
|
1611
|
+
token.prev = prev;
|
|
1612
|
+
token.parens = state.parens;
|
|
1613
|
+
token.output = state.output;
|
|
1614
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
1615
|
+
increment("parens");
|
|
1616
|
+
push({
|
|
1617
|
+
type,
|
|
1618
|
+
value,
|
|
1619
|
+
output: state.output ? "" : ONE_CHAR
|
|
1620
|
+
});
|
|
1621
|
+
push({
|
|
1622
|
+
type: "paren",
|
|
1623
|
+
extglob: true,
|
|
1624
|
+
value: advance(),
|
|
1625
|
+
output
|
|
1626
|
+
});
|
|
1627
|
+
extglobs.push(token);
|
|
1628
|
+
};
|
|
1629
|
+
const extglobClose = (token) => {
|
|
1630
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
1631
|
+
let rest;
|
|
1632
|
+
if (token.type === "negate") {
|
|
1633
|
+
let extglobStar = star;
|
|
1634
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
|
|
1635
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
1636
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
|
|
1637
|
+
...options,
|
|
1638
|
+
fastpaths: false
|
|
1639
|
+
}).output})${extglobStar})`;
|
|
1640
|
+
if (token.prev.type === "bos") state.negatedExtglob = true;
|
|
1641
|
+
}
|
|
1642
|
+
push({
|
|
1643
|
+
type: "paren",
|
|
1644
|
+
extglob: true,
|
|
1645
|
+
value,
|
|
1646
|
+
output
|
|
1647
|
+
});
|
|
1648
|
+
decrement("parens");
|
|
1649
|
+
};
|
|
1650
|
+
/**
|
|
1651
|
+
* Fast paths
|
|
1652
|
+
*/
|
|
1653
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1654
|
+
let backslashes = false;
|
|
1655
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1656
|
+
if (first === "\\") {
|
|
1657
|
+
backslashes = true;
|
|
1658
|
+
return m;
|
|
1659
|
+
}
|
|
1660
|
+
if (first === "?") {
|
|
1661
|
+
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1662
|
+
if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1663
|
+
return QMARK.repeat(chars.length);
|
|
1664
|
+
}
|
|
1665
|
+
if (first === ".") return DOT_LITERAL.repeat(chars.length);
|
|
1666
|
+
if (first === "*") {
|
|
1667
|
+
if (esc) return esc + first + (rest ? star : "");
|
|
1668
|
+
return star;
|
|
1669
|
+
}
|
|
1670
|
+
return esc ? m : `\\${m}`;
|
|
1671
|
+
});
|
|
1672
|
+
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
1673
|
+
else output = output.replace(/\\+/g, (m) => {
|
|
1674
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1675
|
+
});
|
|
1676
|
+
if (output === input && opts.contains === true) {
|
|
1677
|
+
state.output = input;
|
|
1678
|
+
return state;
|
|
1679
|
+
}
|
|
1680
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
1681
|
+
return state;
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Tokenize input until we reach end-of-string
|
|
1685
|
+
*/
|
|
1686
|
+
while (!eos()) {
|
|
1687
|
+
value = advance();
|
|
1688
|
+
if (value === "\0") continue;
|
|
1689
|
+
/**
|
|
1690
|
+
* Escaped characters
|
|
1691
|
+
*/
|
|
1692
|
+
if (value === "\\") {
|
|
1693
|
+
const next = peek();
|
|
1694
|
+
if (next === "/" && opts.bash !== true) continue;
|
|
1695
|
+
if (next === "." || next === ";") continue;
|
|
1696
|
+
if (!next) {
|
|
1697
|
+
value += "\\";
|
|
1698
|
+
push({
|
|
1699
|
+
type: "text",
|
|
1700
|
+
value
|
|
1701
|
+
});
|
|
1702
|
+
continue;
|
|
1703
|
+
}
|
|
1704
|
+
const match = /^\\+/.exec(remaining());
|
|
1705
|
+
let slashes = 0;
|
|
1706
|
+
if (match && match[0].length > 2) {
|
|
1707
|
+
slashes = match[0].length;
|
|
1708
|
+
state.index += slashes;
|
|
1709
|
+
if (slashes % 2 !== 0) value += "\\";
|
|
1710
|
+
}
|
|
1711
|
+
if (opts.unescape === true) value = advance();
|
|
1712
|
+
else value += advance();
|
|
1713
|
+
if (state.brackets === 0) {
|
|
1714
|
+
push({
|
|
1715
|
+
type: "text",
|
|
1716
|
+
value
|
|
1717
|
+
});
|
|
1718
|
+
continue;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* If we're inside a regex character class, continue
|
|
1723
|
+
* until we reach the closing bracket.
|
|
1724
|
+
*/
|
|
1725
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1726
|
+
if (opts.posix !== false && value === ":") {
|
|
1727
|
+
const inner = prev.value.slice(1);
|
|
1728
|
+
if (inner.includes("[")) {
|
|
1729
|
+
prev.posix = true;
|
|
1730
|
+
if (inner.includes(":")) {
|
|
1731
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1732
|
+
const pre = prev.value.slice(0, idx);
|
|
1733
|
+
const posix = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
|
|
1734
|
+
if (posix) {
|
|
1735
|
+
prev.value = pre + posix;
|
|
1736
|
+
state.backtrack = true;
|
|
1737
|
+
advance();
|
|
1738
|
+
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
|
|
1739
|
+
continue;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
|
|
1745
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
|
|
1746
|
+
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
|
|
1747
|
+
prev.value += value;
|
|
1748
|
+
append({ value });
|
|
1749
|
+
continue;
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* If we're inside a quoted string, continue
|
|
1753
|
+
* until we reach the closing double quote.
|
|
1754
|
+
*/
|
|
1755
|
+
if (state.quotes === 1 && value !== "\"") {
|
|
1756
|
+
value = utils.escapeRegex(value);
|
|
1757
|
+
prev.value += value;
|
|
1758
|
+
append({ value });
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Double quotes
|
|
1763
|
+
*/
|
|
1764
|
+
if (value === "\"") {
|
|
1765
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1766
|
+
if (opts.keepQuotes === true) push({
|
|
1767
|
+
type: "text",
|
|
1768
|
+
value
|
|
1769
|
+
});
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Parentheses
|
|
1774
|
+
*/
|
|
1775
|
+
if (value === "(") {
|
|
1776
|
+
increment("parens");
|
|
1777
|
+
push({
|
|
1778
|
+
type: "paren",
|
|
1779
|
+
value
|
|
1780
|
+
});
|
|
1781
|
+
continue;
|
|
1782
|
+
}
|
|
1783
|
+
if (value === ")") {
|
|
1784
|
+
if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
|
|
1785
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1786
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1787
|
+
extglobClose(extglobs.pop());
|
|
1788
|
+
continue;
|
|
1789
|
+
}
|
|
1790
|
+
push({
|
|
1791
|
+
type: "paren",
|
|
1792
|
+
value,
|
|
1793
|
+
output: state.parens ? ")" : "\\)"
|
|
1794
|
+
});
|
|
1795
|
+
decrement("parens");
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Square brackets
|
|
1800
|
+
*/
|
|
1801
|
+
if (value === "[") {
|
|
1802
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1803
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1804
|
+
value = `\\${value}`;
|
|
1805
|
+
} else increment("brackets");
|
|
1806
|
+
push({
|
|
1807
|
+
type: "bracket",
|
|
1808
|
+
value
|
|
1809
|
+
});
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
if (value === "]") {
|
|
1813
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1814
|
+
push({
|
|
1815
|
+
type: "text",
|
|
1816
|
+
value,
|
|
1817
|
+
output: `\\${value}`
|
|
1818
|
+
});
|
|
1819
|
+
continue;
|
|
1820
|
+
}
|
|
1821
|
+
if (state.brackets === 0) {
|
|
1822
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
|
|
1823
|
+
push({
|
|
1824
|
+
type: "text",
|
|
1825
|
+
value,
|
|
1826
|
+
output: `\\${value}`
|
|
1827
|
+
});
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1830
|
+
decrement("brackets");
|
|
1831
|
+
const prevValue = prev.value.slice(1);
|
|
1832
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
|
|
1833
|
+
prev.value += value;
|
|
1834
|
+
append({ value });
|
|
1835
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
|
|
1836
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1837
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1838
|
+
if (opts.literalBrackets === true) {
|
|
1839
|
+
state.output += escaped;
|
|
1840
|
+
prev.value = escaped;
|
|
1841
|
+
continue;
|
|
1842
|
+
}
|
|
1843
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1844
|
+
state.output += prev.value;
|
|
1845
|
+
continue;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Braces
|
|
1849
|
+
*/
|
|
1850
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1851
|
+
increment("braces");
|
|
1852
|
+
const open = {
|
|
1853
|
+
type: "brace",
|
|
1854
|
+
value,
|
|
1855
|
+
output: "(",
|
|
1856
|
+
outputIndex: state.output.length,
|
|
1857
|
+
tokensIndex: state.tokens.length
|
|
1858
|
+
};
|
|
1859
|
+
braces.push(open);
|
|
1860
|
+
push(open);
|
|
1861
|
+
continue;
|
|
1862
|
+
}
|
|
1863
|
+
if (value === "}") {
|
|
1864
|
+
const brace = braces[braces.length - 1];
|
|
1865
|
+
if (opts.nobrace === true || !brace) {
|
|
1866
|
+
push({
|
|
1867
|
+
type: "text",
|
|
1868
|
+
value,
|
|
1869
|
+
output: value
|
|
1870
|
+
});
|
|
1871
|
+
continue;
|
|
1872
|
+
}
|
|
1873
|
+
let output = ")";
|
|
1874
|
+
if (brace.dots === true) {
|
|
1875
|
+
const arr = tokens.slice();
|
|
1876
|
+
const range = [];
|
|
1877
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1878
|
+
tokens.pop();
|
|
1879
|
+
if (arr[i].type === "brace") break;
|
|
1880
|
+
if (arr[i].type !== "dots") range.unshift(arr[i].value);
|
|
1881
|
+
}
|
|
1882
|
+
output = expandRange(range, opts);
|
|
1883
|
+
state.backtrack = true;
|
|
1884
|
+
}
|
|
1885
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1886
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1887
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1888
|
+
brace.value = brace.output = "\\{";
|
|
1889
|
+
value = output = "\\}";
|
|
1890
|
+
state.output = out;
|
|
1891
|
+
for (const t of toks) state.output += t.output || t.value;
|
|
1892
|
+
}
|
|
1893
|
+
push({
|
|
1894
|
+
type: "brace",
|
|
1895
|
+
value,
|
|
1896
|
+
output
|
|
1897
|
+
});
|
|
1898
|
+
decrement("braces");
|
|
1899
|
+
braces.pop();
|
|
1900
|
+
continue;
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Pipes
|
|
1904
|
+
*/
|
|
1905
|
+
if (value === "|") {
|
|
1906
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
1907
|
+
push({
|
|
1908
|
+
type: "text",
|
|
1909
|
+
value
|
|
1910
|
+
});
|
|
1911
|
+
continue;
|
|
1912
|
+
}
|
|
1913
|
+
/**
|
|
1914
|
+
* Commas
|
|
1915
|
+
*/
|
|
1916
|
+
if (value === ",") {
|
|
1917
|
+
let output = value;
|
|
1918
|
+
const brace = braces[braces.length - 1];
|
|
1919
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1920
|
+
brace.comma = true;
|
|
1921
|
+
output = "|";
|
|
1922
|
+
}
|
|
1923
|
+
push({
|
|
1924
|
+
type: "comma",
|
|
1925
|
+
value,
|
|
1926
|
+
output
|
|
1927
|
+
});
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Slashes
|
|
1932
|
+
*/
|
|
1933
|
+
if (value === "/") {
|
|
1934
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1935
|
+
state.start = state.index + 1;
|
|
1936
|
+
state.consumed = "";
|
|
1937
|
+
state.output = "";
|
|
1938
|
+
tokens.pop();
|
|
1939
|
+
prev = bos;
|
|
1940
|
+
continue;
|
|
1941
|
+
}
|
|
1942
|
+
push({
|
|
1943
|
+
type: "slash",
|
|
1944
|
+
value,
|
|
1945
|
+
output: SLASH_LITERAL
|
|
1946
|
+
});
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Dots
|
|
1951
|
+
*/
|
|
1952
|
+
if (value === ".") {
|
|
1953
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1954
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1955
|
+
const brace = braces[braces.length - 1];
|
|
1956
|
+
prev.type = "dots";
|
|
1957
|
+
prev.output += value;
|
|
1958
|
+
prev.value += value;
|
|
1959
|
+
brace.dots = true;
|
|
1960
|
+
continue;
|
|
1961
|
+
}
|
|
1962
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1963
|
+
push({
|
|
1964
|
+
type: "text",
|
|
1965
|
+
value,
|
|
1966
|
+
output: DOT_LITERAL
|
|
1967
|
+
});
|
|
1968
|
+
continue;
|
|
1969
|
+
}
|
|
1970
|
+
push({
|
|
1971
|
+
type: "dot",
|
|
1972
|
+
value,
|
|
1973
|
+
output: DOT_LITERAL
|
|
1974
|
+
});
|
|
1975
|
+
continue;
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Question marks
|
|
1979
|
+
*/
|
|
1980
|
+
if (value === "?") {
|
|
1981
|
+
if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1982
|
+
extglobOpen("qmark", value);
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
if (prev && prev.type === "paren") {
|
|
1986
|
+
const next = peek();
|
|
1987
|
+
let output = value;
|
|
1988
|
+
if (next === "<" && !utils.supportsLookbehinds()) throw new Error("Node.js v10 or higher is required for regex lookbehinds");
|
|
1989
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
1990
|
+
push({
|
|
1991
|
+
type: "text",
|
|
1992
|
+
value,
|
|
1993
|
+
output
|
|
1994
|
+
});
|
|
1995
|
+
continue;
|
|
1996
|
+
}
|
|
1997
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1998
|
+
push({
|
|
1999
|
+
type: "qmark",
|
|
2000
|
+
value,
|
|
2001
|
+
output: QMARK_NO_DOT
|
|
2002
|
+
});
|
|
2003
|
+
continue;
|
|
2004
|
+
}
|
|
2005
|
+
push({
|
|
2006
|
+
type: "qmark",
|
|
2007
|
+
value,
|
|
2008
|
+
output: QMARK
|
|
2009
|
+
});
|
|
2010
|
+
continue;
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Exclamation
|
|
2014
|
+
*/
|
|
2015
|
+
if (value === "!") {
|
|
2016
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
2017
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
2018
|
+
extglobOpen("negate", value);
|
|
2019
|
+
continue;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
2023
|
+
negate();
|
|
2024
|
+
continue;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Plus
|
|
2029
|
+
*/
|
|
2030
|
+
if (value === "+") {
|
|
2031
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
2032
|
+
extglobOpen("plus", value);
|
|
2033
|
+
continue;
|
|
2034
|
+
}
|
|
2035
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
2036
|
+
push({
|
|
2037
|
+
type: "plus",
|
|
2038
|
+
value,
|
|
2039
|
+
output: PLUS_LITERAL
|
|
2040
|
+
});
|
|
2041
|
+
continue;
|
|
2042
|
+
}
|
|
2043
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
2044
|
+
push({
|
|
2045
|
+
type: "plus",
|
|
2046
|
+
value
|
|
2047
|
+
});
|
|
2048
|
+
continue;
|
|
2049
|
+
}
|
|
2050
|
+
push({
|
|
2051
|
+
type: "plus",
|
|
2052
|
+
value: PLUS_LITERAL
|
|
2053
|
+
});
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* Plain text
|
|
2058
|
+
*/
|
|
2059
|
+
if (value === "@") {
|
|
2060
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
2061
|
+
push({
|
|
2062
|
+
type: "at",
|
|
2063
|
+
extglob: true,
|
|
2064
|
+
value,
|
|
2065
|
+
output: ""
|
|
2066
|
+
});
|
|
2067
|
+
continue;
|
|
2068
|
+
}
|
|
2069
|
+
push({
|
|
2070
|
+
type: "text",
|
|
2071
|
+
value
|
|
2072
|
+
});
|
|
2073
|
+
continue;
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Plain text
|
|
2077
|
+
*/
|
|
2078
|
+
if (value !== "*") {
|
|
2079
|
+
if (value === "$" || value === "^") value = `\\${value}`;
|
|
2080
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
2081
|
+
if (match) {
|
|
2082
|
+
value += match[0];
|
|
2083
|
+
state.index += match[0].length;
|
|
2084
|
+
}
|
|
2085
|
+
push({
|
|
2086
|
+
type: "text",
|
|
2087
|
+
value
|
|
2088
|
+
});
|
|
2089
|
+
continue;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Stars
|
|
2093
|
+
*/
|
|
2094
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
2095
|
+
prev.type = "star";
|
|
2096
|
+
prev.star = true;
|
|
2097
|
+
prev.value += value;
|
|
2098
|
+
prev.output = star;
|
|
2099
|
+
state.backtrack = true;
|
|
2100
|
+
state.globstar = true;
|
|
2101
|
+
consume(value);
|
|
2102
|
+
continue;
|
|
2103
|
+
}
|
|
2104
|
+
let rest = remaining();
|
|
2105
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
2106
|
+
extglobOpen("star", value);
|
|
2107
|
+
continue;
|
|
2108
|
+
}
|
|
2109
|
+
if (prev.type === "star") {
|
|
2110
|
+
if (opts.noglobstar === true) {
|
|
2111
|
+
consume(value);
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
const prior = prev.prev;
|
|
2115
|
+
const before = prior.prev;
|
|
2116
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
2117
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
2118
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
2119
|
+
push({
|
|
2120
|
+
type: "star",
|
|
2121
|
+
value,
|
|
2122
|
+
output: ""
|
|
2123
|
+
});
|
|
2124
|
+
continue;
|
|
2125
|
+
}
|
|
2126
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
2127
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
2128
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
2129
|
+
push({
|
|
2130
|
+
type: "star",
|
|
2131
|
+
value,
|
|
2132
|
+
output: ""
|
|
2133
|
+
});
|
|
2134
|
+
continue;
|
|
2135
|
+
}
|
|
2136
|
+
while (rest.slice(0, 3) === "/**") {
|
|
2137
|
+
const after = input[state.index + 4];
|
|
2138
|
+
if (after && after !== "/") break;
|
|
2139
|
+
rest = rest.slice(3);
|
|
2140
|
+
consume("/**", 3);
|
|
2141
|
+
}
|
|
2142
|
+
if (prior.type === "bos" && eos()) {
|
|
2143
|
+
prev.type = "globstar";
|
|
2144
|
+
prev.value += value;
|
|
2145
|
+
prev.output = globstar(opts);
|
|
2146
|
+
state.output = prev.output;
|
|
2147
|
+
state.globstar = true;
|
|
2148
|
+
consume(value);
|
|
2149
|
+
continue;
|
|
2150
|
+
}
|
|
2151
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
2152
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2153
|
+
prior.output = `(?:${prior.output}`;
|
|
2154
|
+
prev.type = "globstar";
|
|
2155
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
2156
|
+
prev.value += value;
|
|
2157
|
+
state.globstar = true;
|
|
2158
|
+
state.output += prior.output + prev.output;
|
|
2159
|
+
consume(value);
|
|
2160
|
+
continue;
|
|
2161
|
+
}
|
|
2162
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
2163
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
2164
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2165
|
+
prior.output = `(?:${prior.output}`;
|
|
2166
|
+
prev.type = "globstar";
|
|
2167
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
2168
|
+
prev.value += value;
|
|
2169
|
+
state.output += prior.output + prev.output;
|
|
2170
|
+
state.globstar = true;
|
|
2171
|
+
consume(value + advance());
|
|
2172
|
+
push({
|
|
2173
|
+
type: "slash",
|
|
2174
|
+
value: "/",
|
|
2175
|
+
output: ""
|
|
2176
|
+
});
|
|
2177
|
+
continue;
|
|
2178
|
+
}
|
|
2179
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
2180
|
+
prev.type = "globstar";
|
|
2181
|
+
prev.value += value;
|
|
2182
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
2183
|
+
state.output = prev.output;
|
|
2184
|
+
state.globstar = true;
|
|
2185
|
+
consume(value + advance());
|
|
2186
|
+
push({
|
|
2187
|
+
type: "slash",
|
|
2188
|
+
value: "/",
|
|
2189
|
+
output: ""
|
|
2190
|
+
});
|
|
2191
|
+
continue;
|
|
2192
|
+
}
|
|
2193
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
2194
|
+
prev.type = "globstar";
|
|
2195
|
+
prev.output = globstar(opts);
|
|
2196
|
+
prev.value += value;
|
|
2197
|
+
state.output += prev.output;
|
|
2198
|
+
state.globstar = true;
|
|
2199
|
+
consume(value);
|
|
2200
|
+
continue;
|
|
2201
|
+
}
|
|
2202
|
+
const token = {
|
|
2203
|
+
type: "star",
|
|
2204
|
+
value,
|
|
2205
|
+
output: star
|
|
2206
|
+
};
|
|
2207
|
+
if (opts.bash === true) {
|
|
2208
|
+
token.output = ".*?";
|
|
2209
|
+
if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
|
|
2210
|
+
push(token);
|
|
2211
|
+
continue;
|
|
2212
|
+
}
|
|
2213
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
2214
|
+
token.output = value;
|
|
2215
|
+
push(token);
|
|
2216
|
+
continue;
|
|
2217
|
+
}
|
|
2218
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
2219
|
+
if (prev.type === "dot") {
|
|
2220
|
+
state.output += NO_DOT_SLASH;
|
|
2221
|
+
prev.output += NO_DOT_SLASH;
|
|
2222
|
+
} else if (opts.dot === true) {
|
|
2223
|
+
state.output += NO_DOTS_SLASH;
|
|
2224
|
+
prev.output += NO_DOTS_SLASH;
|
|
2225
|
+
} else {
|
|
2226
|
+
state.output += nodot;
|
|
2227
|
+
prev.output += nodot;
|
|
2228
|
+
}
|
|
2229
|
+
if (peek() !== "*") {
|
|
2230
|
+
state.output += ONE_CHAR;
|
|
2231
|
+
prev.output += ONE_CHAR;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
push(token);
|
|
2235
|
+
}
|
|
2236
|
+
while (state.brackets > 0) {
|
|
2237
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
2238
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
2239
|
+
decrement("brackets");
|
|
2240
|
+
}
|
|
2241
|
+
while (state.parens > 0) {
|
|
2242
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
2243
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
2244
|
+
decrement("parens");
|
|
2245
|
+
}
|
|
2246
|
+
while (state.braces > 0) {
|
|
2247
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
2248
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
2249
|
+
decrement("braces");
|
|
2250
|
+
}
|
|
2251
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
|
|
2252
|
+
type: "maybe_slash",
|
|
2253
|
+
value: "",
|
|
2254
|
+
output: `${SLASH_LITERAL}?`
|
|
2255
|
+
});
|
|
2256
|
+
if (state.backtrack === true) {
|
|
2257
|
+
state.output = "";
|
|
2258
|
+
for (const token of state.tokens) {
|
|
2259
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2260
|
+
if (token.suffix) state.output += token.suffix;
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
return state;
|
|
2264
|
+
};
|
|
2265
|
+
/**
|
|
2266
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
2267
|
+
* This can significantly speed up processing and has very little downside
|
|
2268
|
+
* impact when none of the fast paths match.
|
|
2269
|
+
*/
|
|
2270
|
+
parse.fastpaths = (input, options) => {
|
|
2271
|
+
const opts = { ...options };
|
|
2272
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2273
|
+
const len = input.length;
|
|
2274
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2275
|
+
input = REPLACEMENTS[input] || input;
|
|
2276
|
+
const win32 = utils.isWindows(options);
|
|
2277
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(win32);
|
|
2278
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
2279
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
2280
|
+
const capture = opts.capture ? "" : "?:";
|
|
2281
|
+
const state = {
|
|
2282
|
+
negated: false,
|
|
2283
|
+
prefix: ""
|
|
2284
|
+
};
|
|
2285
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
2286
|
+
if (opts.capture) star = `(${star})`;
|
|
2287
|
+
const globstar = (opts) => {
|
|
2288
|
+
if (opts.noglobstar === true) return star;
|
|
2289
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
2290
|
+
};
|
|
2291
|
+
const create = (str) => {
|
|
2292
|
+
switch (str) {
|
|
2293
|
+
case "*": return `${nodot}${ONE_CHAR}${star}`;
|
|
2294
|
+
case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2295
|
+
case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2296
|
+
case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
2297
|
+
case "**": return nodot + globstar(opts);
|
|
2298
|
+
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
2299
|
+
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2300
|
+
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2301
|
+
default: {
|
|
2302
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
2303
|
+
if (!match) return;
|
|
2304
|
+
const source = create(match[1]);
|
|
2305
|
+
if (!source) return;
|
|
2306
|
+
return source + DOT_LITERAL + match[2];
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
let source = create(utils.removePrefix(input, state));
|
|
2311
|
+
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
|
|
2312
|
+
return source;
|
|
2313
|
+
};
|
|
2314
|
+
module.exports = parse;
|
|
2315
|
+
}));
|
|
2316
|
+
//#endregion
|
|
2317
|
+
//#region ../../node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js
|
|
2318
|
+
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2319
|
+
const path$1 = __require("path");
|
|
2320
|
+
const scan = require_scan();
|
|
2321
|
+
const parse = require_parse();
|
|
2322
|
+
const utils = require_utils();
|
|
2323
|
+
const constants = require_constants();
|
|
2324
|
+
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
2325
|
+
/**
|
|
2326
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
2327
|
+
* returned function takes a string to match as its first argument,
|
|
2328
|
+
* and returns true if the string is a match. The returned matcher
|
|
2329
|
+
* function also takes a boolean as the second argument that, when true,
|
|
2330
|
+
* returns an object with additional information.
|
|
2331
|
+
*
|
|
2332
|
+
* ```js
|
|
2333
|
+
* const picomatch = require('picomatch');
|
|
2334
|
+
* // picomatch(glob[, options]);
|
|
2335
|
+
*
|
|
2336
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
2337
|
+
* console.log(isMatch('a.a')); //=> false
|
|
2338
|
+
* console.log(isMatch('a.b')); //=> true
|
|
2339
|
+
* ```
|
|
2340
|
+
* @name picomatch
|
|
2341
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
2342
|
+
* @param {Object=} `options`
|
|
2343
|
+
* @return {Function=} Returns a matcher function.
|
|
2344
|
+
* @api public
|
|
2345
|
+
*/
|
|
2346
|
+
const picomatch = (glob, options, returnState = false) => {
|
|
2347
|
+
if (Array.isArray(glob)) {
|
|
2348
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
2349
|
+
const arrayMatcher = (str) => {
|
|
2350
|
+
for (const isMatch of fns) {
|
|
2351
|
+
const state = isMatch(str);
|
|
2352
|
+
if (state) return state;
|
|
2353
|
+
}
|
|
2354
|
+
return false;
|
|
2355
|
+
};
|
|
2356
|
+
return arrayMatcher;
|
|
2357
|
+
}
|
|
2358
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
2359
|
+
if (glob === "" || typeof glob !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
|
|
2360
|
+
const opts = options || {};
|
|
2361
|
+
const posix = utils.isWindows(options);
|
|
2362
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
2363
|
+
const state = regex.state;
|
|
2364
|
+
delete regex.state;
|
|
2365
|
+
let isIgnored = () => false;
|
|
2366
|
+
if (opts.ignore) {
|
|
2367
|
+
const ignoreOpts = {
|
|
2368
|
+
...options,
|
|
2369
|
+
ignore: null,
|
|
2370
|
+
onMatch: null,
|
|
2371
|
+
onResult: null
|
|
2372
|
+
};
|
|
2373
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
2374
|
+
}
|
|
2375
|
+
const matcher = (input, returnObject = false) => {
|
|
2376
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
2377
|
+
glob,
|
|
2378
|
+
posix
|
|
2379
|
+
});
|
|
2380
|
+
const result = {
|
|
2381
|
+
glob,
|
|
2382
|
+
state,
|
|
2383
|
+
regex,
|
|
2384
|
+
posix,
|
|
2385
|
+
input,
|
|
2386
|
+
output,
|
|
2387
|
+
match,
|
|
2388
|
+
isMatch
|
|
2389
|
+
};
|
|
2390
|
+
if (typeof opts.onResult === "function") opts.onResult(result);
|
|
2391
|
+
if (isMatch === false) {
|
|
2392
|
+
result.isMatch = false;
|
|
2393
|
+
return returnObject ? result : false;
|
|
2394
|
+
}
|
|
2395
|
+
if (isIgnored(input)) {
|
|
2396
|
+
if (typeof opts.onIgnore === "function") opts.onIgnore(result);
|
|
2397
|
+
result.isMatch = false;
|
|
2398
|
+
return returnObject ? result : false;
|
|
2399
|
+
}
|
|
2400
|
+
if (typeof opts.onMatch === "function") opts.onMatch(result);
|
|
2401
|
+
return returnObject ? result : true;
|
|
2402
|
+
};
|
|
2403
|
+
if (returnState) matcher.state = state;
|
|
2404
|
+
return matcher;
|
|
2405
|
+
};
|
|
2406
|
+
/**
|
|
2407
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
2408
|
+
* `picomatch()` function to test the input string.
|
|
2409
|
+
*
|
|
2410
|
+
* ```js
|
|
2411
|
+
* const picomatch = require('picomatch');
|
|
2412
|
+
* // picomatch.test(input, regex[, options]);
|
|
2413
|
+
*
|
|
2414
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
2415
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
2416
|
+
* ```
|
|
2417
|
+
* @param {String} `input` String to test.
|
|
2418
|
+
* @param {RegExp} `regex`
|
|
2419
|
+
* @return {Object} Returns an object with matching info.
|
|
2420
|
+
* @api public
|
|
2421
|
+
*/
|
|
2422
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
2423
|
+
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
|
|
2424
|
+
if (input === "") return {
|
|
2425
|
+
isMatch: false,
|
|
2426
|
+
output: ""
|
|
2427
|
+
};
|
|
2428
|
+
const opts = options || {};
|
|
2429
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
2430
|
+
let match = input === glob;
|
|
2431
|
+
let output = match && format ? format(input) : input;
|
|
2432
|
+
if (match === false) {
|
|
2433
|
+
output = format ? format(input) : input;
|
|
2434
|
+
match = output === glob;
|
|
2435
|
+
}
|
|
2436
|
+
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
|
|
2437
|
+
else match = regex.exec(output);
|
|
2438
|
+
return {
|
|
2439
|
+
isMatch: Boolean(match),
|
|
2440
|
+
match,
|
|
2441
|
+
output
|
|
2442
|
+
};
|
|
2443
|
+
};
|
|
2444
|
+
/**
|
|
2445
|
+
* Match the basename of a filepath.
|
|
2446
|
+
*
|
|
2447
|
+
* ```js
|
|
2448
|
+
* const picomatch = require('picomatch');
|
|
2449
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
2450
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
2451
|
+
* ```
|
|
2452
|
+
* @param {String} `input` String to test.
|
|
2453
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
2454
|
+
* @return {Boolean}
|
|
2455
|
+
* @api public
|
|
2456
|
+
*/
|
|
2457
|
+
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
2458
|
+
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(path$1.basename(input));
|
|
2459
|
+
};
|
|
2460
|
+
/**
|
|
2461
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
2462
|
+
*
|
|
2463
|
+
* ```js
|
|
2464
|
+
* const picomatch = require('picomatch');
|
|
2465
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
2466
|
+
*
|
|
2467
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
2468
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
2469
|
+
* ```
|
|
2470
|
+
* @param {String|Array} str The string to test.
|
|
2471
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
2472
|
+
* @param {Object} [options] See available [options](#options).
|
|
2473
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
2474
|
+
* @api public
|
|
2475
|
+
*/
|
|
2476
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
2477
|
+
/**
|
|
2478
|
+
* Parse a glob pattern to create the source string for a regular
|
|
2479
|
+
* expression.
|
|
2480
|
+
*
|
|
2481
|
+
* ```js
|
|
2482
|
+
* const picomatch = require('picomatch');
|
|
2483
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
2484
|
+
* ```
|
|
2485
|
+
* @param {String} `pattern`
|
|
2486
|
+
* @param {Object} `options`
|
|
2487
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
2488
|
+
* @api public
|
|
2489
|
+
*/
|
|
2490
|
+
picomatch.parse = (pattern, options) => {
|
|
2491
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
2492
|
+
return parse(pattern, {
|
|
2493
|
+
...options,
|
|
2494
|
+
fastpaths: false
|
|
2495
|
+
});
|
|
2496
|
+
};
|
|
2497
|
+
/**
|
|
2498
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
2499
|
+
*
|
|
2500
|
+
* ```js
|
|
2501
|
+
* const picomatch = require('picomatch');
|
|
2502
|
+
* // picomatch.scan(input[, options]);
|
|
2503
|
+
*
|
|
2504
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
2505
|
+
* console.log(result);
|
|
2506
|
+
* { prefix: '!./',
|
|
2507
|
+
* input: '!./foo/*.js',
|
|
2508
|
+
* start: 3,
|
|
2509
|
+
* base: 'foo',
|
|
2510
|
+
* glob: '*.js',
|
|
2511
|
+
* isBrace: false,
|
|
2512
|
+
* isBracket: false,
|
|
2513
|
+
* isGlob: true,
|
|
2514
|
+
* isExtglob: false,
|
|
2515
|
+
* isGlobstar: false,
|
|
2516
|
+
* negated: true }
|
|
2517
|
+
* ```
|
|
2518
|
+
* @param {String} `input` Glob pattern to scan.
|
|
2519
|
+
* @param {Object} `options`
|
|
2520
|
+
* @return {Object} Returns an object with
|
|
2521
|
+
* @api public
|
|
2522
|
+
*/
|
|
2523
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
2524
|
+
/**
|
|
2525
|
+
* Compile a regular expression from the `state` object returned by the
|
|
2526
|
+
* [parse()](#parse) method.
|
|
2527
|
+
*
|
|
2528
|
+
* @param {Object} `state`
|
|
2529
|
+
* @param {Object} `options`
|
|
2530
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
2531
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
2532
|
+
* @return {RegExp}
|
|
2533
|
+
* @api public
|
|
2534
|
+
*/
|
|
2535
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
2536
|
+
if (returnOutput === true) return state.output;
|
|
2537
|
+
const opts = options || {};
|
|
2538
|
+
const prepend = opts.contains ? "" : "^";
|
|
2539
|
+
const append = opts.contains ? "" : "$";
|
|
2540
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
2541
|
+
if (state && state.negated === true) source = `^(?!${source}).*$`;
|
|
2542
|
+
const regex = picomatch.toRegex(source, options);
|
|
2543
|
+
if (returnState === true) regex.state = state;
|
|
2544
|
+
return regex;
|
|
2545
|
+
};
|
|
2546
|
+
/**
|
|
2547
|
+
* Create a regular expression from a parsed glob pattern.
|
|
2548
|
+
*
|
|
2549
|
+
* ```js
|
|
2550
|
+
* const picomatch = require('picomatch');
|
|
2551
|
+
* const state = picomatch.parse('*.js');
|
|
2552
|
+
* // picomatch.compileRe(state[, options]);
|
|
2553
|
+
*
|
|
2554
|
+
* console.log(picomatch.compileRe(state));
|
|
2555
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2556
|
+
* ```
|
|
2557
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
2558
|
+
* @param {Object} `options`
|
|
2559
|
+
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
2560
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
2561
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
2562
|
+
* @api public
|
|
2563
|
+
*/
|
|
2564
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
2565
|
+
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
|
|
2566
|
+
let parsed = {
|
|
2567
|
+
negated: false,
|
|
2568
|
+
fastpaths: true
|
|
2569
|
+
};
|
|
2570
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
|
|
2571
|
+
if (!parsed.output) parsed = parse(input, options);
|
|
2572
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
2573
|
+
};
|
|
2574
|
+
/**
|
|
2575
|
+
* Create a regular expression from the given regex source string.
|
|
2576
|
+
*
|
|
2577
|
+
* ```js
|
|
2578
|
+
* const picomatch = require('picomatch');
|
|
2579
|
+
* // picomatch.toRegex(source[, options]);
|
|
2580
|
+
*
|
|
2581
|
+
* const { output } = picomatch.parse('*.js');
|
|
2582
|
+
* console.log(picomatch.toRegex(output));
|
|
2583
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2584
|
+
* ```
|
|
2585
|
+
* @param {String} `source` Regular expression source string.
|
|
2586
|
+
* @param {Object} `options`
|
|
2587
|
+
* @return {RegExp}
|
|
2588
|
+
* @api public
|
|
2589
|
+
*/
|
|
2590
|
+
picomatch.toRegex = (source, options) => {
|
|
2591
|
+
try {
|
|
2592
|
+
const opts = options || {};
|
|
2593
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
2594
|
+
} catch (err) {
|
|
2595
|
+
if (options && options.debug === true) throw err;
|
|
2596
|
+
return /$^/;
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
/**
|
|
2600
|
+
* Picomatch constants.
|
|
2601
|
+
* @return {Object}
|
|
2602
|
+
*/
|
|
2603
|
+
picomatch.constants = constants;
|
|
2604
|
+
/**
|
|
2605
|
+
* Expose "picomatch"
|
|
2606
|
+
*/
|
|
2607
|
+
module.exports = picomatch;
|
|
2608
|
+
}));
|
|
2609
|
+
//#endregion
|
|
874
2610
|
//#region ../core/dist/index.js
|
|
2611
|
+
var import_picomatch = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
2612
|
+
module.exports = require_picomatch$1();
|
|
2613
|
+
})))(), 1);
|
|
875
2614
|
var __create = Object.create;
|
|
876
2615
|
var __defProp = Object.defineProperty;
|
|
877
2616
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -893,30 +2632,53 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
893
2632
|
value: mod,
|
|
894
2633
|
enumerable: true
|
|
895
2634
|
}) : target, mod));
|
|
896
|
-
const
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
2635
|
+
const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
|
|
2636
|
+
const SCORE_API_URL = "https://www.react.doctor/api/score";
|
|
2637
|
+
const FETCH_TIMEOUT_MS = 1e4;
|
|
2638
|
+
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
2639
|
+
const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
|
|
2640
|
+
const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
|
|
2641
|
+
const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
|
|
2642
|
+
var InvalidGlobPatternError = class extends Error {
|
|
2643
|
+
pattern;
|
|
2644
|
+
reason;
|
|
2645
|
+
constructor(pattern, reason) {
|
|
2646
|
+
super(`Invalid glob pattern ${JSON.stringify(pattern)}: ${reason}`);
|
|
2647
|
+
this.name = "InvalidGlobPatternError";
|
|
2648
|
+
this.pattern = pattern;
|
|
2649
|
+
this.reason = reason;
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
const assertGlobPattern = (condition, pattern, reason) => {
|
|
2653
|
+
if (!condition) throw new InvalidGlobPatternError(pattern, reason);
|
|
2654
|
+
};
|
|
2655
|
+
const countGlobWildcards = (pattern) => (pattern.match(/[*?]/g) ?? []).length;
|
|
2656
|
+
const normalizeGlobPattern = (pattern) => pattern.replace(/\\/g, "/").replace(/^\//, "");
|
|
2657
|
+
const PICOMATCH_OPTIONS = {
|
|
2658
|
+
dot: true,
|
|
2659
|
+
strictSlashes: false,
|
|
2660
|
+
windows: false
|
|
2661
|
+
};
|
|
2662
|
+
const compileGlobPattern = (rawPattern) => {
|
|
2663
|
+
assertGlobPattern(typeof rawPattern === "string" && rawPattern.length > 0, String(rawPattern), "pattern must be a non-empty string.");
|
|
2664
|
+
assertGlobPattern(rawPattern.length <= MAX_GLOB_PATTERN_LENGTH_CHARS, rawPattern, `pattern length ${rawPattern.length} exceeds the maximum of ${MAX_GLOB_PATTERN_LENGTH_CHARS} characters.`);
|
|
2665
|
+
const wildcardCount = countGlobWildcards(rawPattern);
|
|
2666
|
+
assertGlobPattern(wildcardCount <= 24, rawPattern, `pattern uses ${wildcardCount} wildcards (\`*\` / \`?\`), exceeding the maximum of 24. This guards against catastrophic backtracking from pathological patterns; split the pattern into multiple smaller entries.`);
|
|
2667
|
+
try {
|
|
2668
|
+
return import_picomatch.default.makeRe(normalizeGlobPattern(rawPattern), PICOMATCH_OPTIONS);
|
|
2669
|
+
} catch (caughtError) {
|
|
2670
|
+
throw new InvalidGlobPatternError(rawPattern, caughtError instanceof Error ? caughtError.message : String(caughtError));
|
|
2671
|
+
}
|
|
2672
|
+
};
|
|
2673
|
+
const compileGlobPatternsLenient = (patterns, onInvalid) => {
|
|
2674
|
+
const compiled = [];
|
|
2675
|
+
for (const pattern of patterns) try {
|
|
2676
|
+
compiled.push(compileGlobPattern(pattern));
|
|
2677
|
+
} catch (caughtError) {
|
|
2678
|
+
if (!(caughtError instanceof InvalidGlobPatternError)) throw caughtError;
|
|
2679
|
+
onInvalid(caughtError);
|
|
917
2680
|
}
|
|
918
|
-
|
|
919
|
-
return new RegExp(regexSource);
|
|
2681
|
+
return compiled;
|
|
920
2682
|
};
|
|
921
2683
|
const toRelativePath = (filePath, rootDirectory) => {
|
|
922
2684
|
const normalizedFilePath = filePath.replace(/\\/g, "/");
|
|
@@ -924,22 +2686,22 @@ const toRelativePath = (filePath, rootDirectory) => {
|
|
|
924
2686
|
if (normalizedFilePath.startsWith(normalizedRoot)) return normalizedFilePath.slice(normalizedRoot.length);
|
|
925
2687
|
return normalizedFilePath.replace(/^\.\//, "");
|
|
926
2688
|
};
|
|
927
|
-
const
|
|
2689
|
+
const warnConfigIssue = (message) => {
|
|
928
2690
|
process.stderr.write(`[react-doctor] ${message}\n`);
|
|
929
2691
|
};
|
|
930
2692
|
const isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
931
2693
|
const collectStringList = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
932
2694
|
const validateOverrideEntry = (entry, index) => {
|
|
933
2695
|
if (!isPlainObject(entry)) {
|
|
934
|
-
|
|
2696
|
+
warnConfigIssue(`ignore.overrides[${index}] must be an object with { files, rules }; ignoring this entry.`);
|
|
935
2697
|
return null;
|
|
936
2698
|
}
|
|
937
2699
|
if (!isStringArray(entry.files)) {
|
|
938
|
-
|
|
2700
|
+
warnConfigIssue(`ignore.overrides[${index}].files must be an array of strings; ignoring this entry.`);
|
|
939
2701
|
return null;
|
|
940
2702
|
}
|
|
941
2703
|
if (entry.rules !== void 0 && !isStringArray(entry.rules)) {
|
|
942
|
-
|
|
2704
|
+
warnConfigIssue(`ignore.overrides[${index}].rules must be an array of "plugin/rule" strings or omitted; treating as missing (override would suppress every rule for the matched files).`);
|
|
943
2705
|
return { files: entry.files };
|
|
944
2706
|
}
|
|
945
2707
|
return entry.rules === void 0 ? { files: entry.files } : {
|
|
@@ -951,13 +2713,13 @@ const compileIgnoreOverrides = (userConfig) => {
|
|
|
951
2713
|
const overrides = userConfig?.ignore?.overrides;
|
|
952
2714
|
if (overrides === void 0) return [];
|
|
953
2715
|
if (!Array.isArray(overrides)) {
|
|
954
|
-
|
|
2716
|
+
warnConfigIssue(`ignore.overrides must be an array of { files, rules } entries; ignoring.`);
|
|
955
2717
|
return [];
|
|
956
2718
|
}
|
|
957
2719
|
return overrides.flatMap((entry, index) => {
|
|
958
2720
|
const validated = validateOverrideEntry(entry, index);
|
|
959
2721
|
if (!validated) return [];
|
|
960
|
-
const filePatterns = collectStringList(validated.files)
|
|
2722
|
+
const filePatterns = compileGlobPatternsLenient(collectStringList(validated.files), (error) => warnConfigIssue(`ignore.overrides[${index}]: ${error.message}`));
|
|
961
2723
|
if (filePatterns.length === 0) return [];
|
|
962
2724
|
return [{
|
|
963
2725
|
filePatterns,
|
|
@@ -971,12 +2733,94 @@ const isDiagnosticIgnoredByOverrides = (diagnostic, rootDirectory, overrides) =>
|
|
|
971
2733
|
const ruleIdentifier = `${diagnostic.plugin}/${diagnostic.rule}`;
|
|
972
2734
|
return overrides.some((override) => override.filePatterns.some((pattern) => pattern.test(relativeFilePath)) && (override.ruleIds.size === 0 || override.ruleIds.has(ruleIdentifier)));
|
|
973
2735
|
};
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
2736
|
+
/**
|
|
2737
|
+
* Assembles the internal `RuleSeverityControls` shape from a user
|
|
2738
|
+
* config's top-level `rules` and `categories` fields — the
|
|
2739
|
+
* ESLint / oxlint-shaped severity surface.
|
|
2740
|
+
*
|
|
2741
|
+
* Returns `undefined` when neither field is present so the common
|
|
2742
|
+
* path (no severity config at all) stays allocation-free for
|
|
2743
|
+
* downstream consumers.
|
|
2744
|
+
*/
|
|
2745
|
+
const buildRuleSeverityControls = (config) => {
|
|
2746
|
+
if (!config) return void 0;
|
|
2747
|
+
if (config.rules === void 0 && config.categories === void 0) return void 0;
|
|
2748
|
+
return {
|
|
2749
|
+
...config.rules !== void 0 ? { rules: config.rules } : {},
|
|
2750
|
+
...config.categories !== void 0 ? { categories: config.categories } : {}
|
|
2751
|
+
};
|
|
2752
|
+
};
|
|
2753
|
+
/**
|
|
2754
|
+
* Projects a diagnostic onto the three axes rule-targeted controls
|
|
2755
|
+
* reason about:
|
|
2756
|
+
*
|
|
2757
|
+
* - `ruleKey` — the fully-qualified `"<plugin>/<rule>"` form users
|
|
2758
|
+
* put in config files (consumed by top-level `rules` severity and
|
|
2759
|
+
* `surfaces.*.{include,exclude}Rules`).
|
|
2760
|
+
* - `category` — the diagnostic's category label (consumed by
|
|
2761
|
+
* top-level `categories` severity and
|
|
2762
|
+
* `surfaces.*.{include,exclude}Categories`).
|
|
2763
|
+
* - `tags` — behavioral tags from the rule registry (consumed by
|
|
2764
|
+
* `ignore.tags` and `surfaces.*.{include,exclude}Tags`). Empty
|
|
2765
|
+
* for non-`react-doctor` plugins.
|
|
2766
|
+
*/
|
|
2767
|
+
const getDiagnosticRuleIdentity = (diagnostic) => ({
|
|
2768
|
+
ruleKey: `${diagnostic.plugin}/${diagnostic.rule}`,
|
|
2769
|
+
category: diagnostic.category,
|
|
2770
|
+
tags: diagnostic.plugin === "react-doctor" ? reactDoctorPlugin.rules[diagnostic.rule]?.tags ?? [] : []
|
|
2771
|
+
});
|
|
2772
|
+
/**
|
|
2773
|
+
* Resolves the user-configured severity override for a rule.
|
|
2774
|
+
* Per-rule overrides win over per-category overrides. Returns
|
|
2775
|
+
* `undefined` when neither channel matches — callers should fall
|
|
2776
|
+
* back to the rule's built-in severity.
|
|
2777
|
+
*/
|
|
2778
|
+
const resolveRuleSeverityOverride = (input, controls) => {
|
|
2779
|
+
if (!controls) return void 0;
|
|
2780
|
+
return controls.rules?.[input.ruleKey] ?? (input.category !== void 0 ? controls.categories?.[input.category] : void 0);
|
|
2781
|
+
};
|
|
2782
|
+
const SEVERITY_FOR_OVERRIDE = {
|
|
2783
|
+
error: "error",
|
|
2784
|
+
warn: "warning"
|
|
2785
|
+
};
|
|
2786
|
+
const restampSeverity = (diagnostic, override) => {
|
|
2787
|
+
const targetSeverity = SEVERITY_FOR_OVERRIDE[override];
|
|
2788
|
+
if (diagnostic.severity === targetSeverity) return diagnostic;
|
|
2789
|
+
return {
|
|
2790
|
+
...diagnostic,
|
|
2791
|
+
severity: targetSeverity
|
|
2792
|
+
};
|
|
2793
|
+
};
|
|
2794
|
+
/**
|
|
2795
|
+
* Applies the user's top-level `rules` / `categories` / `tags`
|
|
2796
|
+
* severity config to a post-lint diagnostic list:
|
|
2797
|
+
*
|
|
2798
|
+
* - `"off"` drops the diagnostic entirely. For react-doctor rules
|
|
2799
|
+
* this also happens at lint-registration time; this post-filter
|
|
2800
|
+
* covers external plugins (`react/*`, `jsx-a11y/*`, custom adopted
|
|
2801
|
+
* configs) whose severities the lint config can't reach.
|
|
2802
|
+
* - `"warn"` / `"error"` re-stamps `diagnostic.severity` so downstream
|
|
2803
|
+
* consumers — `--fail-on`, the score input, the CLI summary — see
|
|
2804
|
+
* the user-chosen severity rather than the rule's built-in one.
|
|
2805
|
+
*
|
|
2806
|
+
* Returns the input array by identity when no controls are configured
|
|
2807
|
+
* so the common path stays allocation-free.
|
|
2808
|
+
*/
|
|
2809
|
+
const applySeverityControls = (diagnostics, config) => {
|
|
2810
|
+
const controls = buildRuleSeverityControls(config);
|
|
2811
|
+
if (!controls) return diagnostics;
|
|
2812
|
+
const adjusted = [];
|
|
2813
|
+
for (const diagnostic of diagnostics) {
|
|
2814
|
+
const { ruleKey, category } = getDiagnosticRuleIdentity(diagnostic);
|
|
2815
|
+
const override = resolveRuleSeverityOverride({
|
|
2816
|
+
ruleKey,
|
|
2817
|
+
category
|
|
2818
|
+
}, controls);
|
|
2819
|
+
if (override === "off") continue;
|
|
2820
|
+
adjusted.push(override === void 0 ? diagnostic : restampSeverity(diagnostic, override));
|
|
2821
|
+
}
|
|
2822
|
+
return adjusted;
|
|
2823
|
+
};
|
|
980
2824
|
const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
|
|
981
2825
|
const batchIncludePaths = (baseArgs, includePaths) => {
|
|
982
2826
|
const baseArgsLength = estimateArgsLength(baseArgs);
|
|
@@ -1648,7 +3492,7 @@ const evaluateSuppression = (lines, diagnosticLineIndex, ruleId) => {
|
|
|
1648
3492
|
const compileIgnoredFilePatterns = (userConfig) => {
|
|
1649
3493
|
const files = userConfig?.ignore?.files;
|
|
1650
3494
|
if (!Array.isArray(files)) return [];
|
|
1651
|
-
return files.filter((entry) => typeof entry === "string")
|
|
3495
|
+
return compileGlobPatternsLenient(files.filter((entry) => typeof entry === "string"), (error) => warnConfigIssue(`ignore.files: ${error.message}`));
|
|
1652
3496
|
};
|
|
1653
3497
|
const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
|
|
1654
3498
|
if (patterns.length === 0) return false;
|
|
@@ -1812,8 +3656,8 @@ const shouldAutoSuppress = (diagnostic) => {
|
|
|
1812
3656
|
return false;
|
|
1813
3657
|
};
|
|
1814
3658
|
const mergeAndFilterDiagnostics = (mergedDiagnostics, directory, userConfig, readFileLinesSync, options = {}) => {
|
|
1815
|
-
const
|
|
1816
|
-
const filtered = userConfig ? filterIgnoredDiagnostics(
|
|
3659
|
+
const severityAdjusted = applySeverityControls(mergedDiagnostics.filter((diagnostic) => !shouldAutoSuppress(diagnostic)), userConfig);
|
|
3660
|
+
const filtered = userConfig ? filterIgnoredDiagnostics(severityAdjusted, userConfig, directory, readFileLinesSync) : severityAdjusted;
|
|
1817
3661
|
if (options.respectInlineDisables === false) return filtered;
|
|
1818
3662
|
return filterInlineSuppressions(filtered, directory, readFileLinesSync);
|
|
1819
3663
|
};
|
|
@@ -1843,6 +3687,13 @@ const detectUserLintConfigPaths = (rootDirectory) => {
|
|
|
1843
3687
|
}
|
|
1844
3688
|
return [];
|
|
1845
3689
|
};
|
|
3690
|
+
const DIAGNOSTIC_SURFACES = [
|
|
3691
|
+
"cli",
|
|
3692
|
+
"prComment",
|
|
3693
|
+
"score",
|
|
3694
|
+
"ciFailure"
|
|
3695
|
+
];
|
|
3696
|
+
const isDiagnosticSurface = (value) => typeof value === "string" && DIAGNOSTIC_SURFACES.includes(value);
|
|
1846
3697
|
const runGit = (cwd, args) => {
|
|
1847
3698
|
const result = spawnSync("git", args, {
|
|
1848
3699
|
cwd,
|
|
@@ -1960,6 +3811,11 @@ const getDiffInfo = (directory, explicitBaseBranch) => {
|
|
|
1960
3811
|
};
|
|
1961
3812
|
const filterSourceFiles = (filePaths) => filePaths.filter((filePath) => SOURCE_FILE_PATTERN.test(filePath));
|
|
1962
3813
|
const computeJsxIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter((filePath) => JSX_FILE_PATTERN.test(filePath)) : void 0;
|
|
3814
|
+
const VALID_RULE_SEVERITIES = [
|
|
3815
|
+
"error",
|
|
3816
|
+
"warn",
|
|
3817
|
+
"off"
|
|
3818
|
+
];
|
|
1963
3819
|
const BOOLEAN_FIELD_NAMES = [
|
|
1964
3820
|
"lint",
|
|
1965
3821
|
"verbose",
|
|
@@ -1970,18 +3826,27 @@ const BOOLEAN_FIELD_NAMES = [
|
|
|
1970
3826
|
"offline"
|
|
1971
3827
|
];
|
|
1972
3828
|
const STRING_FIELD_NAMES = ["rootDir"];
|
|
3829
|
+
const SURFACE_CONTROL_FIELD_NAMES = [
|
|
3830
|
+
"includeTags",
|
|
3831
|
+
"excludeTags",
|
|
3832
|
+
"includeCategories",
|
|
3833
|
+
"excludeCategories",
|
|
3834
|
+
"includeRules",
|
|
3835
|
+
"excludeRules"
|
|
3836
|
+
];
|
|
3837
|
+
const SEVERITY_FIELD_NAMES = ["rules", "categories"];
|
|
1973
3838
|
const warnConfigField = (message) => {
|
|
1974
3839
|
process.stderr.write(`[react-doctor] ${message}\n`);
|
|
1975
3840
|
};
|
|
3841
|
+
const isPlainObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3842
|
+
const formatType = (value) => typeof value === "string" ? `"${value}"` : typeof value;
|
|
3843
|
+
const isRuleSeverity = (value) => typeof value === "string" && VALID_RULE_SEVERITIES.includes(value);
|
|
1976
3844
|
const coerceMaybeBooleanString = (fieldName, value) => {
|
|
1977
|
-
if (typeof value === "boolean"
|
|
1978
|
-
if (value === "true") {
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
if (value === "false") {
|
|
1983
|
-
warnConfigField(`config field "${fieldName}" is the string "false"; treating as boolean false.`);
|
|
1984
|
-
return false;
|
|
3845
|
+
if (typeof value === "boolean") return value;
|
|
3846
|
+
if (value === "true" || value === "false") {
|
|
3847
|
+
const coerced = value === "true";
|
|
3848
|
+
warnConfigField(`config field "${fieldName}" is the string "${value}"; treating as boolean ${coerced}.`);
|
|
3849
|
+
return coerced;
|
|
1985
3850
|
}
|
|
1986
3851
|
warnConfigField(`config field "${fieldName}" must be a boolean (got ${typeof value}); ignoring this field.`);
|
|
1987
3852
|
};
|
|
@@ -1989,22 +3854,78 @@ const validateString = (fieldName, value) => {
|
|
|
1989
3854
|
if (typeof value === "string") return value;
|
|
1990
3855
|
warnConfigField(`config field "${fieldName}" must be a string (got ${typeof value}); ignoring this field.`);
|
|
1991
3856
|
};
|
|
3857
|
+
const validateStringArrayField = (fieldName, value) => {
|
|
3858
|
+
if (!Array.isArray(value)) {
|
|
3859
|
+
warnConfigField(`config field "${fieldName}" must be an array of strings (got ${typeof value}); ignoring this field.`);
|
|
3860
|
+
return;
|
|
3861
|
+
}
|
|
3862
|
+
return value.filter((entry) => {
|
|
3863
|
+
if (typeof entry === "string") return true;
|
|
3864
|
+
warnConfigField(`config field "${fieldName}" contains a non-string entry (${typeof entry}); ignoring the entry.`);
|
|
3865
|
+
return false;
|
|
3866
|
+
});
|
|
3867
|
+
};
|
|
3868
|
+
const validateSurfaceControls = (surface, rawControls) => {
|
|
3869
|
+
if (!isPlainObject$1(rawControls)) {
|
|
3870
|
+
warnConfigField(`config field "surfaces.${surface}" must be an object (got ${typeof rawControls}); ignoring this surface.`);
|
|
3871
|
+
return;
|
|
3872
|
+
}
|
|
3873
|
+
const validated = {};
|
|
3874
|
+
for (const fieldName of SURFACE_CONTROL_FIELD_NAMES) {
|
|
3875
|
+
if (rawControls[fieldName] === void 0) continue;
|
|
3876
|
+
const result = validateStringArrayField(`surfaces.${surface}.${fieldName}`, rawControls[fieldName]);
|
|
3877
|
+
if (result !== void 0) validated[fieldName] = result;
|
|
3878
|
+
}
|
|
3879
|
+
return validated;
|
|
3880
|
+
};
|
|
3881
|
+
const validateSurfacesField = (rawSurfaces) => {
|
|
3882
|
+
if (!isPlainObject$1(rawSurfaces)) {
|
|
3883
|
+
warnConfigField(`config field "surfaces" must be an object (got ${typeof rawSurfaces}); ignoring this field.`);
|
|
3884
|
+
return;
|
|
3885
|
+
}
|
|
3886
|
+
const validated = {};
|
|
3887
|
+
for (const [key, value] of Object.entries(rawSurfaces)) {
|
|
3888
|
+
if (!isDiagnosticSurface(key)) {
|
|
3889
|
+
warnConfigField(`config field "surfaces.${key}" is not a known surface (expected one of: ${DIAGNOSTIC_SURFACES.join(", ")}); ignoring.`);
|
|
3890
|
+
continue;
|
|
3891
|
+
}
|
|
3892
|
+
const controls = validateSurfaceControls(key, value);
|
|
3893
|
+
if (controls !== void 0) validated[key] = controls;
|
|
3894
|
+
}
|
|
3895
|
+
return validated;
|
|
3896
|
+
};
|
|
3897
|
+
const validateSeverityMap = (fieldName, rawMap) => {
|
|
3898
|
+
if (!isPlainObject$1(rawMap)) {
|
|
3899
|
+
warnConfigField(`config field "${fieldName}" must be an object (got ${typeof rawMap}); ignoring this field.`);
|
|
3900
|
+
return;
|
|
3901
|
+
}
|
|
3902
|
+
const validated = {};
|
|
3903
|
+
for (const [key, value] of Object.entries(rawMap)) {
|
|
3904
|
+
if (key.length === 0) {
|
|
3905
|
+
warnConfigField(`config field "${fieldName}" has an empty key; ignoring the entry.`);
|
|
3906
|
+
continue;
|
|
3907
|
+
}
|
|
3908
|
+
if (!isRuleSeverity(value)) {
|
|
3909
|
+
warnConfigField(`config field "${fieldName}.${key}" must be one of: ${VALID_RULE_SEVERITIES.join(", ")} (got ${formatType(value)}); ignoring the entry.`);
|
|
3910
|
+
continue;
|
|
3911
|
+
}
|
|
3912
|
+
validated[key] = value;
|
|
3913
|
+
}
|
|
3914
|
+
return validated;
|
|
3915
|
+
};
|
|
3916
|
+
const applyFieldValidator = (config, validated, fieldName, validator) => {
|
|
3917
|
+
const raw = config[fieldName];
|
|
3918
|
+
if (raw === void 0) return;
|
|
3919
|
+
const result = validator(raw);
|
|
3920
|
+
if (result === void 0) delete validated[fieldName];
|
|
3921
|
+
else validated[fieldName] = result;
|
|
3922
|
+
};
|
|
1992
3923
|
const validateConfigTypes = (config) => {
|
|
1993
3924
|
const validated = { ...config };
|
|
1994
|
-
for (const fieldName of BOOLEAN_FIELD_NAMES)
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
if (coerced === void 0) delete validated[fieldName];
|
|
1999
|
-
else validated[fieldName] = coerced;
|
|
2000
|
-
}
|
|
2001
|
-
for (const fieldName of STRING_FIELD_NAMES) {
|
|
2002
|
-
const original = config[fieldName];
|
|
2003
|
-
if (original === void 0) continue;
|
|
2004
|
-
const validatedString = validateString(fieldName, original);
|
|
2005
|
-
if (validatedString === void 0) delete validated[fieldName];
|
|
2006
|
-
else validated[fieldName] = validatedString;
|
|
2007
|
-
}
|
|
3925
|
+
for (const fieldName of BOOLEAN_FIELD_NAMES) applyFieldValidator(config, validated, fieldName, (value) => coerceMaybeBooleanString(fieldName, value));
|
|
3926
|
+
for (const fieldName of STRING_FIELD_NAMES) applyFieldValidator(config, validated, fieldName, (value) => validateString(fieldName, value));
|
|
3927
|
+
applyFieldValidator(config, validated, "surfaces", validateSurfacesField);
|
|
3928
|
+
for (const fieldName of SEVERITY_FIELD_NAMES) applyFieldValidator(config, validated, fieldName, (value) => validateSeverityMap(fieldName, value));
|
|
2008
3929
|
return validated;
|
|
2009
3930
|
};
|
|
2010
3931
|
const CONFIG_FILENAME = "react-doctor.config.json";
|
|
@@ -2242,7 +4163,7 @@ const dedupeDiagnostics = (diagnostics) => {
|
|
|
2242
4163
|
const buildCapabilities = (project) => {
|
|
2243
4164
|
const capabilities = /* @__PURE__ */ new Set();
|
|
2244
4165
|
capabilities.add(project.framework);
|
|
2245
|
-
if (project.framework === "expo" || project.framework === "react-native") capabilities.add("react-native");
|
|
4166
|
+
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
2246
4167
|
const reactMajor = project.reactMajorVersion;
|
|
2247
4168
|
if (reactMajor !== null) for (let major = 17; major <= reactMajor; major++) capabilities.add(`react:${major}`);
|
|
2248
4169
|
if (project.tailwindVersion !== null) {
|
|
@@ -2324,65 +4245,11 @@ const filterRulesToAvailable = (rules, pluginNamespace, availableRuleNames) => {
|
|
|
2324
4245
|
}
|
|
2325
4246
|
return filtered;
|
|
2326
4247
|
};
|
|
2327
|
-
const
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
"react-hooks-js/hooks": "error",
|
|
2333
|
-
"react-hooks-js/set-state-in-effect": "error",
|
|
2334
|
-
"react-hooks-js/globals": "error",
|
|
2335
|
-
"react-hooks-js/error-boundaries": "error",
|
|
2336
|
-
"react-hooks-js/preserve-manual-memoization": "error",
|
|
2337
|
-
"react-hooks-js/unsupported-syntax": "error",
|
|
2338
|
-
"react-hooks-js/component-hook-factories": "error",
|
|
2339
|
-
"react-hooks-js/static-components": "error",
|
|
2340
|
-
"react-hooks-js/use-memo": "error",
|
|
2341
|
-
"react-hooks-js/void-use-memo": "error",
|
|
2342
|
-
"react-hooks-js/incompatible-library": "error",
|
|
2343
|
-
"react-hooks-js/todo": "error"
|
|
2344
|
-
};
|
|
2345
|
-
const YOU_MIGHT_NOT_NEED_EFFECT_RULES = {
|
|
2346
|
-
"effect/no-derived-state": "warn",
|
|
2347
|
-
"effect/no-chain-state-updates": "warn",
|
|
2348
|
-
"effect/no-event-handler": "warn",
|
|
2349
|
-
"effect/no-adjust-state-on-prop-change": "warn",
|
|
2350
|
-
"effect/no-reset-all-state-on-prop-change": "warn",
|
|
2351
|
-
"effect/no-pass-live-state-to-parent": "warn",
|
|
2352
|
-
"effect/no-pass-data-to-parent": "warn",
|
|
2353
|
-
"effect/no-initialize-state": "warn"
|
|
2354
|
-
};
|
|
2355
|
-
const BUILTIN_REACT_RULES = {
|
|
2356
|
-
"react/rules-of-hooks": "error",
|
|
2357
|
-
"react/no-direct-mutation-state": "error",
|
|
2358
|
-
"react/jsx-no-duplicate-props": "error",
|
|
2359
|
-
"react/jsx-key": "error",
|
|
2360
|
-
"react/no-children-prop": "warn",
|
|
2361
|
-
"react/no-danger": "warn",
|
|
2362
|
-
"react/jsx-no-script-url": "error",
|
|
2363
|
-
"react/no-render-return-value": "warn",
|
|
2364
|
-
"react/no-string-refs": "warn",
|
|
2365
|
-
"react/no-is-mounted": "warn",
|
|
2366
|
-
"react/require-render-return": "error",
|
|
2367
|
-
"react/no-unknown-property": "warn"
|
|
2368
|
-
};
|
|
2369
|
-
const BUILTIN_A11Y_RULES = {
|
|
2370
|
-
"jsx-a11y/alt-text": "error",
|
|
2371
|
-
"jsx-a11y/anchor-is-valid": "warn",
|
|
2372
|
-
"jsx-a11y/click-events-have-key-events": "warn",
|
|
2373
|
-
"jsx-a11y/no-static-element-interactions": "warn",
|
|
2374
|
-
"jsx-a11y/role-has-required-aria-props": "error",
|
|
2375
|
-
"jsx-a11y/no-autofocus": "warn",
|
|
2376
|
-
"jsx-a11y/heading-has-content": "warn",
|
|
2377
|
-
"jsx-a11y/html-has-lang": "warn",
|
|
2378
|
-
"jsx-a11y/no-redundant-roles": "warn",
|
|
2379
|
-
"jsx-a11y/scope": "warn",
|
|
2380
|
-
"jsx-a11y/tabindex-no-positive": "warn",
|
|
2381
|
-
"jsx-a11y/label-has-associated-control": "warn",
|
|
2382
|
-
"jsx-a11y/no-distracting-elements": "error",
|
|
2383
|
-
"jsx-a11y/iframe-has-title": "warn"
|
|
2384
|
-
};
|
|
2385
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set() }) => {
|
|
4248
|
+
const resolveSettingsRootDirectory = (rootDirectory) => {
|
|
4249
|
+
if (!fs.existsSync(rootDirectory)) return rootDirectory;
|
|
4250
|
+
return fs.realpathSync(rootDirectory);
|
|
4251
|
+
};
|
|
4252
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls }) => {
|
|
2386
4253
|
const reactHooksJsPlugin = resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
|
|
2387
4254
|
const reactCompilerRules = reactHooksJsPlugin ? filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames) : {};
|
|
2388
4255
|
const youMightNotNeedEffectPlugin = resolveYouMightNotNeedEffectPlugin(customRulesOnly);
|
|
@@ -2396,7 +4263,12 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
2396
4263
|
const fullKey = `react-doctor/${ruleId}`;
|
|
2397
4264
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
2398
4265
|
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags)) continue;
|
|
2399
|
-
|
|
4266
|
+
const severity = resolveRuleSeverityOverride({
|
|
4267
|
+
ruleKey: fullKey,
|
|
4268
|
+
category: rule.category
|
|
4269
|
+
}, severityControls) ?? rule.severity;
|
|
4270
|
+
if (severity === "off") continue;
|
|
4271
|
+
enabledReactDoctorRules[fullKey] = severity;
|
|
2400
4272
|
}
|
|
2401
4273
|
return {
|
|
2402
4274
|
...extendsPaths.length > 0 ? { extends: extendsPaths } : {},
|
|
@@ -2411,6 +4283,11 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
2411
4283
|
},
|
|
2412
4284
|
plugins: customRulesOnly ? [] : ["react", "jsx-a11y"],
|
|
2413
4285
|
jsPlugins: [...jsPlugins, pluginPath],
|
|
4286
|
+
settings: { "react-doctor": {
|
|
4287
|
+
framework: project.framework,
|
|
4288
|
+
rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
|
|
4289
|
+
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
4290
|
+
} },
|
|
2414
4291
|
rules: {
|
|
2415
4292
|
...customRulesOnly ? {} : BUILTIN_REACT_RULES,
|
|
2416
4293
|
...customRulesOnly ? {} : BUILTIN_A11Y_RULES,
|
|
@@ -2713,7 +4590,25 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
2713
4590
|
const bindingResolution = resolveUseCallBinding(sourceText, absolutePath, primaryLabel.span.offset);
|
|
2714
4591
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
2715
4592
|
};
|
|
2716
|
-
const
|
|
4593
|
+
const getPublicEnvPrefix = (framework) => {
|
|
4594
|
+
switch (framework) {
|
|
4595
|
+
case "nextjs": return "NEXT_PUBLIC_*";
|
|
4596
|
+
case "vite":
|
|
4597
|
+
case "tanstack-start": return "VITE_*";
|
|
4598
|
+
case "cra": return "REACT_APP_*";
|
|
4599
|
+
case "gatsby": return "GATSBY_*";
|
|
4600
|
+
default: return null;
|
|
4601
|
+
}
|
|
4602
|
+
};
|
|
4603
|
+
const buildNoSecretsRecommendation = (project, fallbackRecommendation) => {
|
|
4604
|
+
const publicEnvPrefix = getPublicEnvPrefix(project.framework);
|
|
4605
|
+
if (!publicEnvPrefix) return fallbackRecommendation;
|
|
4606
|
+
return `Move secrets to server-only code. In ${formatFrameworkName(project.framework)}, only \`${publicEnvPrefix}\` env vars are exposed to the browser, and they must not contain secrets`;
|
|
4607
|
+
};
|
|
4608
|
+
const getRuleRecommendation = (ruleName, project) => {
|
|
4609
|
+
if (ruleName === "no-secrets-in-client-code") return buildNoSecretsRecommendation(project, reactDoctorPlugin.rules["no-secrets-in-client-code"]?.recommendation ?? "Move secrets to server-only code");
|
|
4610
|
+
return reactDoctorPlugin.rules[ruleName]?.recommendation;
|
|
4611
|
+
};
|
|
2717
4612
|
const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
|
|
2718
4613
|
const esmRequire = createRequire(import.meta.url);
|
|
2719
4614
|
const PLUGIN_CATEGORY_MAP = {
|
|
@@ -2738,14 +4633,14 @@ const PLUGIN_CATEGORY_MAP = {
|
|
|
2738
4633
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
2739
4634
|
const REACT_COMPILER_MESSAGE = "React Compiler can't optimize this code";
|
|
2740
4635
|
const lookupOwnString = (record, key) => Object.hasOwn(record, key) ? record[key] : void 0;
|
|
2741
|
-
const cleanDiagnosticMessage = (message, help, plugin, rule) => {
|
|
4636
|
+
const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
2742
4637
|
if (plugin === "react-hooks-js") return {
|
|
2743
4638
|
message: REACT_COMPILER_MESSAGE,
|
|
2744
4639
|
help: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || help
|
|
2745
4640
|
};
|
|
2746
4641
|
return {
|
|
2747
4642
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
2748
|
-
help: help || getRuleRecommendation(rule) || ""
|
|
4643
|
+
help: help || getRuleRecommendation(rule, project) || ""
|
|
2749
4644
|
};
|
|
2750
4645
|
};
|
|
2751
4646
|
const parseRuleCode = (code) => {
|
|
@@ -2848,7 +4743,7 @@ const isOxlintOutput = (value) => {
|
|
|
2848
4743
|
const candidate = value;
|
|
2849
4744
|
return Array.isArray(candidate.diagnostics);
|
|
2850
4745
|
};
|
|
2851
|
-
const parseOxlintOutput = (stdout, rootDirectory) => {
|
|
4746
|
+
const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
2852
4747
|
if (!stdout) return [];
|
|
2853
4748
|
const jsonStart = stdout.indexOf("{");
|
|
2854
4749
|
const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
|
|
@@ -2862,7 +4757,7 @@ const parseOxlintOutput = (stdout, rootDirectory) => {
|
|
|
2862
4757
|
return parsed.diagnostics.filter((diagnostic) => diagnostic.code && SOURCE_FILE_PATTERN.test(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory)).map((diagnostic) => {
|
|
2863
4758
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
2864
4759
|
const primaryLabel = diagnostic.labels[0];
|
|
2865
|
-
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule);
|
|
4760
|
+
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
2866
4761
|
return {
|
|
2867
4762
|
filePath: diagnostic.filename,
|
|
2868
4763
|
plugin,
|
|
@@ -2892,7 +4787,7 @@ const validateRuleRegistration = () => {
|
|
|
2892
4787
|
for (const fullKey of ALL_REACT_DOCTOR_RULE_KEYS) {
|
|
2893
4788
|
const ruleName = fullKey.replace(/^react-doctor\//, "");
|
|
2894
4789
|
if (!getRuleCategory(ruleName)) missingCategory.push(fullKey);
|
|
2895
|
-
if (!
|
|
4790
|
+
if (!reactDoctorPlugin.rules[ruleName]?.recommendation) missingHelp.push(fullKey);
|
|
2896
4791
|
if (FRAMEWORK_SPECIFIC_RULE_KEYS.has(fullKey) && !reactDoctorPlugin.rules[ruleName]?.requires) missingMetadata.push(fullKey);
|
|
2897
4792
|
}
|
|
2898
4793
|
if (missingCategory.length > 0 || missingHelp.length > 0 || missingMetadata.length > 0) {
|
|
@@ -2905,7 +4800,9 @@ const validateRuleRegistration = () => {
|
|
|
2905
4800
|
}
|
|
2906
4801
|
};
|
|
2907
4802
|
const runOxlint = async (options) => {
|
|
2908
|
-
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), onPartialFailure } = options;
|
|
4803
|
+
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), userConfig, onPartialFailure } = options;
|
|
4804
|
+
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
4805
|
+
const severityControls = buildRuleSeverityControls(userConfig);
|
|
2909
4806
|
validateRuleRegistration();
|
|
2910
4807
|
if (includePaths !== void 0 && includePaths.length === 0) return [];
|
|
2911
4808
|
const configDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
@@ -2917,7 +4814,9 @@ const runOxlint = async (options) => {
|
|
|
2917
4814
|
project,
|
|
2918
4815
|
customRulesOnly,
|
|
2919
4816
|
extendsPaths,
|
|
2920
|
-
ignoredTags
|
|
4817
|
+
ignoredTags,
|
|
4818
|
+
serverAuthFunctionNames,
|
|
4819
|
+
severityControls
|
|
2921
4820
|
});
|
|
2922
4821
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
2923
4822
|
try {
|
|
@@ -2954,7 +4853,7 @@ const runOxlint = async (options) => {
|
|
|
2954
4853
|
const spawnLintBatch = async (batch) => {
|
|
2955
4854
|
const batchArgs = [...baseArgs, ...batch];
|
|
2956
4855
|
try {
|
|
2957
|
-
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath), rootDirectory);
|
|
4856
|
+
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath), project, rootDirectory);
|
|
2958
4857
|
} catch (error) {
|
|
2959
4858
|
if (!isSplittableOxlintBatchError(error)) throw error;
|
|
2960
4859
|
if (batch.length <= 1) {
|
|
@@ -2984,7 +4883,9 @@ const runOxlint = async (options) => {
|
|
|
2984
4883
|
project,
|
|
2985
4884
|
customRulesOnly,
|
|
2986
4885
|
extendsPaths: [],
|
|
2987
|
-
ignoredTags
|
|
4886
|
+
ignoredTags,
|
|
4887
|
+
serverAuthFunctionNames,
|
|
4888
|
+
severityControls
|
|
2988
4889
|
}));
|
|
2989
4890
|
return await spawnLintBatches();
|
|
2990
4891
|
}
|
|
@@ -3048,7 +4949,8 @@ const diagnose = async (directory, options = {}) => {
|
|
|
3048
4949
|
customRulesOnly: userConfig?.customRulesOnly ?? false,
|
|
3049
4950
|
respectInlineDisables: effectiveRespectInlineDisables,
|
|
3050
4951
|
adoptExistingLintConfig: userConfig?.adoptExistingLintConfig ?? true,
|
|
3051
|
-
ignoredTags
|
|
4952
|
+
ignoredTags,
|
|
4953
|
+
userConfig
|
|
3052
4954
|
}).catch((error) => {
|
|
3053
4955
|
console.error("Lint failed:", error);
|
|
3054
4956
|
return EMPTY_DIAGNOSTICS;
|