react-doctor 0.9.23-dev.ed93f67 → 0.9.23-dev.eeff4d4
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/dist/{build-section-divider-DzuKtYKf.js → build-section-divider-M4JYIvJl.js} +5 -5
- package/dist/{ci-lxPnLNY2.js → ci-D7ljXIo9.js} +13 -13
- package/dist/cli.js +25 -25
- package/dist/{constants-EMNGZNtj.js → constants-BXN6vJ3T.js} +21 -8
- package/dist/{constants-T2clfs7L.js → constants-zyF-Em_y.js} +10 -3
- package/dist/{design-88ebRYs1.js → design-XQwuAooI.js} +4 -4
- package/dist/duplicate-jsx-worker.js +1 -1
- package/dist/{exit-gracefully-Dcr71UQz.js → exit-gracefully-BOyeEcyb.js} +6 -6
- package/dist/{handle-error-CU_FATUx.js → handle-error-UWlOKn6r.js} +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +913 -60
- package/dist/{inspect-DAWaaj5s.js → inspect-F_2FwEY4.js} +16 -16
- package/dist/{install-DSkwdY2A.js → install-KoxCju0L.js} +10 -10
- package/dist/{install-doctor-script-BMFIMJNG.js → install-doctor-script-BrfKpUzQ.js} +5 -5
- package/dist/{install-github-workflow-CnUL3IaA.js → install-github-workflow-hAvw3S8o.js} +6 -6
- package/dist/{install-react-doctor-CyRBo17H.js → install-react-doctor-Dt86VM3q.js} +9 -9
- package/dist/{is-cache-globally-disabled-CYjFzsDs.js → is-cache-globally-disabled-DaT77eEZ.js} +4 -4
- package/dist/{jsx-runtime-Di-r43F6.js → jsx-runtime-BrXRMax1.js} +6 -6
- package/dist/oxlint-worker.js +1 -1
- package/dist/{print-branded-header-C_IdES5E.js → print-branded-header-BtUUFoRA.js} +4 -4
- package/dist/project-analysis-worker.js +105 -7
- package/dist/{prompt-runtime-scan-url-BfVNLYXF.js → prompt-runtime-scan-url-Buwk-3bK.js} +5 -5
- package/dist/{read-object-file-Lc7IMSGY.js → read-object-file-_cBPiQ53.js} +4 -4
- package/dist/{record-metric-D5cWO5c1.js → record-metric-CqZ2oVM5.js} +902 -61
- package/dist/{report-error-DNUzAKVW.js → report-error-TQ0RuHaV.js} +6 -6
- package/dist/{report-workflow-result-4mYTuWWb.js → report-workflow-result-AVT357TZ.js} +6 -6
- package/dist/{resolve-scan-exit-code-BTg4e2sN.js → resolve-scan-exit-code-DHwcZs-_.js} +13 -13
- package/dist/{resolve-scope-C3GbCfvM.js → resolve-scope-C0xGQv5Z.js} +6 -6
- package/dist/{rules-JNqrM_qU.js → rules-DrN3BHA6.js} +7 -7
- package/dist/{run-scan-app-DOOG-mGi.js → run-scan-app-DgD9ZUcX.js} +11 -11
- package/dist/{runtime-scan-BzDfOeYC.js → runtime-scan-CUd9z8wt.js} +10 -10
- package/dist/{sanitize-runtime-url-CxOV1srN.js → sanitize-runtime-url-BbR8vJyj.js} +4 -4
- package/dist/{scan-ivk9wx91.js → scan-DStBkQc_.js} +10 -10
- package/dist/{should-skip-prompts-Bictn_Xl.js → should-skip-prompts-B3A5qWMu.js} +4 -4
- package/dist/{should-use-tui-DGIYCdEm.js → should-use-tui-lowPvEnC.js} +4 -4
- package/dist/{start-scan-preamble-Zd-z2ssT.js → start-scan-preamble-CTa9UHkf.js} +5 -5
- package/dist/start-scan-preamble.js +3 -3
- package/dist/{telemetry-runtime-ByXNkZlA.js → telemetry-runtime-DJWGuzba.js} +7 -7
- package/dist/{version-CCx32laG.js → version-gbK4YNDr.js} +5 -5
- package/dist/{why-Bu3hAeLo.js → why-Cdmh9drp.js} +4 -4
- package/dist/{with-run-span-5rSWU2YJ.js → with-run-span-CmXGFcgD.js} +6 -6
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="835688e2-3e41-50bb-9c66-fa5b45d875d1")}catch(e){}}();
|
|
3
3
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-ChKA3wi6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as fs$1$2 from "node:fs";
|
|
@@ -26,7 +26,7 @@ import { PassThrough } from "node:stream";
|
|
|
26
26
|
import { convertToTSX } from "@astrojs/compiler/sync";
|
|
27
27
|
import { STATUS_CODES } from "node:http";
|
|
28
28
|
import { gzipSync } from "node:zlib";
|
|
29
|
-
//#region ../core/dist/constants-
|
|
29
|
+
//#region ../core/dist/constants-BCogC6RN.js
|
|
30
30
|
const HTML_FILE_PATTERN = /\.html$/i;
|
|
31
31
|
const SOURCE_FILE_PATTERN = /\.(?:astro|tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
|
|
32
32
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
@@ -308,6 +308,12 @@ const ES_TARGET_YEAR_BY_NAME = {
|
|
|
308
308
|
*/
|
|
309
309
|
const TSCONFIG_FILENAMES = ["tsconfig.json", "tsconfig.base.json"];
|
|
310
310
|
const DISABLE_DIRECTIVE_BACKUP_DIRECTORY_SEGMENTS = [".react-doctor", "audit-backups"];
|
|
311
|
+
const LINT_IGNORE_STYLE_FILENAMES = [
|
|
312
|
+
".eslintignore",
|
|
313
|
+
".oxlintignore",
|
|
314
|
+
".prettierignore"
|
|
315
|
+
];
|
|
316
|
+
const LINT_LINGUIST_FILENAME = ".gitattributes";
|
|
311
317
|
/**
|
|
312
318
|
* Project-config files that `StagedFiles.materialize` copies into
|
|
313
319
|
* the temp directory alongside staged sources so oxlint resolves
|
|
@@ -319,6 +325,8 @@ const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
|
|
|
319
325
|
"tsconfig.json",
|
|
320
326
|
"tsconfig.base.json",
|
|
321
327
|
"package.json",
|
|
328
|
+
"pnpm-workspace.yaml",
|
|
329
|
+
"nx.json",
|
|
322
330
|
"doctor.config.ts",
|
|
323
331
|
"doctor.config.mts",
|
|
324
332
|
"doctor.config.cts",
|
|
@@ -328,8 +336,11 @@ const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
|
|
|
328
336
|
"doctor.config.json",
|
|
329
337
|
"doctor.config.jsonc",
|
|
330
338
|
"oxlint.json",
|
|
331
|
-
".oxlintrc.json"
|
|
339
|
+
".oxlintrc.json",
|
|
340
|
+
...LINT_IGNORE_STYLE_FILENAMES,
|
|
341
|
+
LINT_LINGUIST_FILENAME
|
|
332
342
|
];
|
|
343
|
+
[...LINT_IGNORE_STYLE_FILENAMES];
|
|
333
344
|
const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
|
|
334
345
|
const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
|
|
335
346
|
const NODE_COMPILE_CACHE_DIR_NAME = "node-compile-cache";
|
|
@@ -445,7 +456,7 @@ const isPlainObject = (value) => {
|
|
|
445
456
|
//#region ../core/dist/react-compiler-detection-worker-protocol-Dp5LlrE8.js
|
|
446
457
|
const isReactCompilerDetectionReply = (value) => typeof value === "object" && value !== null && "id" in value && typeof value.id === "number" && "hasReactCompiler" in value && (typeof value.hasReactCompiler === "boolean" || value.hasReactCompiler === null);
|
|
447
458
|
//#endregion
|
|
448
|
-
//#region ../core/dist/react-compiler-detection-client-
|
|
459
|
+
//#region ../core/dist/react-compiler-detection-client-Cdrl3lr2.js
|
|
449
460
|
const pendingOutputsByRequestKey = /* @__PURE__ */ new Map();
|
|
450
461
|
const toRequestKey = (request) => [
|
|
451
462
|
request.directory,
|
|
@@ -2720,7 +2731,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2720
2731
|
module.exports = picomatch;
|
|
2721
2732
|
}));
|
|
2722
2733
|
//#endregion
|
|
2723
|
-
//#region ../core/dist/collect-unplugin-auto-import-global-scopes-
|
|
2734
|
+
//#region ../core/dist/collect-unplugin-auto-import-global-scopes-nxDYvwKf.js
|
|
2724
2735
|
var import_picomatch = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2725
2736
|
const pico = require_picomatch$1();
|
|
2726
2737
|
const utils = require_utils();
|
|
@@ -2836,6 +2847,7 @@ const compileGlobPatternsLenient = (patterns, onInvalid) => {
|
|
|
2836
2847
|
}
|
|
2837
2848
|
return compiled;
|
|
2838
2849
|
};
|
|
2850
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2839
2851
|
const isOxcAstNode = (value) => Boolean(value) && typeof value === "object" && typeof value.type === "string";
|
|
2840
2852
|
const getStaticModuleSpecifier = (value) => {
|
|
2841
2853
|
if (!isOxcAstNode(value)) return void 0;
|
|
@@ -3170,7 +3182,7 @@ const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }
|
|
|
3170
3182
|
return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
|
|
3171
3183
|
};
|
|
3172
3184
|
//#endregion
|
|
3173
|
-
//#region ../core/dist/detect-duplicate-jsx-subtrees-
|
|
3185
|
+
//#region ../core/dist/detect-duplicate-jsx-subtrees-DKRoO0e9.js
|
|
3174
3186
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
3175
3187
|
setImmediate(resolve);
|
|
3176
3188
|
});
|
|
@@ -3734,7 +3746,7 @@ const detectDuplicateJsxSubtreesCooperative = async (sourceReader, options = {})
|
|
|
3734
3746
|
});
|
|
3735
3747
|
};
|
|
3736
3748
|
//#endregion
|
|
3737
|
-
//#region ../core/dist/detect-react-compiler-
|
|
3749
|
+
//#region ../core/dist/detect-react-compiler-B2QVSnc0.js
|
|
3738
3750
|
const NEXT_CONFIG_FILENAMES = [
|
|
3739
3751
|
"next.config.js",
|
|
3740
3752
|
"next.config.mjs",
|
|
@@ -12332,7 +12344,7 @@ const orDie$1 = (self) => catch_$2(self, die$1);
|
|
|
12332
12344
|
/** @internal */
|
|
12333
12345
|
const orElseSucceed$1 = /* @__PURE__ */ dual(2, (self, f) => catch_$2(self, (_) => sync$2(f)));
|
|
12334
12346
|
/** @internal */
|
|
12335
|
-
const ignore$
|
|
12347
|
+
const ignore$2 = /* @__PURE__ */ dual((args) => isEffect$1(args[0]), (self, options) => {
|
|
12336
12348
|
if (!options?.log) return matchEffect$2(self, {
|
|
12337
12349
|
onFailure: (_) => void_$2,
|
|
12338
12350
|
onSuccess: (_) => void_$2
|
|
@@ -17868,7 +17880,7 @@ const retry = retry$1;
|
|
|
17868
17880
|
* @category error handling
|
|
17869
17881
|
* @since 2.0.0
|
|
17870
17882
|
*/
|
|
17871
|
-
const ignore = ignore$
|
|
17883
|
+
const ignore$1 = ignore$2;
|
|
17872
17884
|
/**
|
|
17873
17885
|
* Recovers from a typed failure by producing a fallback success value.
|
|
17874
17886
|
*
|
|
@@ -63703,7 +63715,7 @@ const make$8 = /* @__PURE__ */ fnUntraced(function* (options) {
|
|
|
63703
63715
|
if (disabledUntil !== void 0) return void_;
|
|
63704
63716
|
runExportFork(runExport);
|
|
63705
63717
|
return awaitEmpty(exportFibers);
|
|
63706
|
-
}).pipe(ignore, interruptible, timeoutOption(options.shutdownTimeout)));
|
|
63718
|
+
}).pipe(ignore$1, interruptible, timeoutOption(options.shutdownTimeout)));
|
|
63707
63719
|
yield* sleep(exportInterval).pipe(andThen(run(exportFibers, runExport)), flatMap$2(await_), forever, forkIn(scope));
|
|
63708
63720
|
return { push(data) {
|
|
63709
63721
|
if (disabledUntil !== void 0) return;
|
|
@@ -65761,11 +65773,11 @@ const layer$2 = /* @__PURE__ */ effect(ChildProcessSpawner, /* @__PURE__ */ gen(
|
|
|
65761
65773
|
const killWithTimeout = withTimeout(childProcess, cmd, cmd.options);
|
|
65762
65774
|
if (exited) {
|
|
65763
65775
|
const [code] = yield* _await(exitSignal);
|
|
65764
|
-
if (code !== 0 && isNotNull(code)) return yield* ignore(killWithTimeout(killProcessGroup));
|
|
65776
|
+
if (code !== 0 && isNotNull(code)) return yield* ignore$1(killWithTimeout(killProcessGroup));
|
|
65765
65777
|
return yield* void_;
|
|
65766
65778
|
}
|
|
65767
65779
|
if (!isReferenced) return yield* void_;
|
|
65768
|
-
return yield* killWithTimeout((command, childProcess, signal) => killProcessGroup(command, childProcess, signal).pipe(catch_$1(() => killProcess(command, childProcess, signal)), andThen(_await(exitSignal)))).pipe(ignore);
|
|
65780
|
+
return yield* killWithTimeout((command, childProcess, signal) => killProcessGroup(command, childProcess, signal).pipe(catch_$1(() => killProcess(command, childProcess, signal)), andThen(_await(exitSignal)))).pipe(ignore$1);
|
|
65769
65781
|
}));
|
|
65770
65782
|
const pid = ProcessId(childProcess.pid);
|
|
65771
65783
|
childProcess.on("exit", (code) => {
|
|
@@ -66311,6 +66323,571 @@ const layer = /* @__PURE__ */ succeed$3(Path)({
|
|
|
66311
66323
|
});
|
|
66312
66324
|
//#endregion
|
|
66313
66325
|
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
66326
|
+
var import_ignore = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66327
|
+
function makeArray(subject) {
|
|
66328
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
66329
|
+
}
|
|
66330
|
+
const UNDEFINED = void 0;
|
|
66331
|
+
const EMPTY = "";
|
|
66332
|
+
const SPACE = " ";
|
|
66333
|
+
const ESCAPE = "\\";
|
|
66334
|
+
const REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
66335
|
+
const BOM = "";
|
|
66336
|
+
const REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/;
|
|
66337
|
+
const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
66338
|
+
const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
66339
|
+
const REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
66340
|
+
const DOUBLE_SLASH = "//";
|
|
66341
|
+
const SLASH_CODE = 47;
|
|
66342
|
+
const DOT_CODE = 46;
|
|
66343
|
+
const SLASH = "/";
|
|
66344
|
+
let TMP_KEY_IGNORE = "node-ignore";
|
|
66345
|
+
/* istanbul ignore else */
|
|
66346
|
+
if (typeof Symbol !== "undefined") TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
66347
|
+
const KEY_IGNORE = TMP_KEY_IGNORE;
|
|
66348
|
+
const define = (object, key, value) => {
|
|
66349
|
+
Object.defineProperty(object, key, { value });
|
|
66350
|
+
return value;
|
|
66351
|
+
};
|
|
66352
|
+
const RETURN_FALSE = () => false;
|
|
66353
|
+
const POSIX_CLASSES = {
|
|
66354
|
+
alnum: "0-9A-Za-z",
|
|
66355
|
+
alpha: "A-Za-z",
|
|
66356
|
+
blank: " \\t",
|
|
66357
|
+
cntrl: "\\x00-\\x1f\\x7f",
|
|
66358
|
+
digit: "0-9",
|
|
66359
|
+
graph: "!-.0-~",
|
|
66360
|
+
lower: "a-z",
|
|
66361
|
+
print: " -.0-~",
|
|
66362
|
+
punct: "!-.:-@\\[-`{-~",
|
|
66363
|
+
space: " \\t\\n\\r",
|
|
66364
|
+
upper: "A-Z",
|
|
66365
|
+
xdigit: "0-9A-Fa-f"
|
|
66366
|
+
};
|
|
66367
|
+
const CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
|
|
66368
|
+
const escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
|
|
66369
|
+
const NON_SLASH = "(?!\\/)";
|
|
66370
|
+
const classSource = (negated, body) => {
|
|
66371
|
+
if (negated) return `[^\\/${body}]`;
|
|
66372
|
+
const source = `[${body}]`;
|
|
66373
|
+
return new RegExp(source).test("/") ? NON_SLASH + source : source;
|
|
66374
|
+
};
|
|
66375
|
+
const scanBracket = (pattern, start) => {
|
|
66376
|
+
const { length } = pattern;
|
|
66377
|
+
let index = start + 1;
|
|
66378
|
+
let negated = EMPTY;
|
|
66379
|
+
const lead = pattern[index];
|
|
66380
|
+
if (lead === "!" || lead === "^") {
|
|
66381
|
+
negated = "^";
|
|
66382
|
+
index++;
|
|
66383
|
+
}
|
|
66384
|
+
let body = EMPTY;
|
|
66385
|
+
let prev = EMPTY;
|
|
66386
|
+
for (;;) {
|
|
66387
|
+
const char = pattern[index];
|
|
66388
|
+
if (char === UNDEFINED) return null;
|
|
66389
|
+
if (char === ESCAPE) {
|
|
66390
|
+
const escaped = pattern[++index];
|
|
66391
|
+
body += escapeMember(escaped);
|
|
66392
|
+
prev = escaped;
|
|
66393
|
+
} else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
|
|
66394
|
+
index++;
|
|
66395
|
+
let to = pattern[index];
|
|
66396
|
+
if (to === ESCAPE) to = pattern[index += 1];
|
|
66397
|
+
if (prev <= to) body += `-${escapeMember(to)}`;
|
|
66398
|
+
prev = EMPTY;
|
|
66399
|
+
} else if (char === "[" && pattern[index + 1] === ":") {
|
|
66400
|
+
const nameStart = index + 2;
|
|
66401
|
+
let end = nameStart;
|
|
66402
|
+
while (end < length && pattern[end] !== "]") end++;
|
|
66403
|
+
if (end === length) return null;
|
|
66404
|
+
if (end > nameStart && pattern[end - 1] === ":") {
|
|
66405
|
+
const name = pattern.slice(nameStart, end - 1);
|
|
66406
|
+
if (!Object.prototype.hasOwnProperty.call(POSIX_CLASSES, name)) return null;
|
|
66407
|
+
body += POSIX_CLASSES[name];
|
|
66408
|
+
prev = EMPTY;
|
|
66409
|
+
index = end;
|
|
66410
|
+
} else {
|
|
66411
|
+
body += escapeMember("[");
|
|
66412
|
+
prev = "[";
|
|
66413
|
+
index = nameStart - 2;
|
|
66414
|
+
}
|
|
66415
|
+
} else {
|
|
66416
|
+
body += escapeMember(char);
|
|
66417
|
+
prev = char;
|
|
66418
|
+
}
|
|
66419
|
+
index++;
|
|
66420
|
+
if (pattern[index] === "]") return {
|
|
66421
|
+
end: index,
|
|
66422
|
+
source: classSource(negated, body)
|
|
66423
|
+
};
|
|
66424
|
+
}
|
|
66425
|
+
};
|
|
66426
|
+
const NEVER_MATCH = "[]";
|
|
66427
|
+
const PLACEHOLDER = "\0";
|
|
66428
|
+
const REGEX_RESTORE_PLACEHOLDER = new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g");
|
|
66429
|
+
const TRAILING_WILDCARD = "";
|
|
66430
|
+
const TRAILING_DOUBLESTAR = "";
|
|
66431
|
+
const isReserved = (char) => char === PLACEHOLDER || char === TRAILING_WILDCARD || char === TRAILING_DOUBLESTAR;
|
|
66432
|
+
const extractBrackets = (pattern) => {
|
|
66433
|
+
const sources = [];
|
|
66434
|
+
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
66435
|
+
const { length } = pattern;
|
|
66436
|
+
let out = EMPTY;
|
|
66437
|
+
let index = 0;
|
|
66438
|
+
while (index < length) {
|
|
66439
|
+
const char = pattern[index];
|
|
66440
|
+
if (char === ESCAPE) {
|
|
66441
|
+
const escaped = pattern[index + 1];
|
|
66442
|
+
if (escaped === SLASH && index + 2 === length) out += hold(NEVER_MATCH);
|
|
66443
|
+
else if (escaped === "*" || escaped === "[" || escaped === SPACE) out += pattern.slice(index, index + 2);
|
|
66444
|
+
else out += hold(REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : isReserved(escaped) ? `[${escaped}]` : escaped);
|
|
66445
|
+
index += 2;
|
|
66446
|
+
} else if (isReserved(char)) {
|
|
66447
|
+
out += hold(`[${char}]`);
|
|
66448
|
+
index++;
|
|
66449
|
+
} else if (char === "[") {
|
|
66450
|
+
const scanned = scanBracket(pattern, index);
|
|
66451
|
+
if (scanned === null) {
|
|
66452
|
+
out += hold(NEVER_MATCH);
|
|
66453
|
+
index = length;
|
|
66454
|
+
} else {
|
|
66455
|
+
out += hold(scanned.source);
|
|
66456
|
+
index = scanned.end + 1;
|
|
66457
|
+
}
|
|
66458
|
+
} else {
|
|
66459
|
+
out += char;
|
|
66460
|
+
index++;
|
|
66461
|
+
}
|
|
66462
|
+
}
|
|
66463
|
+
return {
|
|
66464
|
+
source: out,
|
|
66465
|
+
sources
|
|
66466
|
+
};
|
|
66467
|
+
};
|
|
66468
|
+
const DIRECT = null;
|
|
66469
|
+
const REGEX_INNER_SLASH = /\/(?!$)/;
|
|
66470
|
+
const WILDCARD = "[^\\/]*";
|
|
66471
|
+
const REPLACERS = [
|
|
66472
|
+
[
|
|
66473
|
+
/(\\+)( ?)/g,
|
|
66474
|
+
(_, run, space) => space ? run.slice(0, run.length - run.length % 2) + SPACE : run,
|
|
66475
|
+
ESCAPE + SPACE
|
|
66476
|
+
],
|
|
66477
|
+
[
|
|
66478
|
+
/(^|\/)\*{3,}(?=\/|$)/g,
|
|
66479
|
+
(_, start) => `${start}**`,
|
|
66480
|
+
"*"
|
|
66481
|
+
],
|
|
66482
|
+
[/[\\$.|*+(){^]/g, (match) => `\\${match}`],
|
|
66483
|
+
[
|
|
66484
|
+
/(?!\\)\?/g,
|
|
66485
|
+
() => "[^/]",
|
|
66486
|
+
"?"
|
|
66487
|
+
],
|
|
66488
|
+
[
|
|
66489
|
+
/^\//,
|
|
66490
|
+
() => "^",
|
|
66491
|
+
SLASH
|
|
66492
|
+
],
|
|
66493
|
+
[
|
|
66494
|
+
/\//g,
|
|
66495
|
+
() => "\\/",
|
|
66496
|
+
SLASH
|
|
66497
|
+
],
|
|
66498
|
+
[
|
|
66499
|
+
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
66500
|
+
() => "(?:^|\\/)",
|
|
66501
|
+
"*"
|
|
66502
|
+
],
|
|
66503
|
+
[DIRECT, (source, pattern) => {
|
|
66504
|
+
if (!source || source[0] === "^" || source[0] === "(") return source;
|
|
66505
|
+
return (!REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^") + source;
|
|
66506
|
+
}],
|
|
66507
|
+
[
|
|
66508
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
66509
|
+
(_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
66510
|
+
"*"
|
|
66511
|
+
],
|
|
66512
|
+
[
|
|
66513
|
+
/(^|[^\\])(?:\\\*)+(?!$)/g,
|
|
66514
|
+
(_, p1) => p1 + WILDCARD,
|
|
66515
|
+
"*"
|
|
66516
|
+
],
|
|
66517
|
+
[
|
|
66518
|
+
/(^|[^\\])((?:\\\\)*)\\\*$/,
|
|
66519
|
+
(match, p1, p2) => p2 === EMPTY ? p1 + TRAILING_WILDCARD : match,
|
|
66520
|
+
"*"
|
|
66521
|
+
],
|
|
66522
|
+
[
|
|
66523
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
66524
|
+
() => ESCAPE,
|
|
66525
|
+
ESCAPE + ESCAPE
|
|
66526
|
+
],
|
|
66527
|
+
[
|
|
66528
|
+
/\\\\/g,
|
|
66529
|
+
() => ESCAPE,
|
|
66530
|
+
ESCAPE + ESCAPE
|
|
66531
|
+
],
|
|
66532
|
+
[
|
|
66533
|
+
/\\\[([^\]/]*?)($|\])/g,
|
|
66534
|
+
(match, range, close) => `\\[${range}${close}`,
|
|
66535
|
+
"["
|
|
66536
|
+
],
|
|
66537
|
+
[DIRECT, (source) => {
|
|
66538
|
+
const last = source[source.length - 1];
|
|
66539
|
+
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) return source;
|
|
66540
|
+
return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
66541
|
+
}]
|
|
66542
|
+
];
|
|
66543
|
+
const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
|
|
66544
|
+
const MODE_IGNORE = "regex";
|
|
66545
|
+
const MODE_CHECK_IGNORE = "checkRegex";
|
|
66546
|
+
const UNDERSCORE = "_";
|
|
66547
|
+
const replaceTrailingWildcard = (_, p1) => {
|
|
66548
|
+
return `${p1 ? `${p1}[^/]+` : "[^/]*"}(?=$|\\/$)`;
|
|
66549
|
+
};
|
|
66550
|
+
const REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
|
|
66551
|
+
const replaceTrailingDoublestar = () => "[\\s\\S]";
|
|
66552
|
+
const separatorAfter = (run, at) => {
|
|
66553
|
+
let separator = EMPTY;
|
|
66554
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) separator += run[index].single;
|
|
66555
|
+
return separator;
|
|
66556
|
+
};
|
|
66557
|
+
const pinWildcards = (source) => {
|
|
66558
|
+
if (source.indexOf(WILDCARD) < 0) return source;
|
|
66559
|
+
const tokens = [];
|
|
66560
|
+
const { length } = source;
|
|
66561
|
+
let index = 0;
|
|
66562
|
+
while (index < length) {
|
|
66563
|
+
const char = source[index];
|
|
66564
|
+
if (source.startsWith(WILDCARD, index)) {
|
|
66565
|
+
tokens.push({ wildcard: true });
|
|
66566
|
+
index += 6;
|
|
66567
|
+
} else if (char === "[") {
|
|
66568
|
+
let end = index + 1;
|
|
66569
|
+
if (source[end] === "^") end++;
|
|
66570
|
+
if (source[end] === "]") end++;
|
|
66571
|
+
while (end < length && source[end] !== "]") end += source[end] === ESCAPE ? 2 : 1;
|
|
66572
|
+
end++;
|
|
66573
|
+
tokens.push({ single: source.slice(index, end) });
|
|
66574
|
+
index = end;
|
|
66575
|
+
} else if (char === ESCAPE) {
|
|
66576
|
+
tokens.push({ single: source.slice(index, index + 2) });
|
|
66577
|
+
index += 2;
|
|
66578
|
+
} else if (char === "(") {
|
|
66579
|
+
let depth = 0;
|
|
66580
|
+
let end = index;
|
|
66581
|
+
do {
|
|
66582
|
+
if (source[end] === ESCAPE) end++;
|
|
66583
|
+
else if (source[end] === "(") depth++;
|
|
66584
|
+
else if (source[end] === ")") depth--;
|
|
66585
|
+
end++;
|
|
66586
|
+
} while (end < length && depth > 0);
|
|
66587
|
+
if ("*+?".indexOf(source[end]) >= 0) end++;
|
|
66588
|
+
tokens.push({ boundary: source.slice(index, end) });
|
|
66589
|
+
index = end;
|
|
66590
|
+
} else if (char === "^" || char === "$") {
|
|
66591
|
+
tokens.push({ boundary: char });
|
|
66592
|
+
index++;
|
|
66593
|
+
} else {
|
|
66594
|
+
tokens.push({ single: char });
|
|
66595
|
+
index++;
|
|
66596
|
+
}
|
|
66597
|
+
}
|
|
66598
|
+
let out = EMPTY;
|
|
66599
|
+
let run = [];
|
|
66600
|
+
const flush = () => {
|
|
66601
|
+
let lastWildcard;
|
|
66602
|
+
run.forEach((token, at) => {
|
|
66603
|
+
if (token.wildcard) lastWildcard = at;
|
|
66604
|
+
});
|
|
66605
|
+
run.forEach((token, at) => {
|
|
66606
|
+
if (!token.wildcard) {
|
|
66607
|
+
out += token.single;
|
|
66608
|
+
return;
|
|
66609
|
+
}
|
|
66610
|
+
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
66611
|
+
});
|
|
66612
|
+
run = [];
|
|
66613
|
+
};
|
|
66614
|
+
tokens.forEach((token) => {
|
|
66615
|
+
if (token.boundary === void 0) {
|
|
66616
|
+
run.push(token);
|
|
66617
|
+
return;
|
|
66618
|
+
}
|
|
66619
|
+
flush();
|
|
66620
|
+
out += token.boundary;
|
|
66621
|
+
});
|
|
66622
|
+
flush();
|
|
66623
|
+
return out;
|
|
66624
|
+
};
|
|
66625
|
+
const makeRegexPrefix = (pattern) => {
|
|
66626
|
+
if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) pattern = "**";
|
|
66627
|
+
const { source, sources } = extractBrackets(pattern);
|
|
66628
|
+
const replaced = REPLACERS.reduce((prev, [matcher, replacer, required]) => {
|
|
66629
|
+
if (matcher === DIRECT) return replacer(prev, pattern);
|
|
66630
|
+
if (required !== UNDEFINED && prev.indexOf(required) < 0) return prev;
|
|
66631
|
+
return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
|
|
66632
|
+
}, source);
|
|
66633
|
+
return sources.length ? replaced.replace(REGEX_RESTORE_PLACEHOLDER, (match, index) => sources[index]) : replaced;
|
|
66634
|
+
};
|
|
66635
|
+
const checkSourceOf = (body, prefix) => {
|
|
66636
|
+
if (body[body.length - 1] === SLASH) prefix = makeRegexPrefix(body.slice(0, -1));
|
|
66637
|
+
const head = prefix.slice(0, -1);
|
|
66638
|
+
const last = prefix[prefix.length - 1];
|
|
66639
|
+
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? head : NEVER_MATCH;
|
|
66640
|
+
};
|
|
66641
|
+
const matchesBasename = (body) => {
|
|
66642
|
+
const index = body.indexOf(SLASH);
|
|
66643
|
+
return index < 0 || index === body.length - 1;
|
|
66644
|
+
};
|
|
66645
|
+
const basenameOf = (path) => {
|
|
66646
|
+
const end = path.length - 1;
|
|
66647
|
+
const index = path.lastIndexOf(SLASH, path[end] === SLASH ? end - 1 : end);
|
|
66648
|
+
return index < 0 ? path : path.slice(index + 1);
|
|
66649
|
+
};
|
|
66650
|
+
const parentOf = (path) => {
|
|
66651
|
+
if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
|
|
66652
|
+
const slices = path.split(SLASH).filter(Boolean);
|
|
66653
|
+
slices.pop();
|
|
66654
|
+
return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
|
|
66655
|
+
}
|
|
66656
|
+
const end = path.length - 1;
|
|
66657
|
+
const cut = path.lastIndexOf(SLASH, path.charCodeAt(end) === SLASH_CODE ? end - 1 : end);
|
|
66658
|
+
return cut < 0 ? EMPTY : path.slice(0, cut + 1);
|
|
66659
|
+
};
|
|
66660
|
+
const isString = (subject) => typeof subject === "string";
|
|
66661
|
+
const checkPattern = (pattern) => pattern && isString(pattern);
|
|
66662
|
+
const splitPattern = (pattern) => (pattern[pattern.length - 1] === "\r" ? pattern.slice(0, -1) : pattern).split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
66663
|
+
var IgnoreRule = class {
|
|
66664
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
66665
|
+
this.pattern = pattern;
|
|
66666
|
+
this.mark = mark;
|
|
66667
|
+
this.negative = negative;
|
|
66668
|
+
define(this, "body", body);
|
|
66669
|
+
define(this, "ignoreCase", ignoreCase);
|
|
66670
|
+
define(this, "regexPrefix", prefix);
|
|
66671
|
+
}
|
|
66672
|
+
get _basenameOnly() {
|
|
66673
|
+
return define(this, "_basenameOnly", matchesBasename(this.body));
|
|
66674
|
+
}
|
|
66675
|
+
get regex() {
|
|
66676
|
+
const key = UNDERSCORE + MODE_IGNORE;
|
|
66677
|
+
if (this[key]) return this[key];
|
|
66678
|
+
return this._make(MODE_IGNORE, key);
|
|
66679
|
+
}
|
|
66680
|
+
get checkRegex() {
|
|
66681
|
+
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
66682
|
+
if (this[key]) return this[key];
|
|
66683
|
+
return this._make(MODE_CHECK_IGNORE, key);
|
|
66684
|
+
}
|
|
66685
|
+
_make(mode, key) {
|
|
66686
|
+
const str = pinWildcards(mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix));
|
|
66687
|
+
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
66688
|
+
return define(this, key, regex);
|
|
66689
|
+
}
|
|
66690
|
+
};
|
|
66691
|
+
const hasTrailingBackslash = (str) => {
|
|
66692
|
+
let count = 0;
|
|
66693
|
+
while (str[str.length - count - 1] === ESCAPE) count++;
|
|
66694
|
+
return count % 2 === 1;
|
|
66695
|
+
};
|
|
66696
|
+
const trimEnd = (body, stripLineEnd) => {
|
|
66697
|
+
let lineEnd = body.length;
|
|
66698
|
+
let end;
|
|
66699
|
+
for (;;) {
|
|
66700
|
+
if (stripLineEnd && body[lineEnd - 1] === "\r") lineEnd--;
|
|
66701
|
+
end = lineEnd;
|
|
66702
|
+
while (body[end - 1] === SPACE) end--;
|
|
66703
|
+
if (!stripLineEnd || body[end - 1] !== "\n") break;
|
|
66704
|
+
lineEnd = end - 1;
|
|
66705
|
+
}
|
|
66706
|
+
if (end === lineEnd) return body.slice(0, lineEnd);
|
|
66707
|
+
let backslashes = 0;
|
|
66708
|
+
while (body[end - backslashes - 1] === ESCAPE) backslashes++;
|
|
66709
|
+
return backslashes % 2 ? body.slice(0, end - 1) + SPACE : body.slice(0, end);
|
|
66710
|
+
};
|
|
66711
|
+
const createRule = (pattern, mark, ignoreCase, stripLineEnd, stripBOM) => {
|
|
66712
|
+
let body = stripBOM && pattern[0] === BOM ? pattern.slice(1) : pattern;
|
|
66713
|
+
if (body[0] === "#") return;
|
|
66714
|
+
let negative = false;
|
|
66715
|
+
if (body[0] === "!") {
|
|
66716
|
+
negative = true;
|
|
66717
|
+
body = body.slice(1);
|
|
66718
|
+
}
|
|
66719
|
+
const last = body[body.length - 1];
|
|
66720
|
+
if (last === SPACE || stripLineEnd && (last === "\r" || last === "\n")) body = trimEnd(body, stripLineEnd);
|
|
66721
|
+
if (!body || hasTrailingBackslash(body)) return;
|
|
66722
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
66723
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
66724
|
+
return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
|
|
66725
|
+
};
|
|
66726
|
+
var RuleManager = class {
|
|
66727
|
+
constructor(ignoreCase) {
|
|
66728
|
+
this._ignoreCase = ignoreCase;
|
|
66729
|
+
this._rules = [];
|
|
66730
|
+
this._basenameCount = 0;
|
|
66731
|
+
}
|
|
66732
|
+
_add(pattern, index) {
|
|
66733
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
66734
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
66735
|
+
this._basenameCount += pattern._rules._basenameCount;
|
|
66736
|
+
this._added = true;
|
|
66737
|
+
return;
|
|
66738
|
+
}
|
|
66739
|
+
const isStr = isString(pattern);
|
|
66740
|
+
const raw = isStr ? pattern : pattern.pattern;
|
|
66741
|
+
const rule = checkPattern(raw) && createRule(raw, isStr ? UNDEFINED : pattern.mark, this._ignoreCase, !this._split, this._stripBOM && !index);
|
|
66742
|
+
if (rule) {
|
|
66743
|
+
this._added = true;
|
|
66744
|
+
this._rules.push(rule);
|
|
66745
|
+
if (matchesBasename(rule.body)) this._basenameCount++;
|
|
66746
|
+
}
|
|
66747
|
+
}
|
|
66748
|
+
add(pattern) {
|
|
66749
|
+
this._added = false;
|
|
66750
|
+
this._split = isString(pattern);
|
|
66751
|
+
this._stripBOM = !this._split || pattern[0] === BOM;
|
|
66752
|
+
makeArray(this._split ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
66753
|
+
if (this._added) this._literalRules = UNDEFINED;
|
|
66754
|
+
return this._added;
|
|
66755
|
+
}
|
|
66756
|
+
testLiteral(path) {
|
|
66757
|
+
const rules = this._literalRules || (this._literalRules = this._rules.filter(({ body }) => body[body.length - (body[body.length - 1] === SLASH ? 2 : 1)] === "*"));
|
|
66758
|
+
let ignored = false;
|
|
66759
|
+
let unignored = false;
|
|
66760
|
+
let matchedRule;
|
|
66761
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
66762
|
+
const rule = rules[index];
|
|
66763
|
+
if (rule.checkRegex.test(path)) {
|
|
66764
|
+
ignored = !rule.negative;
|
|
66765
|
+
unignored = rule.negative;
|
|
66766
|
+
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
66767
|
+
break;
|
|
66768
|
+
}
|
|
66769
|
+
}
|
|
66770
|
+
const ret = {
|
|
66771
|
+
ignored,
|
|
66772
|
+
unignored
|
|
66773
|
+
};
|
|
66774
|
+
if (matchedRule) ret.rule = matchedRule;
|
|
66775
|
+
return ret;
|
|
66776
|
+
}
|
|
66777
|
+
test(path, mode) {
|
|
66778
|
+
const rules = this._rules;
|
|
66779
|
+
const { length } = rules;
|
|
66780
|
+
const shortcut = this._basenameCount * 2 >= length;
|
|
66781
|
+
const basename = shortcut ? basenameOf(path) : path;
|
|
66782
|
+
for (let index = length - 1; index >= 0; index--) {
|
|
66783
|
+
const rule = rules[index];
|
|
66784
|
+
if (rule[mode].test(shortcut && rule._basenameOnly ? basename : path)) {
|
|
66785
|
+
const { negative } = rule;
|
|
66786
|
+
const ret = {
|
|
66787
|
+
ignored: !negative,
|
|
66788
|
+
unignored: negative
|
|
66789
|
+
};
|
|
66790
|
+
if (!negative) ret.rule = rule;
|
|
66791
|
+
return ret;
|
|
66792
|
+
}
|
|
66793
|
+
}
|
|
66794
|
+
return {
|
|
66795
|
+
ignored: false,
|
|
66796
|
+
unignored: false
|
|
66797
|
+
};
|
|
66798
|
+
}
|
|
66799
|
+
};
|
|
66800
|
+
const throwError = (message, Ctor) => {
|
|
66801
|
+
throw new Ctor(message);
|
|
66802
|
+
};
|
|
66803
|
+
const checkPath = (path, originalPath, doThrow) => {
|
|
66804
|
+
if (!isString(path)) return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
66805
|
+
if (!path) return doThrow(`path must not be empty`, TypeError);
|
|
66806
|
+
if (checkPath.isNotRelative(path)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
|
|
66807
|
+
return true;
|
|
66808
|
+
};
|
|
66809
|
+
const isNotRelative = (path) => {
|
|
66810
|
+
const first = path.charCodeAt(0);
|
|
66811
|
+
if (first === SLASH_CODE) return true;
|
|
66812
|
+
if (first !== DOT_CODE) return false;
|
|
66813
|
+
if (path.length === 1) return true;
|
|
66814
|
+
const second = path.charCodeAt(1);
|
|
66815
|
+
if (second === SLASH_CODE) return true;
|
|
66816
|
+
if (second !== DOT_CODE) return false;
|
|
66817
|
+
return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
|
|
66818
|
+
};
|
|
66819
|
+
checkPath.isNotRelative = isNotRelative;
|
|
66820
|
+
/* istanbul ignore next */
|
|
66821
|
+
checkPath.convert = (p) => p;
|
|
66822
|
+
const convertPath = (target) => isString(target) && checkPath.convert(target);
|
|
66823
|
+
var Ignore = class {
|
|
66824
|
+
constructor({ ignorecase = true, ignoreCase = ignorecase, allowRelativePaths = false } = {}) {
|
|
66825
|
+
define(this, KEY_IGNORE, true);
|
|
66826
|
+
this._rules = new RuleManager(ignoreCase);
|
|
66827
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
66828
|
+
this._initCache();
|
|
66829
|
+
}
|
|
66830
|
+
_initCache() {
|
|
66831
|
+
this._ignoreCache = Object.create(null);
|
|
66832
|
+
this._testCache = Object.create(null);
|
|
66833
|
+
}
|
|
66834
|
+
add(pattern) {
|
|
66835
|
+
if (this._rules.add(pattern)) this._initCache();
|
|
66836
|
+
return this;
|
|
66837
|
+
}
|
|
66838
|
+
addPattern(pattern) {
|
|
66839
|
+
return this.add(pattern);
|
|
66840
|
+
}
|
|
66841
|
+
_test(originalPath, cache, path) {
|
|
66842
|
+
checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
66843
|
+
return path ? this._t(path, cache) : {
|
|
66844
|
+
ignored: false,
|
|
66845
|
+
unignored: false
|
|
66846
|
+
};
|
|
66847
|
+
}
|
|
66848
|
+
checkIgnore(target) {
|
|
66849
|
+
const path = convertPath(target);
|
|
66850
|
+
if (!path || path.charCodeAt(path.length - 1) !== SLASH_CODE) return this._test(target, this._testCache, path);
|
|
66851
|
+
const dir = this._t(path, this._testCache);
|
|
66852
|
+
if (dir.ignored) return dir;
|
|
66853
|
+
const literal = this._rules.testLiteral(path);
|
|
66854
|
+
return literal.ignored || literal.unignored ? literal : dir;
|
|
66855
|
+
}
|
|
66856
|
+
_t(path, cache) {
|
|
66857
|
+
if (path in cache) return cache[path];
|
|
66858
|
+
const parentPath = parentOf(path);
|
|
66859
|
+
const parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
|
|
66860
|
+
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, MODE_IGNORE);
|
|
66861
|
+
}
|
|
66862
|
+
ignores(path) {
|
|
66863
|
+
return this._test(path, this._ignoreCache, convertPath(path)).ignored;
|
|
66864
|
+
}
|
|
66865
|
+
createFilter() {
|
|
66866
|
+
return (path) => !this.ignores(path);
|
|
66867
|
+
}
|
|
66868
|
+
filter(paths) {
|
|
66869
|
+
return makeArray(paths).filter(this.createFilter());
|
|
66870
|
+
}
|
|
66871
|
+
test(path) {
|
|
66872
|
+
return this._test(path, this._testCache, convertPath(path));
|
|
66873
|
+
}
|
|
66874
|
+
};
|
|
66875
|
+
const factory = (options) => new Ignore(options);
|
|
66876
|
+
const isPathValid = (path) => checkPath(convertPath(path), path, RETURN_FALSE);
|
|
66877
|
+
/* istanbul ignore next */
|
|
66878
|
+
const setupWindows = () => {
|
|
66879
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
66880
|
+
checkPath.convert = makePosix;
|
|
66881
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
66882
|
+
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
66883
|
+
};
|
|
66884
|
+
/* istanbul ignore next */
|
|
66885
|
+
if (typeof process !== "undefined" && process.platform === "win32") setupWindows();
|
|
66886
|
+
module.exports = factory;
|
|
66887
|
+
factory.default = factory;
|
|
66888
|
+
module.exports.isPathValid = isPathValid;
|
|
66889
|
+
define(module.exports, Symbol.for("setupWindows"), setupWindows);
|
|
66890
|
+
})))(), 1);
|
|
66314
66891
|
var comma = ",".charCodeAt(0);
|
|
66315
66892
|
";".charCodeAt(0);
|
|
66316
66893
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -70385,7 +70962,6 @@ const DEFAULT_SURFACE_EXCLUDED_TAGS = {
|
|
|
70385
70962
|
score: ["design"],
|
|
70386
70963
|
ciFailure: ["design"]
|
|
70387
70964
|
};
|
|
70388
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
70389
70965
|
const KNOWN_RULE_KEYS = new Set([...ALL_REACT_DOCTOR_RULE_KEYS, ...EXTERNAL_RULES.map((rule) => rule.key)]);
|
|
70390
70966
|
const BUNDLED_RULE_NAMESPACES = new Set([...KNOWN_RULE_KEYS].flatMap(getEquivalentRuleKeys).map((key) => key.slice(0, key.lastIndexOf("/"))));
|
|
70391
70967
|
const getUnknownBundledRuleKeys = (rules) => Object.keys(rules ?? {}).filter((key) => {
|
|
@@ -74246,7 +74822,7 @@ const stripGitignoreEscape = (pattern) => {
|
|
|
74246
74822
|
if (pattern.startsWith("\\#") || pattern.startsWith("\\!")) return pattern.slice(1);
|
|
74247
74823
|
return pattern;
|
|
74248
74824
|
};
|
|
74249
|
-
const readIgnoreFile = (filePath) => {
|
|
74825
|
+
const readIgnoreFile = (filePath, { preserveSyntax = false } = {}) => {
|
|
74250
74826
|
let content;
|
|
74251
74827
|
try {
|
|
74252
74828
|
content = fs$1$2.readFileSync(filePath, "utf-8");
|
|
@@ -74256,7 +74832,13 @@ const readIgnoreFile = (filePath) => {
|
|
|
74256
74832
|
return [];
|
|
74257
74833
|
}
|
|
74258
74834
|
const patterns = [];
|
|
74259
|
-
|
|
74835
|
+
const source = preserveSyntax ? stripUtf8Bom(content) : content;
|
|
74836
|
+
for (const line of source.split("\n")) {
|
|
74837
|
+
if (preserveSyntax) {
|
|
74838
|
+
const pattern = line.replace(/\r$/, "");
|
|
74839
|
+
if (pattern.length > 0 && !pattern.startsWith("#")) patterns.push(pattern);
|
|
74840
|
+
continue;
|
|
74841
|
+
}
|
|
74260
74842
|
const trimmed = line.trim();
|
|
74261
74843
|
if (trimmed.length === 0) continue;
|
|
74262
74844
|
if (trimmed.startsWith("#")) continue;
|
|
@@ -74264,33 +74846,52 @@ const readIgnoreFile = (filePath) => {
|
|
|
74264
74846
|
}
|
|
74265
74847
|
return patterns;
|
|
74266
74848
|
};
|
|
74267
|
-
const IGNORE_FILENAMES = [
|
|
74268
|
-
".eslintignore",
|
|
74269
|
-
".oxlintignore",
|
|
74270
|
-
".prettierignore"
|
|
74271
|
-
];
|
|
74272
74849
|
const cachedPatternsByRoot = /* @__PURE__ */ new Map();
|
|
74273
74850
|
const clearIgnorePatternsCache = () => {
|
|
74274
74851
|
cachedPatternsByRoot.clear();
|
|
74275
74852
|
};
|
|
74276
|
-
const
|
|
74277
|
-
|
|
74278
|
-
const
|
|
74279
|
-
const
|
|
74280
|
-
|
|
74281
|
-
|
|
74282
|
-
|
|
74853
|
+
const readLintIgnorePatterns = (rootDirectory, { preserveSyntax = false } = {}) => [...LINT_IGNORE_STYLE_FILENAMES.flatMap((filename) => readIgnoreFile(path$1$1.join(rootDirectory, filename), { preserveSyntax })), ...parseGitattributesLinguistPaths(path$1$1.join(rootDirectory, LINT_LINGUIST_FILENAME))];
|
|
74854
|
+
const rebasePattern = (pattern, directoryPrefix) => {
|
|
74855
|
+
const isNegated = pattern.startsWith("!");
|
|
74856
|
+
const body = isNegated ? pattern.slice(1) : pattern;
|
|
74857
|
+
const effectiveBody = body.replace(/ +$/, "");
|
|
74858
|
+
if (!effectiveBody.trim() || effectiveBody === "/") return null;
|
|
74859
|
+
const isAnchored = effectiveBody.startsWith("/") || effectiveBody.slice(0, -1).includes("/");
|
|
74860
|
+
const relativePattern = body.startsWith("/") ? body.slice(1) : body;
|
|
74861
|
+
return `${isNegated ? "!" : ""}/${directoryPrefix}/${isAnchored ? "" : "**/"}${relativePattern}`;
|
|
74862
|
+
};
|
|
74863
|
+
const readRebasedPatterns = (directory, boundary) => {
|
|
74864
|
+
const directoryPrefix = path$1$1.relative(boundary, directory).split(path$1$1.sep).join("/").replace(/[\\*?[\]]/g, "\\$&");
|
|
74865
|
+
return readLintIgnorePatterns(directory, { preserveSyntax: true }).map((pattern) => rebasePattern(pattern, directoryPrefix)).filter((pattern) => pattern !== null);
|
|
74866
|
+
};
|
|
74867
|
+
const resolveIgnoreBoundaryIndex = (directories) => {
|
|
74868
|
+
const boundaryIndex = directories.findIndex(isProjectBoundary);
|
|
74869
|
+
if (boundaryIndex <= 0) return 0;
|
|
74870
|
+
const packageDirectory = directories.slice(0, boundaryIndex).find((directory) => isFile(path$1$1.join(directory, "package.json")));
|
|
74871
|
+
if (!packageDirectory) return 0;
|
|
74872
|
+
const boundary = directories[boundaryIndex];
|
|
74873
|
+
return getWorkspacePatterns(boundary, readPackageJson(path$1$1.join(boundary, "package.json"))).some((pattern) => resolveWorkspaceDirectories(boundary, pattern).includes(packageDirectory)) ? boundaryIndex : 0;
|
|
74874
|
+
};
|
|
74875
|
+
const collectLintIgnorePolicy = (rootDirectory) => {
|
|
74876
|
+
const scanDirectory = path$1$1.resolve(rootDirectory);
|
|
74877
|
+
const directories = ancestorDirectories(scanDirectory, { includeStart: true });
|
|
74878
|
+
const boundaryIndex = resolveIgnoreBoundaryIndex(directories);
|
|
74879
|
+
const boundary = directories[boundaryIndex];
|
|
74880
|
+
const patterns = readLintIgnorePatterns(boundary, { preserveSyntax: true });
|
|
74881
|
+
for (const directory of directories.slice(0, boundaryIndex).reverse()) patterns.push(...readRebasedPatterns(directory, boundary));
|
|
74882
|
+
if (patterns.length === 0) return null;
|
|
74883
|
+
const matcher = (0, import_ignore.default)({
|
|
74884
|
+
ignorecase: false,
|
|
74885
|
+
allowRelativePaths: true
|
|
74886
|
+
}).add(patterns);
|
|
74887
|
+
return {
|
|
74888
|
+
patterns,
|
|
74889
|
+
includesFile: (filePath) => {
|
|
74890
|
+
const absolutePath = path$1$1.resolve(scanDirectory, filePath);
|
|
74891
|
+
if (!isPathInsideDirectory(absolutePath, scanDirectory)) return true;
|
|
74892
|
+
return !matcher.ignores(path$1$1.relative(boundary, absolutePath).split(path$1$1.sep).join("/"));
|
|
74893
|
+
}
|
|
74283
74894
|
};
|
|
74284
|
-
for (const filename of IGNORE_FILENAMES) for (const pattern of readIgnoreFile(path$1$1.join(rootDirectory, filename))) addPattern(pattern);
|
|
74285
|
-
for (const linguistPath of parseGitattributesLinguistPaths(path$1$1.join(rootDirectory, ".gitattributes"))) addPattern(linguistPath);
|
|
74286
|
-
return patterns;
|
|
74287
|
-
};
|
|
74288
|
-
const collectIgnorePatterns = (rootDirectory) => {
|
|
74289
|
-
const cached = cachedPatternsByRoot.get(rootDirectory);
|
|
74290
|
-
if (cached !== void 0) return cached;
|
|
74291
|
-
const patterns = computeIgnorePatterns(rootDirectory);
|
|
74292
|
-
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
74293
|
-
return patterns;
|
|
74294
74895
|
};
|
|
74295
74896
|
const findFirstLintConfigInDirectory = (directory) => {
|
|
74296
74897
|
for (const filename of ADOPTABLE_LINT_CONFIG_FILENAMES) {
|
|
@@ -74591,6 +75192,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths, options
|
|
|
74591
75192
|
const onExit = () => restore();
|
|
74592
75193
|
process.once("exit", onExit);
|
|
74593
75194
|
const leaseCandidatePath = (absolutePath) => {
|
|
75195
|
+
if (options.includesFile?.(path$1$1.relative(resolvedRootDirectory, absolutePath)) === false) return;
|
|
74594
75196
|
if (!isSymlinkFreePath(absolutePath, resolvedRootDirectory)) return;
|
|
74595
75197
|
if (leasedPaths.has(absolutePath)) return;
|
|
74596
75198
|
if (blockedPaths.has(absolutePath)) return;
|
|
@@ -76024,6 +76626,7 @@ const bridgeReactCompilerDiagnostic = (diagnostic) => {
|
|
|
76024
76626
|
url: bridgeRule.compilerUrl
|
|
76025
76627
|
};
|
|
76026
76628
|
};
|
|
76629
|
+
const getUtf16Offset = (sourceText, utf8Offset) => Buffer.from(sourceText).subarray(0, utf8Offset).toString("utf8").length;
|
|
76027
76630
|
const REACT_MODULE_SOURCE = "react";
|
|
76028
76631
|
const REQUIRE_IDENTIFIER = "require";
|
|
76029
76632
|
const USE_IDENTIFIER = "use";
|
|
@@ -76039,7 +76642,6 @@ const REACT_USE_BINDING_RESOLUTION = {
|
|
|
76039
76642
|
isReactUseBinding: true,
|
|
76040
76643
|
isReactNamespaceBinding: false
|
|
76041
76644
|
};
|
|
76042
|
-
const getUtf16Offset$1 = (sourceText, utf8Offset) => Buffer.from(sourceText).subarray(0, utf8Offset).toString("utf8").length;
|
|
76043
76645
|
const getStaticPropertyName = (node) => {
|
|
76044
76646
|
if (!node) return null;
|
|
76045
76647
|
if (typescriptBinding.isIdentifier(node) || typescriptBinding.isStringLiteral(node) || typescriptBinding.isNumericLiteral(node)) return node.text;
|
|
@@ -76276,7 +76878,7 @@ const findUseCallIdentifier = (sourceFile, useOffset) => {
|
|
|
76276
76878
|
};
|
|
76277
76879
|
const resolveUseCallBinding = (sourceText, filename, utf8Offset) => {
|
|
76278
76880
|
const sourceFile = typescriptBinding.createSourceFile(filename, sourceText, typescriptBinding.ScriptTarget.Latest, true, getTypescriptScriptKind(filename));
|
|
76279
|
-
const useIdentifier = findUseCallIdentifier(sourceFile, getUtf16Offset
|
|
76881
|
+
const useIdentifier = findUseCallIdentifier(sourceFile, getUtf16Offset(sourceText, utf8Offset));
|
|
76280
76882
|
if (!useIdentifier) return null;
|
|
76281
76883
|
return resolveIdentifierBinding(useIdentifier, collectReactImportBindings(sourceFile), sourceFile);
|
|
76282
76884
|
};
|
|
@@ -76311,7 +76913,6 @@ const WORKLET_ACCEPTING_CALLEES = new Set([
|
|
|
76311
76913
|
"executeOnUIRuntimeSync"
|
|
76312
76914
|
]);
|
|
76313
76915
|
const GESTURE_ROOT_IDENTIFIER = "Gesture";
|
|
76314
|
-
const getUtf16Offset = (sourceText, utf8Offset) => Buffer.from(sourceText).subarray(0, utf8Offset).toString("utf8").length;
|
|
76315
76916
|
const hasWorkletDirective = (node) => {
|
|
76316
76917
|
if (!typescriptBinding.isFunctionDeclaration(node) && !typescriptBinding.isFunctionExpression(node) && !typescriptBinding.isArrowFunction(node) && !typescriptBinding.isMethodDeclaration(node)) return false;
|
|
76317
76918
|
const body = node.body;
|
|
@@ -76384,6 +76985,228 @@ const shouldSuppressCompilerFindingInWorklet = (diagnostic, project, rootDirecto
|
|
|
76384
76985
|
}
|
|
76385
76986
|
return isOffsetInsideWorklet(typescriptBinding.createSourceFile(absolutePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, getTypescriptScriptKind(absolutePath)), getUtf16Offset(sourceText, primaryLabel.span.offset));
|
|
76386
76987
|
};
|
|
76988
|
+
const REFLECTION_NAMES = new Set([
|
|
76989
|
+
"eval",
|
|
76990
|
+
"require",
|
|
76991
|
+
"Function",
|
|
76992
|
+
"Object",
|
|
76993
|
+
"Reflect",
|
|
76994
|
+
"Promise",
|
|
76995
|
+
"globalThis",
|
|
76996
|
+
"global",
|
|
76997
|
+
"window",
|
|
76998
|
+
"self",
|
|
76999
|
+
"constructor",
|
|
77000
|
+
"prototype",
|
|
77001
|
+
"__proto__",
|
|
77002
|
+
"__defineGetter__",
|
|
77003
|
+
"__defineSetter__",
|
|
77004
|
+
"__lookupGetter__",
|
|
77005
|
+
"__lookupSetter__"
|
|
77006
|
+
]);
|
|
77007
|
+
const collectEffectSourceIndex = (sourceFile) => {
|
|
77008
|
+
const identifiers = /* @__PURE__ */ new Map();
|
|
77009
|
+
const calls = [];
|
|
77010
|
+
const pendingNodes = [sourceFile];
|
|
77011
|
+
let hasReflection = false;
|
|
77012
|
+
while (pendingNodes.length > 0) {
|
|
77013
|
+
const node = pendingNodes.pop();
|
|
77014
|
+
if (!node) continue;
|
|
77015
|
+
if (typescriptBinding.isIdentifier(node)) {
|
|
77016
|
+
const sameNameIdentifiers = identifiers.get(node.text) ?? /* @__PURE__ */ new Set();
|
|
77017
|
+
sameNameIdentifiers.add(node);
|
|
77018
|
+
identifiers.set(node.text, sameNameIdentifiers);
|
|
77019
|
+
if (REFLECTION_NAMES.has(node.text)) hasReflection = true;
|
|
77020
|
+
}
|
|
77021
|
+
let memberName;
|
|
77022
|
+
if (typescriptBinding.isPropertyAccessExpression(node)) memberName = node.name.text;
|
|
77023
|
+
else if (typescriptBinding.isElementAccessExpression(node)) {
|
|
77024
|
+
const memberArgument = unwrapTypescriptExpression(node.argumentExpression);
|
|
77025
|
+
if (typescriptBinding.isStringLiteral(memberArgument)) memberName = memberArgument.text;
|
|
77026
|
+
else hasReflection = true;
|
|
77027
|
+
} else if (typescriptBinding.isBindingElement(node) && node.propertyName && typescriptBinding.isStringLiteral(node.propertyName)) memberName = node.propertyName.text;
|
|
77028
|
+
else if (typescriptBinding.isPropertyAssignment(node) && typescriptBinding.isStringLiteral(node.name)) memberName = node.name.text;
|
|
77029
|
+
if (memberName && REFLECTION_NAMES.has(memberName)) hasReflection = true;
|
|
77030
|
+
if (typescriptBinding.isComputedPropertyName(node)) hasReflection = true;
|
|
77031
|
+
if (typescriptBinding.isWithStatement(node)) hasReflection = true;
|
|
77032
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
77033
|
+
calls.push(node);
|
|
77034
|
+
if (node.expression.kind === typescriptBinding.SyntaxKind.ImportKeyword) hasReflection = true;
|
|
77035
|
+
}
|
|
77036
|
+
typescriptBinding.forEachChild(node, (child) => {
|
|
77037
|
+
pendingNodes.push(child);
|
|
77038
|
+
});
|
|
77039
|
+
}
|
|
77040
|
+
return {
|
|
77041
|
+
identifiers,
|
|
77042
|
+
calls,
|
|
77043
|
+
hasReflection
|
|
77044
|
+
};
|
|
77045
|
+
};
|
|
77046
|
+
const isInertPrimitive = (expression) => {
|
|
77047
|
+
const unwrapped = unwrapTypescriptExpression(expression);
|
|
77048
|
+
return typescriptBinding.isStringLiteral(unwrapped) || typescriptBinding.isNoSubstitutionTemplateLiteral(unwrapped) || typescriptBinding.isNumericLiteral(unwrapped) || unwrapped.kind === typescriptBinding.SyntaxKind.TrueKeyword || unwrapped.kind === typescriptBinding.SyntaxKind.FalseKeyword || unwrapped.kind === typescriptBinding.SyntaxKind.NullKeyword || typescriptBinding.isPrefixUnaryExpression(unwrapped) && (unwrapped.operator === typescriptBinding.SyntaxKind.PlusToken || unwrapped.operator === typescriptBinding.SyntaxKind.MinusToken) && typescriptBinding.isNumericLiteral(unwrapped.operand);
|
|
77049
|
+
};
|
|
77050
|
+
const isAsyncZeroParameterFunction = (node) => (typescriptBinding.isArrowFunction(node) || typescriptBinding.isFunctionExpression(node)) && node.parameters.length === 0 && !(typescriptBinding.isFunctionExpression(node) && node.asteriskToken) && Boolean(node.modifiers?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.AsyncKeyword));
|
|
77051
|
+
const getSoleCall = (body) => {
|
|
77052
|
+
if (body.statements.length !== 1) return null;
|
|
77053
|
+
const statement = body.statements[0];
|
|
77054
|
+
if (!typescriptBinding.isExpressionStatement(statement)) return null;
|
|
77055
|
+
let expression = unwrapTypescriptExpression(statement.expression);
|
|
77056
|
+
if (typescriptBinding.isVoidExpression(expression)) expression = unwrapTypescriptExpression(expression.expression);
|
|
77057
|
+
return typescriptBinding.isCallExpression(expression) && !expression.questionDotToken ? expression : null;
|
|
77058
|
+
};
|
|
77059
|
+
const findDirectConst = (body, name, beforeStatement) => {
|
|
77060
|
+
for (const statement of body.statements) {
|
|
77061
|
+
if (statement === beforeStatement) return null;
|
|
77062
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
77063
|
+
if (!(statement.declarationList.flags & typescriptBinding.NodeFlags.Const)) continue;
|
|
77064
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.name.text === name) return declaration;
|
|
77065
|
+
}
|
|
77066
|
+
return null;
|
|
77067
|
+
};
|
|
77068
|
+
const hasOnlyAllowedIdentifiers = (index, name, allowedIdentifiers) => {
|
|
77069
|
+
const allowed = new Set(allowedIdentifiers);
|
|
77070
|
+
return [...index.identifiers.get(name) ?? []].every((identifier) => allowed.has(identifier));
|
|
77071
|
+
};
|
|
77072
|
+
const isNativeReactCall = (call, importedName, sourceFile, index) => {
|
|
77073
|
+
const callee = unwrapTypescriptExpression(call.expression);
|
|
77074
|
+
if (!typescriptBinding.isIdentifier(callee) || call.questionDotToken) return false;
|
|
77075
|
+
let matchingImport = null;
|
|
77076
|
+
for (const statement of sourceFile.statements) {
|
|
77077
|
+
if (!typescriptBinding.isImportDeclaration(statement)) continue;
|
|
77078
|
+
if (!typescriptBinding.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "react") continue;
|
|
77079
|
+
const clause = statement.importClause;
|
|
77080
|
+
if (!clause || clause.isTypeOnly) continue;
|
|
77081
|
+
if (clause.name || clause.namedBindings && typescriptBinding.isNamespaceImport(clause.namedBindings)) return false;
|
|
77082
|
+
if (!clause.namedBindings || !typescriptBinding.isNamedImports(clause.namedBindings)) continue;
|
|
77083
|
+
for (const specifier of clause.namedBindings.elements) {
|
|
77084
|
+
if (specifier.name.text !== callee.text) continue;
|
|
77085
|
+
if (matchingImport || specifier.isTypeOnly || (specifier.propertyName?.text ?? specifier.name.text) !== importedName || getImportModuleSource(specifier) !== "react") return false;
|
|
77086
|
+
matchingImport = specifier;
|
|
77087
|
+
}
|
|
77088
|
+
}
|
|
77089
|
+
if (!matchingImport) return false;
|
|
77090
|
+
const allowed = [matchingImport.name];
|
|
77091
|
+
if (matchingImport.propertyName && typescriptBinding.isIdentifier(matchingImport.propertyName)) allowed.push(matchingImport.propertyName);
|
|
77092
|
+
for (const candidateCall of index.calls) {
|
|
77093
|
+
const candidateCallee = unwrapTypescriptExpression(candidateCall.expression);
|
|
77094
|
+
if (typescriptBinding.isIdentifier(candidateCallee) && candidateCallee.text === callee.text) allowed.push(candidateCallee);
|
|
77095
|
+
}
|
|
77096
|
+
return hasOnlyAllowedIdentifiers(index, callee.text, allowed);
|
|
77097
|
+
};
|
|
77098
|
+
const hasDeferredLocalHelper = (helperCall, sourceFile, index) => {
|
|
77099
|
+
const helperIdentifier = unwrapTypescriptExpression(helperCall.expression);
|
|
77100
|
+
if (!typescriptBinding.isIdentifier(helperIdentifier) || helperCall.arguments.length !== 0) return false;
|
|
77101
|
+
let callbackNode = helperCall.parent;
|
|
77102
|
+
while (callbackNode && !typescriptBinding.isArrowFunction(callbackNode) && !typescriptBinding.isFunctionExpression(callbackNode)) callbackNode = callbackNode.parent;
|
|
77103
|
+
if (!callbackNode || !typescriptBinding.isBlock(callbackNode.body) || callbackNode.parameters.length !== 0 || callbackNode.modifiers?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.AsyncKeyword) || typescriptBinding.isFunctionExpression(callbackNode) && callbackNode.asteriskToken || getSoleCall(callbackNode.body) !== helperCall) return false;
|
|
77104
|
+
const effectCall = callbackNode.parent;
|
|
77105
|
+
if (!typescriptBinding.isCallExpression(effectCall) || effectCall.arguments[0] !== callbackNode || effectCall.arguments.length !== 2 || !isNativeReactCall(effectCall, "useEffect", sourceFile, index) || !typescriptBinding.isExpressionStatement(effectCall.parent) || !typescriptBinding.isBlock(effectCall.parent.parent)) return false;
|
|
77106
|
+
const ownerBody = effectCall.parent.parent;
|
|
77107
|
+
if (!typescriptBinding.isArrowFunction(ownerBody.parent) && !typescriptBinding.isFunctionExpression(ownerBody.parent) && !typescriptBinding.isFunctionDeclaration(ownerBody.parent)) return false;
|
|
77108
|
+
if (ownerBody.parent.modifiers?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.AsyncKeyword) || !typescriptBinding.isArrowFunction(ownerBody.parent) && ownerBody.parent.asteriskToken) return false;
|
|
77109
|
+
const dependencies = unwrapTypescriptExpression(effectCall.arguments[1]);
|
|
77110
|
+
if (!typescriptBinding.isArrayLiteralExpression(dependencies)) return false;
|
|
77111
|
+
const helperReferences = [helperIdentifier];
|
|
77112
|
+
for (const dependency of dependencies.elements) {
|
|
77113
|
+
const unwrappedDependency = unwrapTypescriptExpression(dependency);
|
|
77114
|
+
if (!typescriptBinding.isIdentifier(unwrappedDependency) || unwrappedDependency.text !== helperIdentifier.text) return false;
|
|
77115
|
+
helperReferences.push(unwrappedDependency);
|
|
77116
|
+
}
|
|
77117
|
+
const declaration = findDirectConst(ownerBody, helperIdentifier.text, effectCall.parent);
|
|
77118
|
+
if (!declaration?.initializer || !typescriptBinding.isIdentifier(declaration.name)) return false;
|
|
77119
|
+
helperReferences.push(declaration.name);
|
|
77120
|
+
if (!hasOnlyAllowedIdentifiers(index, helperIdentifier.text, helperReferences)) return false;
|
|
77121
|
+
let helper = unwrapTypescriptExpression(declaration.initializer);
|
|
77122
|
+
if (typescriptBinding.isCallExpression(helper)) {
|
|
77123
|
+
if (!isNativeReactCall(helper, "useCallback", sourceFile, index) || helper.arguments.length !== 2 || !typescriptBinding.isArrayLiteralExpression(helper.arguments[1]) || helper.arguments[1].elements.length !== 0) return false;
|
|
77124
|
+
helper = unwrapTypescriptExpression(helper.arguments[0]);
|
|
77125
|
+
}
|
|
77126
|
+
if (!isAsyncZeroParameterFunction(helper) || !typescriptBinding.isBlock(helper.body)) return false;
|
|
77127
|
+
if (helper.body.statements.length !== 1) return false;
|
|
77128
|
+
const tryStatement = helper.body.statements[0];
|
|
77129
|
+
if (!typescriptBinding.isTryStatement(tryStatement) || tryStatement.finallyBlock || !tryStatement.catchClause || tryStatement.catchClause.variableDeclaration) return false;
|
|
77130
|
+
const successCall = getSoleCall(tryStatement.tryBlock);
|
|
77131
|
+
const failureCall = getSoleCall(tryStatement.catchClause.block);
|
|
77132
|
+
if (!successCall || !failureCall || successCall.arguments.length !== 1 || failureCall.arguments.length !== 1) return false;
|
|
77133
|
+
const setterIdentifier = unwrapTypescriptExpression(successCall.expression);
|
|
77134
|
+
const failureSetter = unwrapTypescriptExpression(failureCall.expression);
|
|
77135
|
+
if (!typescriptBinding.isIdentifier(setterIdentifier) || !typescriptBinding.isIdentifier(failureSetter) || setterIdentifier.text !== failureSetter.text || !isInertPrimitive(failureCall.arguments[0])) return false;
|
|
77136
|
+
const awaitedValue = unwrapTypescriptExpression(successCall.arguments[0]);
|
|
77137
|
+
if (!typescriptBinding.isAwaitExpression(awaitedValue)) return false;
|
|
77138
|
+
const producerCall = unwrapTypescriptExpression(awaitedValue.expression);
|
|
77139
|
+
if (!typescriptBinding.isCallExpression(producerCall) || producerCall.questionDotToken || producerCall.arguments.length !== 0) return false;
|
|
77140
|
+
const producerIdentifier = unwrapTypescriptExpression(producerCall.expression);
|
|
77141
|
+
if (!typescriptBinding.isIdentifier(producerIdentifier)) return false;
|
|
77142
|
+
const producerDeclaration = findDirectConst(ownerBody, producerIdentifier.text, effectCall.parent);
|
|
77143
|
+
if (!producerDeclaration?.initializer || !typescriptBinding.isIdentifier(producerDeclaration.name)) return false;
|
|
77144
|
+
const producer = unwrapTypescriptExpression(producerDeclaration.initializer);
|
|
77145
|
+
if (!isAsyncZeroParameterFunction(producer)) return false;
|
|
77146
|
+
let producedValue;
|
|
77147
|
+
if (typescriptBinding.isBlock(producer.body)) {
|
|
77148
|
+
if (producer.body.statements.length !== 1) return false;
|
|
77149
|
+
const statement = producer.body.statements[0];
|
|
77150
|
+
if (!typescriptBinding.isReturnStatement(statement)) return false;
|
|
77151
|
+
producedValue = statement.expression;
|
|
77152
|
+
} else producedValue = producer.body;
|
|
77153
|
+
if (!producedValue || !isInertPrimitive(producedValue)) return false;
|
|
77154
|
+
if (!hasOnlyAllowedIdentifiers(index, producerIdentifier.text, [producerDeclaration.name, producerIdentifier])) return false;
|
|
77155
|
+
for (const statement of ownerBody.statements) {
|
|
77156
|
+
if (statement === effectCall.parent) return false;
|
|
77157
|
+
if (!typescriptBinding.isVariableStatement(statement) || !(statement.declarationList.flags & typescriptBinding.NodeFlags.Const)) continue;
|
|
77158
|
+
for (const stateDeclaration of statement.declarationList.declarations) {
|
|
77159
|
+
if (!typescriptBinding.isArrayBindingPattern(stateDeclaration.name) || stateDeclaration.name.elements.length !== 2 || !stateDeclaration.initializer) continue;
|
|
77160
|
+
const setterBinding = stateDeclaration.name.elements[1];
|
|
77161
|
+
if (typescriptBinding.isOmittedExpression(setterBinding) || !typescriptBinding.isIdentifier(setterBinding.name) || setterBinding.name.text !== setterIdentifier.text || setterBinding.initializer || setterBinding.dotDotDotToken || setterBinding.propertyName) continue;
|
|
77162
|
+
const stateInitializer = unwrapTypescriptExpression(stateDeclaration.initializer);
|
|
77163
|
+
if (!typescriptBinding.isCallExpression(stateInitializer) || !isNativeReactCall(stateInitializer, "useState", sourceFile, index)) continue;
|
|
77164
|
+
return hasOnlyAllowedIdentifiers(index, setterIdentifier.text, [
|
|
77165
|
+
setterBinding.name,
|
|
77166
|
+
setterIdentifier,
|
|
77167
|
+
failureSetter
|
|
77168
|
+
]);
|
|
77169
|
+
}
|
|
77170
|
+
}
|
|
77171
|
+
return false;
|
|
77172
|
+
};
|
|
77173
|
+
const createDeferredEffectStateDiagnosticChecker = (rootDirectory) => {
|
|
77174
|
+
const parsedFiles = /* @__PURE__ */ new Map();
|
|
77175
|
+
const readAndParse = (filename) => {
|
|
77176
|
+
const cached = parsedFiles.get(filename);
|
|
77177
|
+
if (cached !== void 0) return cached;
|
|
77178
|
+
let parsed;
|
|
77179
|
+
try {
|
|
77180
|
+
const sourceText = fs$1$2.readFileSync(filename, "utf8");
|
|
77181
|
+
const sourceFile = typescriptBinding.createSourceFile(filename, sourceText, typescriptBinding.ScriptTarget.Latest, true, getTypescriptScriptKind(filename));
|
|
77182
|
+
parsed = "parseDiagnostics" in sourceFile && Array.isArray(sourceFile.parseDiagnostics) && sourceFile.parseDiagnostics.length > 0 ? null : {
|
|
77183
|
+
sourceText,
|
|
77184
|
+
sourceFile,
|
|
77185
|
+
index: collectEffectSourceIndex(sourceFile)
|
|
77186
|
+
};
|
|
77187
|
+
} catch {
|
|
77188
|
+
parsed = null;
|
|
77189
|
+
}
|
|
77190
|
+
parsedFiles.set(filename, parsed);
|
|
77191
|
+
return parsed;
|
|
77192
|
+
};
|
|
77193
|
+
return (diagnostic) => {
|
|
77194
|
+
if (diagnostic.code !== "react-hooks-js(set-state-in-effect)") return false;
|
|
77195
|
+
const span = diagnostic.labels[0]?.span;
|
|
77196
|
+
if (!span || !Number.isInteger(span.offset) || !Number.isInteger(span.length) || span.offset < 0 || span.length <= 0) return false;
|
|
77197
|
+
const parsed = readAndParse(path$1$1.resolve(rootDirectory, diagnostic.filename));
|
|
77198
|
+
if (!parsed || parsed.index.hasReflection) return false;
|
|
77199
|
+
const { sourceText, sourceFile, index } = parsed;
|
|
77200
|
+
const calleeOffset = getUtf16Offset(sourceText, span.offset);
|
|
77201
|
+
const helperCall = index.calls.find((call) => {
|
|
77202
|
+
const callee = unwrapTypescriptExpression(call.expression);
|
|
77203
|
+
return typescriptBinding.isIdentifier(callee) && callee.getStart(sourceFile) === calleeOffset;
|
|
77204
|
+
});
|
|
77205
|
+
if (!helperCall || helperCall.questionDotToken) return false;
|
|
77206
|
+
const callee = unwrapTypescriptExpression(helperCall.expression);
|
|
77207
|
+
return Buffer.byteLength(sourceText.slice(0, calleeOffset)) === span.offset && Buffer.byteLength(callee.getText(sourceFile)) === span.length && hasDeferredLocalHelper(helperCall, sourceFile, index);
|
|
77208
|
+
};
|
|
77209
|
+
};
|
|
76387
77210
|
const MANUAL_MEMOIZATION_PLUGIN = "react-doctor";
|
|
76388
77211
|
const MANUAL_MEMOIZATION_RULE = "react-compiler-no-manual-memoization";
|
|
76389
77212
|
const REACT_COMPILER_PLUGIN = "react-hooks-js";
|
|
@@ -76672,7 +77495,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath,
|
|
|
76672
77495
|
return minified;
|
|
76673
77496
|
};
|
|
76674
77497
|
const readContextRanges = createDiagnosticContextReader(diagnosticContextDirectory);
|
|
76675
|
-
|
|
77498
|
+
const sourceMappedDiagnostics = parsed.diagnostics.flatMap((unbridgedDiagnostic) => {
|
|
76676
77499
|
if (!isMappableOxlintDiagnostic(unbridgedDiagnostic)) return [];
|
|
76677
77500
|
const rawDiagnostic = bridgeReactCompilerDiagnostic(unbridgedDiagnostic);
|
|
76678
77501
|
const { plugin, rule } = parseRuleCode(rawDiagnostic.code);
|
|
@@ -76698,7 +77521,9 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath,
|
|
|
76698
77521
|
labels,
|
|
76699
77522
|
contextRanges: []
|
|
76700
77523
|
}];
|
|
76701
|
-
})
|
|
77524
|
+
});
|
|
77525
|
+
const shouldSuppressDeferredEffectStateDiagnostic = createDeferredEffectStateDiagnosticChecker(rootDirectory);
|
|
77526
|
+
return suppressMemoizationInBailedOutFunctions(sourceMappedDiagnostics.filter((diagnostic) => isLintableSourceFile(resolveSourceFilename(diagnostic.filename)) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressDeferredEffectStateDiagnostic(diagnostic) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
|
|
76702
77527
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
76703
77528
|
const primaryLabel = diagnostic.labels[0];
|
|
76704
77529
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
@@ -77599,7 +78424,11 @@ const runOxlint = async (options) => {
|
|
|
77599
78424
|
const adoptableConfigPaths = detectedConfigPaths.filter(canOxlintExtendConfig);
|
|
77600
78425
|
const adoptedSettings = detectedConfigPaths.length > 0 ? readAdoptedLintConfigSettings(detectedConfigPaths) : {};
|
|
77601
78426
|
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
77602
|
-
const
|
|
78427
|
+
const lintIgnorePolicy = collectLintIgnorePolicy(rootDirectory);
|
|
78428
|
+
const restoreDisableDirectives = await neutralizeDisableDirectives(rootDirectory, includePaths ?? options.precomputedSourceFiles?.map((sourceFile) => sourceFile.path), {
|
|
78429
|
+
recoverOnly: respectInlineDisables,
|
|
78430
|
+
includesFile: lintIgnorePolicy?.includesFile
|
|
78431
|
+
});
|
|
77603
78432
|
const configDirectory = fs$1$2.mkdtempSync(path$1$1.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
77604
78433
|
const configPath = path$1$1.join(configDirectory, "oxlintrc.json");
|
|
77605
78434
|
const workingDirectory = fs$1$2.existsSync(path$1$1.join(rootDirectory, "oxlint-suppressions.json")) ? configDirectory : void 0;
|
|
@@ -77625,10 +78454,10 @@ const runOxlint = async (options) => {
|
|
|
77625
78454
|
}
|
|
77626
78455
|
}
|
|
77627
78456
|
}
|
|
77628
|
-
const combinedPatterns =
|
|
77629
|
-
if (
|
|
78457
|
+
const combinedPatterns = lintIgnorePolicy?.patterns ?? [];
|
|
78458
|
+
if (lintIgnorePolicy) {
|
|
77630
78459
|
const combinedIgnorePath = path$1$1.join(configDirectory, "combined.ignore");
|
|
77631
|
-
fs$1$2.writeFileSync(combinedIgnorePath,
|
|
78460
|
+
fs$1$2.writeFileSync(combinedIgnorePath, "");
|
|
77632
78461
|
sharedArgs.push("--ignore-path", combinedIgnorePath);
|
|
77633
78462
|
}
|
|
77634
78463
|
const lintWorkerCount = resolveScanConcurrency(options.concurrency ?? 1);
|
|
@@ -77644,8 +78473,9 @@ const runOxlint = async (options) => {
|
|
|
77644
78473
|
];
|
|
77645
78474
|
await yieldToEventLoop();
|
|
77646
78475
|
const sizedScanFiles = options.precomputedSourceFiles ?? (includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null);
|
|
77647
|
-
const
|
|
77648
|
-
const
|
|
78476
|
+
const discoveredFiles = sizedScanFiles === null ? includePaths ?? [] : sizedScanFiles.map((entry) => entry.path);
|
|
78477
|
+
const candidateFiles = lintIgnorePolicy ? discoveredFiles.filter(lintIgnorePolicy.includesFile) : discoveredFiles;
|
|
78478
|
+
const projectIndexModuleSources = includePaths === void 0 && options.deadlineEpochMs === void 0 ? await collectProjectIndexModuleSources(rootDirectory, discoveredFiles) : void 0;
|
|
77649
78479
|
unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
|
|
77650
78480
|
rootDirectory,
|
|
77651
78481
|
candidateFiles
|
|
@@ -79091,10 +79921,11 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
79091
79921
|
const lintFailureState = yield* get$2(lintFailure);
|
|
79092
79922
|
yield* afterLint(lintFailureState.didFail);
|
|
79093
79923
|
if (lintFailureState.didFail) yield* scanProgress.fail(formatLintFailText(lintFailureState.reasonTag, process.version));
|
|
79094
|
-
const
|
|
79095
|
-
const
|
|
79096
|
-
const
|
|
79097
|
-
const
|
|
79924
|
+
const lintFileCoverage = lintFileCoverageState.value;
|
|
79925
|
+
const candidateFiles = lintFileCoverage === null ? [] : [...new Set(lintFileCoverage.candidateFiles.map((filePath) => toNormalizedRelativePath(filePath, scanDirectory)))];
|
|
79926
|
+
const analyzedFiles = lintFileCoverage === null ? [] : [...new Set(lintFileCoverage.analyzedFiles.map((filePath) => toNormalizedRelativePath(filePath, scanDirectory)))].sort();
|
|
79927
|
+
const totalFileCount = lintFileCoverage === null ? lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount) : candidateFiles.length;
|
|
79928
|
+
const scannedFilePaths = input.suppressScanSummary ? lintFileCoverage === null ? fallbackScannedFilePaths : candidateFiles.map((filePath) => path$1$1.resolve(scanDirectory, filePath)) : [];
|
|
79098
79929
|
const scannedFilesLabel = `${totalFileCount} ${totalFileCount === 1 ? "file" : "files"}`;
|
|
79099
79930
|
let maintainabilityCollected = [];
|
|
79100
79931
|
if (lintFailureState.didFail) yield* interrupt(maintainabilityFiber);
|
|
@@ -79330,15 +80161,37 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
79330
80161
|
materializedFiles.push(relativePath);
|
|
79331
80162
|
}
|
|
79332
80163
|
yield* sync(() => {
|
|
79333
|
-
|
|
79334
|
-
|
|
79335
|
-
|
|
79336
|
-
|
|
79337
|
-
|
|
79338
|
-
|
|
79339
|
-
|
|
80164
|
+
const sourceDirectory = path.resolve(input.directory);
|
|
80165
|
+
const projectDirectories = new Set(["", ...input.configSubdirectories ?? []]);
|
|
80166
|
+
const intermediateDirectories = /* @__PURE__ */ new Set();
|
|
80167
|
+
for (const subdirectory of projectDirectories) {
|
|
80168
|
+
const projectDirectory = path.resolve(sourceDirectory, subdirectory);
|
|
80169
|
+
if (!isPathInsideDirectory(projectDirectory, sourceDirectory)) continue;
|
|
80170
|
+
for (const ancestor of ancestorDirectories(projectDirectory, { includeStart: false })) {
|
|
80171
|
+
if (!isPathInsideDirectory(ancestor, sourceDirectory)) break;
|
|
80172
|
+
const relativeDirectory = path.relative(sourceDirectory, ancestor);
|
|
80173
|
+
if (!projectDirectories.has(relativeDirectory)) intermediateDirectories.add(relativeDirectory);
|
|
79340
80174
|
}
|
|
79341
80175
|
}
|
|
80176
|
+
const copyConfigs = (subdirectory, filenames) => {
|
|
80177
|
+
for (const configFilename of filenames) {
|
|
80178
|
+
const sourcePath = path.join(input.directory, subdirectory, configFilename);
|
|
80179
|
+
const targetPath = path.resolve(resolvedTempDirectory, subdirectory, configFilename);
|
|
80180
|
+
if (!isPathInsideDirectory(targetPath, resolvedTempDirectory)) continue;
|
|
80181
|
+
if (isFile(sourcePath) && !fs.existsSync(targetPath)) {
|
|
80182
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
80183
|
+
fs.cpSync(sourcePath, targetPath);
|
|
80184
|
+
}
|
|
80185
|
+
}
|
|
80186
|
+
};
|
|
80187
|
+
for (const subdirectory of projectDirectories) copyConfigs(subdirectory, STAGED_FILES_PROJECT_CONFIG_FILENAMES);
|
|
80188
|
+
for (const subdirectory of intermediateDirectories) copyConfigs(subdirectory, [
|
|
80189
|
+
"package.json",
|
|
80190
|
+
"pnpm-workspace.yaml",
|
|
80191
|
+
"nx.json",
|
|
80192
|
+
...LINT_IGNORE_STYLE_FILENAMES,
|
|
80193
|
+
LINT_LINGUIST_FILENAME
|
|
80194
|
+
]);
|
|
79342
80195
|
});
|
|
79343
80196
|
return {
|
|
79344
80197
|
tempDirectory: input.tempDirectory,
|
|
@@ -79996,4 +80849,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
79996
80849
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
79997
80850
|
|
|
79998
80851
|
//# sourceMappingURL=index.js.map
|
|
79999
|
-
//# debugId=
|
|
80852
|
+
//# debugId=835688e2-3e41-50bb-9c66-fa5b45d875d1
|