react-doctor 0.9.1 → 0.9.2-dev.1098b9c
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 +3 -1
- package/dist/cli.js +2057 -279
- package/dist/index.d.ts +10 -4
- package/dist/index.js +1739 -180
- package/dist/lsp.js +1747 -181
- package/dist/{run-scan-app-DZ5jGWFf.js → run-scan-app-C9MJnVwv.js} +281 -210
- package/package.json +9 -7
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]="18c61424-4926-5cae-8f2a-6001534ea755")}catch(e){}}();
|
|
3
3
|
import { i as __toESM$1, r as __require, t as __commonJSMin$1 } from "./chunk-ChKA3wi6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
|
|
@@ -11,14 +11,16 @@ import * as Path from "node:path";
|
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import * as NodeChildProcess from "node:child_process";
|
|
13
13
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
14
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
14
15
|
import ts from "typescript";
|
|
16
|
+
import * as NodeUrl from "node:url";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
15
18
|
import * as OS from "node:os";
|
|
16
19
|
import os from "node:os";
|
|
17
20
|
import { parseJSON5 } from "confbox";
|
|
18
|
-
import * as NodeUrl from "node:url";
|
|
19
|
-
import { fileURLToPath } from "node:url";
|
|
20
21
|
import { createJiti } from "jiti";
|
|
21
22
|
import { ANALYZED_MANIFEST_FILENAMES, DEFAULT_EXTENSIONS } from "deslop-js/analyzed-inputs";
|
|
23
|
+
import { convertToTSX } from "@astrojs/compiler/sync";
|
|
22
24
|
import { gzipSync } from "node:zlib";
|
|
23
25
|
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.70/node_modules/effect/dist/Pipeable.js
|
|
24
26
|
/**
|
|
@@ -10261,7 +10263,7 @@ const Number$4 = globalThis.Number;
|
|
|
10261
10263
|
* @category constructors
|
|
10262
10264
|
* @since 2.0.0
|
|
10263
10265
|
*/
|
|
10264
|
-
const parse = (s) => {
|
|
10266
|
+
const parse$1 = (s) => {
|
|
10265
10267
|
if (s === "NaN") return some(NaN);
|
|
10266
10268
|
if (s === "Infinity") return some(Infinity);
|
|
10267
10269
|
if (s === "-Infinity") return some(-Infinity);
|
|
@@ -14303,12 +14305,12 @@ TaggedError("EncodingError");
|
|
|
14303
14305
|
//#endregion
|
|
14304
14306
|
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.70/node_modules/effect/dist/internal/schema/annotations.js
|
|
14305
14307
|
/** @internal */
|
|
14306
|
-
function resolve(ast) {
|
|
14308
|
+
function resolve$1(ast) {
|
|
14307
14309
|
return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations;
|
|
14308
14310
|
}
|
|
14309
14311
|
/** @internal */
|
|
14310
14312
|
function resolveAt(key) {
|
|
14311
|
-
return (ast) => resolve(ast)?.[key];
|
|
14313
|
+
return (ast) => resolve$1(ast)?.[key];
|
|
14312
14314
|
}
|
|
14313
14315
|
/** @internal */
|
|
14314
14316
|
const resolveIdentifier = /* @__PURE__ */ resolveAt("identifier");
|
|
@@ -18060,7 +18062,7 @@ function asSync(parser) {
|
|
|
18060
18062
|
}
|
|
18061
18063
|
const recur$1 = /* @__PURE__ */ memoize((ast) => {
|
|
18062
18064
|
let parser;
|
|
18063
|
-
const astOptions = resolve(ast)?.["parseOptions"];
|
|
18065
|
+
const astOptions = resolve$1(ast)?.["parseOptions"];
|
|
18064
18066
|
if (!ast.context && !ast.encoding && !ast.checks) return (ou, options) => {
|
|
18065
18067
|
parser ??= ast.getParser(recur$1);
|
|
18066
18068
|
if (astOptions) options = {
|
|
@@ -57665,7 +57667,7 @@ var UrlParamsError = class extends TaggedError("UrlParamsError") {};
|
|
|
57665
57667
|
* @category converting
|
|
57666
57668
|
* @since 4.0.0
|
|
57667
57669
|
*/
|
|
57668
|
-
const makeUrl = (url, params, hash) => {
|
|
57670
|
+
const makeUrl$1 = (url, params, hash) => {
|
|
57669
57671
|
try {
|
|
57670
57672
|
const urlInstance = new URL(url, baseUrl());
|
|
57671
57673
|
for (let i = 0; i < params.params.length; i++) {
|
|
@@ -58299,7 +58301,7 @@ const Proto$2 = {
|
|
|
58299
58301
|
const make$10 = (f) => makeWith$1((effect) => flatMap$2(effect, (request) => withFiber((fiber) => {
|
|
58300
58302
|
const scopedController = scopedRequests.get(request);
|
|
58301
58303
|
const controller = scopedController ?? new AbortController();
|
|
58302
|
-
const urlResult = makeUrl(request.url, request.urlParams, getOrUndefined(request.hash));
|
|
58304
|
+
const urlResult = makeUrl$1(request.url, request.urlParams, getOrUndefined(request.hash));
|
|
58303
58305
|
if (isFailure(urlResult)) return fail$4(new HttpClientError({ reason: new InvalidUrlError({
|
|
58304
58306
|
request,
|
|
58305
58307
|
cause: urlResult.failure
|
|
@@ -58738,7 +58740,7 @@ const layer$7 = (loggers, options) => effect(CurrentLoggers, withFiber$1(fnUntra
|
|
|
58738
58740
|
* @since 4.0.0
|
|
58739
58741
|
*/
|
|
58740
58742
|
const policy = /* @__PURE__ */ forever$1.pipe(passthrough$2, /* @__PURE__ */ addDelay((error) => {
|
|
58741
|
-
if (isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429) return succeed$2(seconds(fromUndefinedOr(error.reason.response.headers["retry-after"]).pipe(flatMap$5(parse), getOrElse$1(() => 5))));
|
|
58743
|
+
if (isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429) return succeed$2(seconds(fromUndefinedOr(error.reason.response.headers["retry-after"]).pipe(flatMap$5(parse$1), getOrElse$1(() => 5))));
|
|
58742
58744
|
return succeed$2(seconds(1));
|
|
58743
58745
|
}));
|
|
58744
58746
|
/**
|
|
@@ -61380,6 +61382,428 @@ const layer = /* @__PURE__ */ succeed$3(Path$1)({
|
|
|
61380
61382
|
toFileUrl
|
|
61381
61383
|
});
|
|
61382
61384
|
//#endregion
|
|
61385
|
+
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
61386
|
+
var comma = ",".charCodeAt(0);
|
|
61387
|
+
";".charCodeAt(0);
|
|
61388
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
61389
|
+
var intToChar = new Uint8Array(64);
|
|
61390
|
+
var charToInt = new Uint8Array(128);
|
|
61391
|
+
for (let i = 0; i < chars.length; i++) {
|
|
61392
|
+
const c = chars.charCodeAt(i);
|
|
61393
|
+
intToChar[i] = c;
|
|
61394
|
+
charToInt[c] = i;
|
|
61395
|
+
}
|
|
61396
|
+
function decodeInteger(reader, relative) {
|
|
61397
|
+
let value = 0;
|
|
61398
|
+
let shift = 0;
|
|
61399
|
+
let integer = 0;
|
|
61400
|
+
do {
|
|
61401
|
+
integer = charToInt[reader.next()];
|
|
61402
|
+
value |= (integer & 31) << shift;
|
|
61403
|
+
shift += 5;
|
|
61404
|
+
} while (integer & 32);
|
|
61405
|
+
const shouldNegate = value & 1;
|
|
61406
|
+
value >>>= 1;
|
|
61407
|
+
if (shouldNegate) value = -2147483648 | -value;
|
|
61408
|
+
return relative + value;
|
|
61409
|
+
}
|
|
61410
|
+
function hasMoreVlq(reader, max) {
|
|
61411
|
+
if (reader.pos >= max) return false;
|
|
61412
|
+
return reader.peek() !== comma;
|
|
61413
|
+
}
|
|
61414
|
+
var StringReader = class {
|
|
61415
|
+
constructor(buffer) {
|
|
61416
|
+
this.pos = 0;
|
|
61417
|
+
this.buffer = buffer;
|
|
61418
|
+
}
|
|
61419
|
+
next() {
|
|
61420
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
61421
|
+
}
|
|
61422
|
+
peek() {
|
|
61423
|
+
return this.buffer.charCodeAt(this.pos);
|
|
61424
|
+
}
|
|
61425
|
+
indexOf(char) {
|
|
61426
|
+
const { buffer, pos } = this;
|
|
61427
|
+
const idx = buffer.indexOf(char, pos);
|
|
61428
|
+
return idx === -1 ? buffer.length : idx;
|
|
61429
|
+
}
|
|
61430
|
+
};
|
|
61431
|
+
function decode(mappings) {
|
|
61432
|
+
const { length } = mappings;
|
|
61433
|
+
const reader = new StringReader(mappings);
|
|
61434
|
+
const decoded = [];
|
|
61435
|
+
let genColumn = 0;
|
|
61436
|
+
let sourcesIndex = 0;
|
|
61437
|
+
let sourceLine = 0;
|
|
61438
|
+
let sourceColumn = 0;
|
|
61439
|
+
let namesIndex = 0;
|
|
61440
|
+
do {
|
|
61441
|
+
const semi = reader.indexOf(";");
|
|
61442
|
+
const line = [];
|
|
61443
|
+
let sorted = true;
|
|
61444
|
+
let lastCol = 0;
|
|
61445
|
+
genColumn = 0;
|
|
61446
|
+
while (reader.pos < semi) {
|
|
61447
|
+
let seg;
|
|
61448
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
61449
|
+
if (genColumn < lastCol) sorted = false;
|
|
61450
|
+
lastCol = genColumn;
|
|
61451
|
+
if (hasMoreVlq(reader, semi)) {
|
|
61452
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
61453
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
61454
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
61455
|
+
if (hasMoreVlq(reader, semi)) {
|
|
61456
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
61457
|
+
seg = [
|
|
61458
|
+
genColumn,
|
|
61459
|
+
sourcesIndex,
|
|
61460
|
+
sourceLine,
|
|
61461
|
+
sourceColumn,
|
|
61462
|
+
namesIndex
|
|
61463
|
+
];
|
|
61464
|
+
} else seg = [
|
|
61465
|
+
genColumn,
|
|
61466
|
+
sourcesIndex,
|
|
61467
|
+
sourceLine,
|
|
61468
|
+
sourceColumn
|
|
61469
|
+
];
|
|
61470
|
+
} else seg = [genColumn];
|
|
61471
|
+
line.push(seg);
|
|
61472
|
+
reader.pos++;
|
|
61473
|
+
}
|
|
61474
|
+
if (!sorted) sort(line);
|
|
61475
|
+
decoded.push(line);
|
|
61476
|
+
reader.pos = semi + 1;
|
|
61477
|
+
} while (reader.pos <= length);
|
|
61478
|
+
return decoded;
|
|
61479
|
+
}
|
|
61480
|
+
function sort(line) {
|
|
61481
|
+
line.sort(sortComparator$1);
|
|
61482
|
+
}
|
|
61483
|
+
function sortComparator$1(a, b) {
|
|
61484
|
+
return a[0] - b[0];
|
|
61485
|
+
}
|
|
61486
|
+
//#endregion
|
|
61487
|
+
//#region ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
|
|
61488
|
+
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
61489
|
+
/**
|
|
61490
|
+
* Matches the parts of a URL:
|
|
61491
|
+
* 1. Scheme, including ":", guaranteed.
|
|
61492
|
+
* 2. User/password, including "@", optional.
|
|
61493
|
+
* 3. Host, guaranteed.
|
|
61494
|
+
* 4. Port, including ":", optional.
|
|
61495
|
+
* 5. Path, including "/", optional.
|
|
61496
|
+
* 6. Query, including "?", optional.
|
|
61497
|
+
* 7. Hash, including "#", optional.
|
|
61498
|
+
*/
|
|
61499
|
+
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
61500
|
+
/**
|
|
61501
|
+
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
|
|
61502
|
+
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
|
|
61503
|
+
*
|
|
61504
|
+
* 1. Host, optional.
|
|
61505
|
+
* 2. Path, which may include "/", guaranteed.
|
|
61506
|
+
* 3. Query, including "?", optional.
|
|
61507
|
+
* 4. Hash, including "#", optional.
|
|
61508
|
+
*/
|
|
61509
|
+
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
61510
|
+
function isAbsoluteUrl(input) {
|
|
61511
|
+
return schemeRegex.test(input);
|
|
61512
|
+
}
|
|
61513
|
+
function isSchemeRelativeUrl(input) {
|
|
61514
|
+
return input.startsWith("//");
|
|
61515
|
+
}
|
|
61516
|
+
function isAbsolutePath(input) {
|
|
61517
|
+
return input.startsWith("/");
|
|
61518
|
+
}
|
|
61519
|
+
function isFileUrl(input) {
|
|
61520
|
+
return input.startsWith("file:");
|
|
61521
|
+
}
|
|
61522
|
+
function isRelative(input) {
|
|
61523
|
+
return /^[.?#]/.test(input);
|
|
61524
|
+
}
|
|
61525
|
+
function parseAbsoluteUrl(input) {
|
|
61526
|
+
const match = urlRegex.exec(input);
|
|
61527
|
+
return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
|
|
61528
|
+
}
|
|
61529
|
+
function parseFileUrl(input) {
|
|
61530
|
+
const match = fileRegex.exec(input);
|
|
61531
|
+
const path = match[2];
|
|
61532
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
|
|
61533
|
+
}
|
|
61534
|
+
function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
61535
|
+
return {
|
|
61536
|
+
scheme,
|
|
61537
|
+
user,
|
|
61538
|
+
host,
|
|
61539
|
+
port,
|
|
61540
|
+
path,
|
|
61541
|
+
query,
|
|
61542
|
+
hash,
|
|
61543
|
+
type: 7
|
|
61544
|
+
};
|
|
61545
|
+
}
|
|
61546
|
+
function parseUrl(input) {
|
|
61547
|
+
if (isSchemeRelativeUrl(input)) {
|
|
61548
|
+
const url = parseAbsoluteUrl("http:" + input);
|
|
61549
|
+
url.scheme = "";
|
|
61550
|
+
url.type = 6;
|
|
61551
|
+
return url;
|
|
61552
|
+
}
|
|
61553
|
+
if (isAbsolutePath(input)) {
|
|
61554
|
+
const url = parseAbsoluteUrl("http://foo.com" + input);
|
|
61555
|
+
url.scheme = "";
|
|
61556
|
+
url.host = "";
|
|
61557
|
+
url.type = 5;
|
|
61558
|
+
return url;
|
|
61559
|
+
}
|
|
61560
|
+
if (isFileUrl(input)) return parseFileUrl(input);
|
|
61561
|
+
if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
|
|
61562
|
+
const url = parseAbsoluteUrl("http://foo.com/" + input);
|
|
61563
|
+
url.scheme = "";
|
|
61564
|
+
url.host = "";
|
|
61565
|
+
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
61566
|
+
return url;
|
|
61567
|
+
}
|
|
61568
|
+
function stripPathFilename(path) {
|
|
61569
|
+
if (path.endsWith("/..")) return path;
|
|
61570
|
+
const index = path.lastIndexOf("/");
|
|
61571
|
+
return path.slice(0, index + 1);
|
|
61572
|
+
}
|
|
61573
|
+
function mergePaths(url, base) {
|
|
61574
|
+
normalizePath(base, base.type);
|
|
61575
|
+
if (url.path === "/") url.path = base.path;
|
|
61576
|
+
else url.path = stripPathFilename(base.path) + url.path;
|
|
61577
|
+
}
|
|
61578
|
+
/**
|
|
61579
|
+
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
|
|
61580
|
+
* "foo/.". We need to normalize to a standard representation.
|
|
61581
|
+
*/
|
|
61582
|
+
function normalizePath(url, type) {
|
|
61583
|
+
const rel = type <= 4;
|
|
61584
|
+
const pieces = url.path.split("/");
|
|
61585
|
+
let pointer = 1;
|
|
61586
|
+
let positive = 0;
|
|
61587
|
+
let addTrailingSlash = false;
|
|
61588
|
+
for (let i = 1; i < pieces.length; i++) {
|
|
61589
|
+
const piece = pieces[i];
|
|
61590
|
+
if (!piece) {
|
|
61591
|
+
addTrailingSlash = true;
|
|
61592
|
+
continue;
|
|
61593
|
+
}
|
|
61594
|
+
addTrailingSlash = false;
|
|
61595
|
+
if (piece === ".") continue;
|
|
61596
|
+
if (piece === "..") {
|
|
61597
|
+
if (positive) {
|
|
61598
|
+
addTrailingSlash = true;
|
|
61599
|
+
positive--;
|
|
61600
|
+
pointer--;
|
|
61601
|
+
} else if (rel) pieces[pointer++] = piece;
|
|
61602
|
+
continue;
|
|
61603
|
+
}
|
|
61604
|
+
pieces[pointer++] = piece;
|
|
61605
|
+
positive++;
|
|
61606
|
+
}
|
|
61607
|
+
let path = "";
|
|
61608
|
+
for (let i = 1; i < pointer; i++) path += "/" + pieces[i];
|
|
61609
|
+
if (!path || addTrailingSlash && !path.endsWith("/..")) path += "/";
|
|
61610
|
+
url.path = path;
|
|
61611
|
+
}
|
|
61612
|
+
/**
|
|
61613
|
+
* Attempts to resolve `input` URL/path relative to `base`.
|
|
61614
|
+
*/
|
|
61615
|
+
function resolve(input, base) {
|
|
61616
|
+
if (!input && !base) return "";
|
|
61617
|
+
const url = parseUrl(input);
|
|
61618
|
+
let inputType = url.type;
|
|
61619
|
+
if (base && inputType !== 7) {
|
|
61620
|
+
const baseUrl = parseUrl(base);
|
|
61621
|
+
const baseType = baseUrl.type;
|
|
61622
|
+
switch (inputType) {
|
|
61623
|
+
case 1: url.hash = baseUrl.hash;
|
|
61624
|
+
case 2: url.query = baseUrl.query;
|
|
61625
|
+
case 3:
|
|
61626
|
+
case 4: mergePaths(url, baseUrl);
|
|
61627
|
+
case 5:
|
|
61628
|
+
url.user = baseUrl.user;
|
|
61629
|
+
url.host = baseUrl.host;
|
|
61630
|
+
url.port = baseUrl.port;
|
|
61631
|
+
case 6: url.scheme = baseUrl.scheme;
|
|
61632
|
+
}
|
|
61633
|
+
if (baseType > inputType) inputType = baseType;
|
|
61634
|
+
}
|
|
61635
|
+
normalizePath(url, inputType);
|
|
61636
|
+
const queryHash = url.query + url.hash;
|
|
61637
|
+
switch (inputType) {
|
|
61638
|
+
case 2:
|
|
61639
|
+
case 3: return queryHash;
|
|
61640
|
+
case 4: {
|
|
61641
|
+
const path = url.path.slice(1);
|
|
61642
|
+
if (!path) return queryHash || ".";
|
|
61643
|
+
if (isRelative(base || input) && !isRelative(path)) return "./" + path + queryHash;
|
|
61644
|
+
return path + queryHash;
|
|
61645
|
+
}
|
|
61646
|
+
case 5: return url.path + queryHash;
|
|
61647
|
+
default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
|
|
61648
|
+
}
|
|
61649
|
+
}
|
|
61650
|
+
//#endregion
|
|
61651
|
+
//#region ../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
|
|
61652
|
+
function stripFilename(path) {
|
|
61653
|
+
if (!path) return "";
|
|
61654
|
+
const index = path.lastIndexOf("/");
|
|
61655
|
+
return path.slice(0, index + 1);
|
|
61656
|
+
}
|
|
61657
|
+
function resolver(mapUrl, sourceRoot) {
|
|
61658
|
+
const from = stripFilename(mapUrl);
|
|
61659
|
+
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
61660
|
+
return (source) => resolve(prefix + (source || ""), from);
|
|
61661
|
+
}
|
|
61662
|
+
var COLUMN = 0;
|
|
61663
|
+
var SOURCES_INDEX = 1;
|
|
61664
|
+
var SOURCE_LINE = 2;
|
|
61665
|
+
var SOURCE_COLUMN = 3;
|
|
61666
|
+
var NAMES_INDEX = 4;
|
|
61667
|
+
function maybeSort(mappings, owned) {
|
|
61668
|
+
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
61669
|
+
if (unsortedIndex === mappings.length) return mappings;
|
|
61670
|
+
if (!owned) mappings = mappings.slice();
|
|
61671
|
+
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) mappings[i] = sortSegments(mappings[i], owned);
|
|
61672
|
+
return mappings;
|
|
61673
|
+
}
|
|
61674
|
+
function nextUnsortedSegmentLine(mappings, start) {
|
|
61675
|
+
for (let i = start; i < mappings.length; i++) if (!isSorted(mappings[i])) return i;
|
|
61676
|
+
return mappings.length;
|
|
61677
|
+
}
|
|
61678
|
+
function isSorted(line) {
|
|
61679
|
+
for (let j = 1; j < line.length; j++) if (line[j][COLUMN] < line[j - 1][COLUMN]) return false;
|
|
61680
|
+
return true;
|
|
61681
|
+
}
|
|
61682
|
+
function sortSegments(line, owned) {
|
|
61683
|
+
if (!owned) line = line.slice();
|
|
61684
|
+
return line.sort(sortComparator);
|
|
61685
|
+
}
|
|
61686
|
+
function sortComparator(a, b) {
|
|
61687
|
+
return a[COLUMN] - b[COLUMN];
|
|
61688
|
+
}
|
|
61689
|
+
var found = false;
|
|
61690
|
+
function binarySearch(haystack, needle, low, high) {
|
|
61691
|
+
while (low <= high) {
|
|
61692
|
+
const mid = low + (high - low >> 1);
|
|
61693
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
61694
|
+
if (cmp === 0) {
|
|
61695
|
+
found = true;
|
|
61696
|
+
return mid;
|
|
61697
|
+
}
|
|
61698
|
+
if (cmp < 0) low = mid + 1;
|
|
61699
|
+
else high = mid - 1;
|
|
61700
|
+
}
|
|
61701
|
+
found = false;
|
|
61702
|
+
return low - 1;
|
|
61703
|
+
}
|
|
61704
|
+
function upperBound(haystack, needle, index) {
|
|
61705
|
+
for (let i = index + 1; i < haystack.length; index = i++) if (haystack[i][COLUMN] !== needle) break;
|
|
61706
|
+
return index;
|
|
61707
|
+
}
|
|
61708
|
+
function lowerBound(haystack, needle, index) {
|
|
61709
|
+
for (let i = index - 1; i >= 0; index = i--) if (haystack[i][COLUMN] !== needle) break;
|
|
61710
|
+
return index;
|
|
61711
|
+
}
|
|
61712
|
+
function memoizedState() {
|
|
61713
|
+
return {
|
|
61714
|
+
lastKey: -1,
|
|
61715
|
+
lastNeedle: -1,
|
|
61716
|
+
lastIndex: -1
|
|
61717
|
+
};
|
|
61718
|
+
}
|
|
61719
|
+
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
61720
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
61721
|
+
let low = 0;
|
|
61722
|
+
let high = haystack.length - 1;
|
|
61723
|
+
if (key === lastKey) {
|
|
61724
|
+
if (needle === lastNeedle) {
|
|
61725
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
61726
|
+
return lastIndex;
|
|
61727
|
+
}
|
|
61728
|
+
if (needle >= lastNeedle) low = lastIndex === -1 ? 0 : lastIndex;
|
|
61729
|
+
else high = lastIndex;
|
|
61730
|
+
}
|
|
61731
|
+
state.lastKey = key;
|
|
61732
|
+
state.lastNeedle = needle;
|
|
61733
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
61734
|
+
}
|
|
61735
|
+
function parse(map) {
|
|
61736
|
+
return typeof map === "string" ? JSON.parse(map) : map;
|
|
61737
|
+
}
|
|
61738
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
61739
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
61740
|
+
var TraceMap = class {
|
|
61741
|
+
constructor(map, mapUrl) {
|
|
61742
|
+
const isString = typeof map === "string";
|
|
61743
|
+
if (!isString && map._decodedMemo) return map;
|
|
61744
|
+
const parsed = parse(map);
|
|
61745
|
+
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
61746
|
+
this.version = version;
|
|
61747
|
+
this.file = file;
|
|
61748
|
+
this.names = names || [];
|
|
61749
|
+
this.sourceRoot = sourceRoot;
|
|
61750
|
+
this.sources = sources;
|
|
61751
|
+
this.sourcesContent = sourcesContent;
|
|
61752
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
61753
|
+
const resolve = resolver(mapUrl, sourceRoot);
|
|
61754
|
+
this.resolvedSources = sources.map(resolve);
|
|
61755
|
+
const { mappings } = parsed;
|
|
61756
|
+
if (typeof mappings === "string") {
|
|
61757
|
+
this._encoded = mappings;
|
|
61758
|
+
this._decoded = void 0;
|
|
61759
|
+
} else if (Array.isArray(mappings)) {
|
|
61760
|
+
this._encoded = void 0;
|
|
61761
|
+
this._decoded = maybeSort(mappings, isString);
|
|
61762
|
+
} else if (parsed.sections) throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
61763
|
+
else throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
61764
|
+
this._decodedMemo = memoizedState();
|
|
61765
|
+
this._bySources = void 0;
|
|
61766
|
+
this._bySourceMemos = void 0;
|
|
61767
|
+
}
|
|
61768
|
+
};
|
|
61769
|
+
function cast(map) {
|
|
61770
|
+
return map;
|
|
61771
|
+
}
|
|
61772
|
+
function decodedMappings(map) {
|
|
61773
|
+
var _a;
|
|
61774
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
61775
|
+
}
|
|
61776
|
+
function originalPositionFor(map, needle) {
|
|
61777
|
+
let { line, column, bias } = needle;
|
|
61778
|
+
line--;
|
|
61779
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
61780
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
61781
|
+
const decoded = decodedMappings(map);
|
|
61782
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
61783
|
+
const segments = decoded[line];
|
|
61784
|
+
const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || 1);
|
|
61785
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
61786
|
+
const segment = segments[index];
|
|
61787
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
61788
|
+
const { names, resolvedSources } = map;
|
|
61789
|
+
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
|
61790
|
+
}
|
|
61791
|
+
function OMapping(source, line, column, name) {
|
|
61792
|
+
return {
|
|
61793
|
+
source,
|
|
61794
|
+
line,
|
|
61795
|
+
column,
|
|
61796
|
+
name
|
|
61797
|
+
};
|
|
61798
|
+
}
|
|
61799
|
+
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
61800
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
61801
|
+
if (found) index = (bias === -1 ? upperBound : lowerBound)(segments, column, index);
|
|
61802
|
+
else if (bias === -1) index++;
|
|
61803
|
+
if (index === -1 || index === segments.length) return -1;
|
|
61804
|
+
return index;
|
|
61805
|
+
}
|
|
61806
|
+
//#endregion
|
|
61383
61807
|
//#region ../core/dist/index.js
|
|
61384
61808
|
var __create = Object.create;
|
|
61385
61809
|
var __defProp = Object.defineProperty;
|
|
@@ -61448,7 +61872,8 @@ var AmbiguousProjectError = class extends Error {
|
|
|
61448
61872
|
}
|
|
61449
61873
|
};
|
|
61450
61874
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
61451
|
-
const
|
|
61875
|
+
const HTML_FILE_PATTERN = /\.html$/i;
|
|
61876
|
+
const SOURCE_FILE_PATTERN = /\.(?:astro|tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
|
|
61452
61877
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
61453
61878
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
61454
61879
|
const MINIFIED_SNIFF_BYTES = 65536;
|
|
@@ -61791,7 +62216,7 @@ const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
|
61791
62216
|
const FILE_LINT_CACHE_FILENAME = "file-lint-cache.json";
|
|
61792
62217
|
const FILE_LINT_CACHE_MAX_FILE_COUNT = 5e4;
|
|
61793
62218
|
const SIDECAR_LINT_CACHE_FILENAME = "sidecar-lint-cache.json";
|
|
61794
|
-
const CORE_PACKAGE_VERSION = "0.9.
|
|
62219
|
+
const CORE_PACKAGE_VERSION = "0.9.2";
|
|
61795
62220
|
const DEAD_CODE_CACHE_FILENAME = "dead-code-cache.json";
|
|
61796
62221
|
const DEAD_CODE_SUMMARY_CACHE_FILENAME = "dead-code-summaries.json";
|
|
61797
62222
|
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
@@ -62041,8 +62466,13 @@ const findMonorepoRoot = (startDirectory) => {
|
|
|
62041
62466
|
* byte-equivalent copy.
|
|
62042
62467
|
*/
|
|
62043
62468
|
const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
|
|
62469
|
+
const unwrapTypescriptExpression = (expression) => {
|
|
62470
|
+
let currentExpression = expression;
|
|
62471
|
+
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
62472
|
+
return currentExpression;
|
|
62473
|
+
};
|
|
62044
62474
|
const TSCONFIG_FILENAME = "tsconfig.json";
|
|
62045
|
-
const
|
|
62475
|
+
const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
|
|
62046
62476
|
const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
|
|
62047
62477
|
const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
62048
62478
|
const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
|
|
@@ -62059,7 +62489,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
|
62059
62489
|
return null;
|
|
62060
62490
|
};
|
|
62061
62491
|
const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
62062
|
-
if (
|
|
62492
|
+
if (isLocalModuleSpecifier(extendsValue)) {
|
|
62493
|
+
const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
|
|
62494
|
+
if (isFile(resolvedPath)) return resolvedPath;
|
|
62495
|
+
const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
|
|
62496
|
+
return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
|
|
62497
|
+
}
|
|
62063
62498
|
return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
|
|
62064
62499
|
};
|
|
62065
62500
|
const normalizeCompilerOptions = (compilerOptions) => {
|
|
@@ -62166,6 +62601,7 @@ const FRAMEWORK_PACKAGES = {
|
|
|
62166
62601
|
"@tanstack/react-start": "tanstack-start",
|
|
62167
62602
|
"@remix-run/react": "remix",
|
|
62168
62603
|
gatsby: "gatsby",
|
|
62604
|
+
astro: "astro",
|
|
62169
62605
|
vite: "vite",
|
|
62170
62606
|
"react-scripts": "cra",
|
|
62171
62607
|
expo: "expo",
|
|
@@ -62253,6 +62689,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
|
|
|
62253
62689
|
".cts",
|
|
62254
62690
|
".json"
|
|
62255
62691
|
];
|
|
62692
|
+
const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
|
|
62693
|
+
conditionNames: [
|
|
62694
|
+
"import",
|
|
62695
|
+
"require",
|
|
62696
|
+
"node",
|
|
62697
|
+
"default"
|
|
62698
|
+
],
|
|
62699
|
+
extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
|
|
62700
|
+
});
|
|
62256
62701
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
62257
62702
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
62258
62703
|
const allDependencies = {
|
|
@@ -62276,6 +62721,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
|
|
|
62276
62721
|
return false;
|
|
62277
62722
|
};
|
|
62278
62723
|
const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
|
|
62724
|
+
if (!isLocalModuleSpecifier(moduleSpecifier)) {
|
|
62725
|
+
try {
|
|
62726
|
+
const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
|
|
62727
|
+
if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
|
|
62728
|
+
} catch {}
|
|
62729
|
+
try {
|
|
62730
|
+
const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
|
|
62731
|
+
return isFile(resolvedPath) ? resolvedPath : null;
|
|
62732
|
+
} catch {
|
|
62733
|
+
return null;
|
|
62734
|
+
}
|
|
62735
|
+
}
|
|
62279
62736
|
const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
|
|
62280
62737
|
const extension = Path.extname(unresolvedPath);
|
|
62281
62738
|
return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
|
|
@@ -62285,10 +62742,10 @@ const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
|
|
|
62285
62742
|
]).find(isFile) ?? null;
|
|
62286
62743
|
};
|
|
62287
62744
|
const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json") || Path.basename(filePath) === ".babelrc" ? ts.parseJsonText(filePath, content) : ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
62288
|
-
const getStaticPropertyName$
|
|
62745
|
+
const getStaticPropertyName$2 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
|
|
62289
62746
|
const isCommonJsConfigExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
|
|
62290
62747
|
const hasExportModifier = (node) => ts.canHaveModifiers(node) && Boolean(ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
|
|
62291
|
-
const getRequireModuleSpecifier = (expression) => {
|
|
62748
|
+
const getRequireModuleSpecifier$1 = (expression) => {
|
|
62292
62749
|
if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
|
|
62293
62750
|
const moduleSpecifier = expression.arguments[0];
|
|
62294
62751
|
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
@@ -62301,7 +62758,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
|
|
|
62301
62758
|
const namedBindings = importClause?.namedBindings;
|
|
62302
62759
|
return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
|
|
62303
62760
|
}
|
|
62304
|
-
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) =>
|
|
62761
|
+
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
|
|
62305
62762
|
return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
|
|
62306
62763
|
});
|
|
62307
62764
|
const getImportBinding = (sourceFile, bindingName) => {
|
|
@@ -62332,24 +62789,24 @@ const getImportBinding = (sourceFile, bindingName) => {
|
|
|
62332
62789
|
for (const declaration of statement.declarationList.declarations) {
|
|
62333
62790
|
if (!declaration.initializer) continue;
|
|
62334
62791
|
if (ts.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
|
|
62335
|
-
const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
62792
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
62336
62793
|
if (directModuleSpecifier) return {
|
|
62337
62794
|
moduleSpecifier: directModuleSpecifier,
|
|
62338
62795
|
exportName: "default",
|
|
62339
62796
|
isNamespace: true
|
|
62340
62797
|
};
|
|
62341
|
-
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
|
|
62342
|
-
moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
|
|
62798
|
+
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier$1(declaration.initializer.expression) !== null) return {
|
|
62799
|
+
moduleSpecifier: getRequireModuleSpecifier$1(declaration.initializer.expression) ?? "",
|
|
62343
62800
|
exportName: declaration.initializer.name.text,
|
|
62344
62801
|
isNamespace: false
|
|
62345
62802
|
};
|
|
62346
62803
|
}
|
|
62347
62804
|
if (!ts.isObjectBindingPattern(declaration.name)) continue;
|
|
62348
62805
|
const bindingElement = declaration.name.elements.find((element) => ts.isIdentifier(element.name) && element.name.text === bindingName);
|
|
62349
|
-
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
62806
|
+
const moduleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
62350
62807
|
if (bindingElement && moduleSpecifier) return {
|
|
62351
62808
|
moduleSpecifier,
|
|
62352
|
-
exportName: bindingElement.propertyName ? getStaticPropertyName$
|
|
62809
|
+
exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
|
|
62353
62810
|
isNamespace: false
|
|
62354
62811
|
};
|
|
62355
62812
|
}
|
|
@@ -62366,10 +62823,16 @@ const getTopLevelBinding = (sourceFile, bindingName) => {
|
|
|
62366
62823
|
}
|
|
62367
62824
|
return null;
|
|
62368
62825
|
};
|
|
62369
|
-
const getFunctionLocalBindings = (functionNode, argumentsList) => {
|
|
62826
|
+
const getFunctionLocalBindings = (functionNode, argumentsList, argumentAnalysis, functionAnalysis) => {
|
|
62370
62827
|
const localBindings = /* @__PURE__ */ new Map();
|
|
62371
62828
|
functionNode.parameters.forEach((parameter, parameterIndex) => {
|
|
62372
|
-
if (ts.isIdentifier(parameter.name))
|
|
62829
|
+
if (ts.isIdentifier(parameter.name)) {
|
|
62830
|
+
const argument = argumentsList[parameterIndex];
|
|
62831
|
+
localBindings.set(parameter.name.text, {
|
|
62832
|
+
expression: argument ?? parameter.initializer ?? null,
|
|
62833
|
+
analysis: argument ? argumentAnalysis : functionAnalysis
|
|
62834
|
+
});
|
|
62835
|
+
}
|
|
62373
62836
|
});
|
|
62374
62837
|
return localBindings;
|
|
62375
62838
|
};
|
|
@@ -62402,6 +62865,48 @@ const getScopedConfigBinding = (identifier) => {
|
|
|
62402
62865
|
};
|
|
62403
62866
|
};
|
|
62404
62867
|
const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
|
|
62868
|
+
const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
|
|
62869
|
+
const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
|
|
62870
|
+
const isNodeCreateRequireCall = (node, analysis) => {
|
|
62871
|
+
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
|
|
62872
|
+
if (!ts.isCallExpression(node)) return false;
|
|
62873
|
+
const target = node.expression;
|
|
62874
|
+
if (ts.isIdentifier(target)) {
|
|
62875
|
+
if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
|
|
62876
|
+
const importBinding = getImportBinding(analysis.sourceFile, target.text);
|
|
62877
|
+
return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
|
|
62878
|
+
}
|
|
62879
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
|
|
62880
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
|
|
62881
|
+
const createRequireReceiver = target.expression;
|
|
62882
|
+
if (ts.isCallExpression(createRequireReceiver)) {
|
|
62883
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
|
|
62884
|
+
if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
|
|
62885
|
+
const requireIdentifier = createRequireReceiver.expression;
|
|
62886
|
+
return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
|
|
62887
|
+
}
|
|
62888
|
+
if (!ts.isIdentifier(createRequireReceiver)) return false;
|
|
62889
|
+
if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
|
|
62890
|
+
const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
|
|
62891
|
+
return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
|
|
62892
|
+
};
|
|
62893
|
+
const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
|
|
62894
|
+
const [moduleSpecifierNode] = callExpression.arguments;
|
|
62895
|
+
if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
|
|
62896
|
+
const target = callExpression.expression;
|
|
62897
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62898
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
|
|
62899
|
+
if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
|
|
62900
|
+
if (!ts.isIdentifier(target.expression)) return null;
|
|
62901
|
+
const resolverIdentifier = target.expression;
|
|
62902
|
+
if (analysis.localBindings.has(resolverIdentifier.text)) return null;
|
|
62903
|
+
const scopedBinding = getScopedConfigBinding(resolverIdentifier);
|
|
62904
|
+
const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
|
|
62905
|
+
const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
|
|
62906
|
+
if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
|
|
62907
|
+
if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
|
|
62908
|
+
return moduleSpecifierNode.text;
|
|
62909
|
+
};
|
|
62405
62910
|
const getAssignedPropertyInitializer = (identifier, propertyName) => {
|
|
62406
62911
|
let bindingScope = null;
|
|
62407
62912
|
let currentNode = identifier;
|
|
@@ -62444,9 +62949,11 @@ const getAssignedPropertyInitializer = (identifier, propertyName) => {
|
|
|
62444
62949
|
initializer: assignedInitializer
|
|
62445
62950
|
};
|
|
62446
62951
|
};
|
|
62447
|
-
const getStaticConfigValueState = (expression, analysis) => {
|
|
62448
|
-
|
|
62449
|
-
|
|
62952
|
+
const getStaticConfigValueState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
|
|
62953
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
62954
|
+
if (visitedExpressions.has(unwrappedExpression)) return null;
|
|
62955
|
+
const nextVisitedExpressions = new Set(visitedExpressions);
|
|
62956
|
+
nextVisitedExpressions.add(unwrappedExpression);
|
|
62450
62957
|
if (unwrappedExpression.kind === ts.SyntaxKind.NullKeyword || ts.isIdentifier(unwrappedExpression) && unwrappedExpression.text === "undefined") return {
|
|
62451
62958
|
isNullish: true,
|
|
62452
62959
|
isTruthy: false
|
|
@@ -62461,32 +62968,32 @@ const getStaticConfigValueState = (expression, analysis) => {
|
|
|
62461
62968
|
};
|
|
62462
62969
|
if (ts.isIdentifier(unwrappedExpression)) {
|
|
62463
62970
|
if (analysis.localBindings.has(unwrappedExpression.text)) {
|
|
62464
|
-
const
|
|
62465
|
-
return
|
|
62971
|
+
const localReference = analysis.localBindings.get(unwrappedExpression.text);
|
|
62972
|
+
return localReference?.expression ? getStaticConfigValueState(localReference.expression, localReference.analysis, nextVisitedExpressions) : null;
|
|
62466
62973
|
}
|
|
62467
62974
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
|
|
62468
|
-
return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis) : null;
|
|
62975
|
+
return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis, nextVisitedExpressions) : null;
|
|
62469
62976
|
}
|
|
62470
62977
|
if (ts.isConditionalExpression(unwrappedExpression)) {
|
|
62471
|
-
const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis);
|
|
62472
|
-
if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis);
|
|
62473
|
-
const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis);
|
|
62474
|
-
const whenFalseState = getStaticConfigValueState(unwrappedExpression.whenFalse, analysis);
|
|
62978
|
+
const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis, nextVisitedExpressions);
|
|
62979
|
+
if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
|
|
62980
|
+
const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis, nextVisitedExpressions);
|
|
62981
|
+
const whenFalseState = getStaticConfigValueState(unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
|
|
62475
62982
|
return whenTrueState !== null && whenFalseState !== null && whenTrueState.isNullish === whenFalseState.isNullish && whenTrueState.isTruthy === whenFalseState.isTruthy ? whenTrueState : null;
|
|
62476
62983
|
}
|
|
62477
62984
|
if (ts.isBinaryExpression(unwrappedExpression)) {
|
|
62478
|
-
const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis);
|
|
62985
|
+
const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis, nextVisitedExpressions);
|
|
62479
62986
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
|
|
62480
62987
|
if (leftState === null) return null;
|
|
62481
|
-
return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
|
|
62988
|
+
return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
|
|
62482
62989
|
}
|
|
62483
62990
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
|
|
62484
62991
|
if (leftState === null) return null;
|
|
62485
|
-
return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis);
|
|
62992
|
+
return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions);
|
|
62486
62993
|
}
|
|
62487
62994
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken) {
|
|
62488
62995
|
if (leftState === null) return null;
|
|
62489
|
-
return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
|
|
62996
|
+
return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
|
|
62490
62997
|
}
|
|
62491
62998
|
}
|
|
62492
62999
|
return null;
|
|
@@ -62495,25 +63002,27 @@ const isStaticallyDisabledConfigExpression = (expression, analysis) => getStatic
|
|
|
62495
63002
|
const isStaticallyTruthyConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isTruthy === true;
|
|
62496
63003
|
const isStaticallyNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === true;
|
|
62497
63004
|
const isStaticallyNonNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === false;
|
|
62498
|
-
const getReactCompilerFlagState = (expression, analysis) => {
|
|
62499
|
-
|
|
62500
|
-
|
|
63005
|
+
const getReactCompilerFlagState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
|
|
63006
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
63007
|
+
if (visitedExpressions.has(unwrappedExpression)) return null;
|
|
63008
|
+
const nextVisitedExpressions = new Set(visitedExpressions);
|
|
63009
|
+
nextVisitedExpressions.add(unwrappedExpression);
|
|
62501
63010
|
if (ts.isIdentifier(unwrappedExpression)) {
|
|
62502
63011
|
const assignedBinding = getAssignedPropertyInitializer(unwrappedExpression, "reactCompiler");
|
|
62503
63012
|
if (assignedBinding.wasFound && assignedBinding.initializer) return { isEnabled: !isStaticallyDisabledConfigExpression(assignedBinding.initializer, analysis) };
|
|
62504
63013
|
if (analysis.localBindings.has(unwrappedExpression.text)) {
|
|
62505
|
-
const
|
|
62506
|
-
return
|
|
63014
|
+
const localReference = analysis.localBindings.get(unwrappedExpression.text);
|
|
63015
|
+
return localReference?.expression ? getReactCompilerFlagState(localReference.expression, localReference.analysis, nextVisitedExpressions) : null;
|
|
62507
63016
|
}
|
|
62508
63017
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
|
|
62509
|
-
return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis) : null;
|
|
63018
|
+
return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis, nextVisitedExpressions) : null;
|
|
62510
63019
|
}
|
|
62511
63020
|
if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
|
|
62512
63021
|
for (const property of [...unwrappedExpression.properties].reverse()) {
|
|
62513
|
-
if (ts.isPropertyAssignment(property) && getStaticPropertyName$
|
|
63022
|
+
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
|
|
62514
63023
|
if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
|
|
62515
63024
|
if (ts.isSpreadAssignment(property)) {
|
|
62516
|
-
const spreadState = getReactCompilerFlagState(property.expression, analysis);
|
|
63025
|
+
const spreadState = getReactCompilerFlagState(property.expression, analysis, nextVisitedExpressions);
|
|
62517
63026
|
if (spreadState) return spreadState;
|
|
62518
63027
|
}
|
|
62519
63028
|
}
|
|
@@ -62526,8 +63035,8 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
|
|
|
62526
63035
|
visitedExpressions.add(resolvedExpression);
|
|
62527
63036
|
if (ts.isIdentifier(resolvedExpression)) {
|
|
62528
63037
|
if (analysis.localBindings.has(resolvedExpression.text)) {
|
|
62529
|
-
const
|
|
62530
|
-
return
|
|
63038
|
+
const localReference = analysis.localBindings.get(resolvedExpression.text);
|
|
63039
|
+
return localReference?.expression ? getSelectedObjectProperty(localReference.expression, propertyName, localReference.analysis, visitedExpressions) : null;
|
|
62531
63040
|
}
|
|
62532
63041
|
const scopedBinding = getScopedConfigBinding(resolvedExpression);
|
|
62533
63042
|
if (scopedBinding.wasFound) return scopedBinding.initializer ? getSelectedObjectProperty(scopedBinding.initializer, propertyName, analysis, visitedExpressions) : null;
|
|
@@ -62536,9 +63045,18 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
|
|
|
62536
63045
|
}
|
|
62537
63046
|
if (!ts.isObjectLiteralExpression(resolvedExpression)) return null;
|
|
62538
63047
|
for (const property of [...resolvedExpression.properties].reverse()) {
|
|
62539
|
-
if (ts.isPropertyAssignment(property) && getStaticPropertyName$
|
|
62540
|
-
|
|
62541
|
-
|
|
63048
|
+
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === propertyName) return {
|
|
63049
|
+
node: property.initializer,
|
|
63050
|
+
analysis
|
|
63051
|
+
};
|
|
63052
|
+
if (ts.isMethodDeclaration(property) && getStaticPropertyName$2(property.name) === propertyName) return {
|
|
63053
|
+
node: property,
|
|
63054
|
+
analysis
|
|
63055
|
+
};
|
|
63056
|
+
if (ts.isShorthandPropertyAssignment(property) && property.name.text === propertyName) return {
|
|
63057
|
+
node: property.name,
|
|
63058
|
+
analysis
|
|
63059
|
+
};
|
|
62542
63060
|
if (ts.isSpreadAssignment(property)) {
|
|
62543
63061
|
const spreadProperty = getSelectedObjectProperty(property.expression, propertyName, analysis, visitedExpressions);
|
|
62544
63062
|
if (spreadProperty) return spreadProperty;
|
|
@@ -62551,8 +63069,8 @@ const configExpressionMayDefineProperty = (expression, propertyName, analysis) =
|
|
|
62551
63069
|
while (ts.isParenthesizedExpression(resolvedExpression) || ts.isAsExpression(resolvedExpression) || ts.isTypeAssertionExpression(resolvedExpression) || ts.isSatisfiesExpression(resolvedExpression) || ts.isNonNullExpression(resolvedExpression)) resolvedExpression = resolvedExpression.expression;
|
|
62552
63070
|
if (ts.isIdentifier(resolvedExpression)) {
|
|
62553
63071
|
if (analysis.localBindings.has(resolvedExpression.text)) {
|
|
62554
|
-
const
|
|
62555
|
-
return
|
|
63072
|
+
const localReference = analysis.localBindings.get(resolvedExpression.text);
|
|
63073
|
+
return localReference?.expression ? configExpressionMayDefineProperty(localReference.expression, propertyName, localReference.analysis) : true;
|
|
62556
63074
|
}
|
|
62557
63075
|
const scopedBinding = getScopedConfigBinding(resolvedExpression);
|
|
62558
63076
|
if (scopedBinding.wasFound) return scopedBinding.initializer ? configExpressionMayDefineProperty(scopedBinding.initializer, propertyName, analysis) : true;
|
|
@@ -62568,7 +63086,7 @@ const configExpressionMayDefineProperty = (expression, propertyName, analysis) =
|
|
|
62568
63086
|
return resolvedExpression.properties.some((property) => {
|
|
62569
63087
|
if (ts.isSpreadAssignment(property)) return configExpressionMayDefineProperty(property.expression, propertyName, analysis);
|
|
62570
63088
|
if (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property) || ts.isMethodDeclaration(property) || ts.isGetAccessorDeclaration(property) || ts.isSetAccessorDeclaration(property)) {
|
|
62571
|
-
const staticPropertyName = getStaticPropertyName$
|
|
63089
|
+
const staticPropertyName = getStaticPropertyName$2(property.name);
|
|
62572
63090
|
return staticPropertyName === null || staticPropertyName === propertyName;
|
|
62573
63091
|
}
|
|
62574
63092
|
return false;
|
|
@@ -62587,7 +63105,7 @@ const getExportedConfigNodes = (sourceFile, exportName) => {
|
|
|
62587
63105
|
continue;
|
|
62588
63106
|
}
|
|
62589
63107
|
if (ts.isExpressionStatement(statement) && isCommonJsConfigExportAssignment(statement.expression, sourceFile) && exportName !== "default" && ts.isObjectLiteralExpression(statement.expression.right)) for (const property of [...statement.expression.right.properties].reverse()) {
|
|
62590
|
-
if (ts.isPropertyAssignment(property) && getStaticPropertyName$
|
|
63108
|
+
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === exportName) {
|
|
62591
63109
|
exportedNodes.push(property.initializer);
|
|
62592
63110
|
break;
|
|
62593
63111
|
}
|
|
@@ -62636,15 +63154,15 @@ const getReExportedConfigModules = (sourceFile, exportName) => {
|
|
|
62636
63154
|
}
|
|
62637
63155
|
return bindings;
|
|
62638
63156
|
};
|
|
62639
|
-
const analyzeConfigModuleExport = (filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = []) => {
|
|
63157
|
+
const analyzeConfigModuleExport = (filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = [], argumentAnalysis) => {
|
|
62640
63158
|
if (!isFile(filePath) || importDepth > 4) return false;
|
|
62641
63159
|
const moduleVisitKey = `${filePath}:${exportName}:${allowCompilerTransform}`;
|
|
62642
63160
|
if (visitedModules.has(moduleVisitKey)) return false;
|
|
62643
63161
|
const nextVisitedModules = new Set(visitedModules);
|
|
62644
63162
|
nextVisitedModules.add(moduleVisitKey);
|
|
62645
|
-
return analyzeConfigSourceFileExport(parseConfigSourceFile(filePath, NFS.readFileSync(filePath, "utf-8")), filePath, exportName, allowCompilerTransform, importDepth, nextVisitedModules, argumentsList);
|
|
63163
|
+
return analyzeConfigSourceFileExport(parseConfigSourceFile(filePath, NFS.readFileSync(filePath, "utf-8")), filePath, exportName, allowCompilerTransform, importDepth, nextVisitedModules, argumentsList, argumentAnalysis);
|
|
62646
63164
|
};
|
|
62647
|
-
const analyzeConfigSourceFileExport = (sourceFile, filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = []) => {
|
|
63165
|
+
const analyzeConfigSourceFileExport = (sourceFile, filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = [], argumentAnalysis) => {
|
|
62648
63166
|
const analysis = {
|
|
62649
63167
|
filePath,
|
|
62650
63168
|
sourceFile,
|
|
@@ -62654,14 +63172,27 @@ const analyzeConfigSourceFileExport = (sourceFile, filePath, exportName, allowCo
|
|
|
62654
63172
|
localBindings: /* @__PURE__ */ new Map(),
|
|
62655
63173
|
activeFunctions: /* @__PURE__ */ new Set()
|
|
62656
63174
|
};
|
|
63175
|
+
const resolvedArgumentAnalysis = argumentAnalysis ?? analysis;
|
|
62657
63176
|
const exportedConfigNodes = getExportedConfigNodes(sourceFile, exportName);
|
|
62658
|
-
return exportedConfigNodes.some((node) =>
|
|
63177
|
+
return exportedConfigNodes.some((node) => {
|
|
63178
|
+
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) return analyzeConfigFunction(node, analysis, allowCompilerTransform, argumentsList, resolvedArgumentAnalysis);
|
|
63179
|
+
if (argumentsList.length > 0 && ts.isIdentifier(node)) {
|
|
63180
|
+
const topLevelBinding = getTopLevelBinding(sourceFile, node.text);
|
|
63181
|
+
if (topLevelBinding && ts.isFunctionLike(topLevelBinding)) return analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, argumentsList, resolvedArgumentAnalysis);
|
|
63182
|
+
const importBinding = getImportBinding(sourceFile, node.text);
|
|
63183
|
+
if (importBinding) {
|
|
63184
|
+
const importedFilePath = resolveImportedConfigFile(filePath, importBinding.moduleSpecifier);
|
|
63185
|
+
return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList, resolvedArgumentAnalysis));
|
|
63186
|
+
}
|
|
63187
|
+
}
|
|
63188
|
+
return analyzeConfigNode(node, analysis, allowCompilerTransform);
|
|
63189
|
+
}) || getReExportedConfigModules(sourceFile, exportName).some((binding) => {
|
|
62659
63190
|
if (exportedConfigNodes.length > 0 && binding.isNamespace) return false;
|
|
62660
63191
|
const importedFilePath = resolveImportedConfigFile(filePath, binding.moduleSpecifier);
|
|
62661
|
-
return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, binding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList));
|
|
63192
|
+
return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, binding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList, resolvedArgumentAnalysis));
|
|
62662
63193
|
});
|
|
62663
63194
|
};
|
|
62664
|
-
const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, argumentsList = []) => {
|
|
63195
|
+
const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, argumentsList = [], argumentAnalysis = analysis) => {
|
|
62665
63196
|
if (!functionNode.body) return false;
|
|
62666
63197
|
if (analysis.activeFunctions.has(functionNode.pos)) return false;
|
|
62667
63198
|
const activeFunctions = new Set(analysis.activeFunctions);
|
|
@@ -62669,7 +63200,7 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
|
|
|
62669
63200
|
const functionAnalysis = {
|
|
62670
63201
|
...analysis,
|
|
62671
63202
|
visitedNodes: /* @__PURE__ */ new Set(),
|
|
62672
|
-
localBindings: getFunctionLocalBindings(functionNode, argumentsList),
|
|
63203
|
+
localBindings: getFunctionLocalBindings(functionNode, argumentsList, argumentAnalysis, analysis),
|
|
62673
63204
|
activeFunctions
|
|
62674
63205
|
};
|
|
62675
63206
|
if (!ts.isBlock(functionNode.body)) return analyzeConfigNode(functionNode.body, functionAnalysis, allowCompilerTransform);
|
|
@@ -62685,6 +63216,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
|
|
|
62685
63216
|
visitReturns(functionNode.body);
|
|
62686
63217
|
return hasCompiler;
|
|
62687
63218
|
};
|
|
63219
|
+
const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
|
|
63220
|
+
const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
|
|
63221
|
+
if (!importedFilePath) return null;
|
|
63222
|
+
return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList, analysis);
|
|
63223
|
+
};
|
|
62688
63224
|
const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
|
|
62689
63225
|
const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
|
|
62690
63226
|
if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
|
|
@@ -62697,42 +63233,74 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
|
|
|
62697
63233
|
if (assignedPlugins.wasFound) overriddenPropertyNames.add("plugins");
|
|
62698
63234
|
if (assignedPresets.wasFound) overriddenPropertyNames.add("presets");
|
|
62699
63235
|
if (analysis.localBindings.has(identifier.text)) {
|
|
62700
|
-
const
|
|
62701
|
-
return Boolean(
|
|
63236
|
+
const localReference = analysis.localBindings.get(identifier.text);
|
|
63237
|
+
return Boolean(localReference?.expression && analyzeConfigNode(localReference.expression, localReference.analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62702
63238
|
}
|
|
62703
63239
|
const scopedBinding = getScopedConfigBinding(identifier);
|
|
62704
63240
|
if (scopedBinding.wasFound) return Boolean(scopedBinding.initializer && analyzeConfigNode(scopedBinding.initializer, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62705
63241
|
const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
|
|
62706
63242
|
if (importBinding) {
|
|
62707
63243
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
62708
|
-
|
|
62709
|
-
|
|
62710
|
-
|
|
63244
|
+
return Boolean(analyzeImportedConfig({
|
|
63245
|
+
analysis,
|
|
63246
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63247
|
+
exportName: importBinding.exportName,
|
|
63248
|
+
allowCompilerTransform
|
|
63249
|
+
}));
|
|
62711
63250
|
}
|
|
62712
63251
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
|
|
62713
63252
|
return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62714
63253
|
};
|
|
62715
63254
|
const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
|
|
62716
63255
|
const target = callExpression.expression;
|
|
63256
|
+
const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
|
|
63257
|
+
if (callableRequiredModuleSpecifier !== null) {
|
|
63258
|
+
if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
63259
|
+
if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
|
|
63260
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63261
|
+
analysis,
|
|
63262
|
+
moduleSpecifier: callableRequiredModuleSpecifier,
|
|
63263
|
+
exportName: "default",
|
|
63264
|
+
allowCompilerTransform,
|
|
63265
|
+
argumentsList: callExpression.arguments
|
|
63266
|
+
});
|
|
63267
|
+
if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63268
|
+
return null;
|
|
63269
|
+
}
|
|
62717
63270
|
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62718
63271
|
const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
|
|
62719
63272
|
if (propertyName === null) return null;
|
|
62720
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
|
|
63273
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
|
|
62721
63274
|
if (requiredModuleSpecifier !== null) {
|
|
62722
|
-
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62723
|
-
if (
|
|
62724
|
-
const
|
|
62725
|
-
|
|
63275
|
+
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (analysis.localBindings.has(target.expression.expression.text) || getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
63276
|
+
if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
|
|
63277
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63278
|
+
analysis,
|
|
63279
|
+
moduleSpecifier: requiredModuleSpecifier,
|
|
63280
|
+
exportName: propertyName,
|
|
63281
|
+
allowCompilerTransform,
|
|
63282
|
+
argumentsList: callExpression.arguments
|
|
63283
|
+
});
|
|
63284
|
+
if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63285
|
+
return null;
|
|
62726
63286
|
}
|
|
62727
63287
|
if (!ts.isIdentifier(target.expression)) return null;
|
|
62728
|
-
const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
|
|
62729
|
-
if (importBinding?.isNamespace
|
|
62730
|
-
|
|
62731
|
-
|
|
63288
|
+
const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
|
|
63289
|
+
if (importBinding?.isNamespace) {
|
|
63290
|
+
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
|
|
63291
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63292
|
+
analysis,
|
|
63293
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63294
|
+
exportName: propertyName,
|
|
63295
|
+
allowCompilerTransform,
|
|
63296
|
+
argumentsList: callExpression.arguments
|
|
63297
|
+
});
|
|
63298
|
+
if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63299
|
+
return null;
|
|
62732
63300
|
}
|
|
62733
63301
|
const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
|
|
62734
63302
|
if (selectedProperty === null) return null;
|
|
62735
|
-
return ts.isFunctionLike(selectedProperty) ? analyzeConfigFunction(selectedProperty, analysis, allowCompilerTransform, callExpression.arguments) : analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
63303
|
+
return ts.isFunctionLike(selectedProperty.node) ? analyzeConfigFunction(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform, callExpression.arguments, analysis) : analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform);
|
|
62736
63304
|
};
|
|
62737
63305
|
const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTransformCollection = false, excludedPropertyNames) => {
|
|
62738
63306
|
const excludedPropertiesVisitKey = excludedPropertyNames ? [...excludedPropertyNames].sort().join(",") : "";
|
|
@@ -62746,25 +63314,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62746
63314
|
const reactCompilerFlagState = excludedPropertyNames?.has("reactCompiler") ? null : getReactCompilerFlagState(node, analysis);
|
|
62747
63315
|
if (reactCompilerFlagState?.isEnabled) return true;
|
|
62748
63316
|
for (const [propertyIndex, property] of node.properties.entries()) if (ts.isPropertyAssignment(property)) {
|
|
62749
|
-
const propertyName = getStaticPropertyName$
|
|
63317
|
+
const propertyName = getStaticPropertyName$2(property.name);
|
|
62750
63318
|
if (propertyName && excludedPropertyNames?.has(propertyName)) continue;
|
|
62751
63319
|
if (propertyName === "reactCompiler") continue;
|
|
62752
|
-
if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$
|
|
63320
|
+
if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === propertyName)) continue;
|
|
62753
63321
|
const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
|
|
62754
|
-
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)
|
|
62755
|
-
|
|
62756
|
-
|
|
63322
|
+
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
|
|
63323
|
+
if (analyzeImportedConfig({
|
|
63324
|
+
analysis,
|
|
63325
|
+
moduleSpecifier: property.initializer.text,
|
|
63326
|
+
exportName: "default",
|
|
63327
|
+
allowCompilerTransform: false
|
|
63328
|
+
})) return true;
|
|
62757
63329
|
}
|
|
62758
63330
|
if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
|
|
62759
63331
|
} else if (ts.isShorthandPropertyAssignment(property)) {
|
|
62760
63332
|
if (excludedPropertyNames?.has(property.name.text)) continue;
|
|
62761
63333
|
if (property.name.text === "reactCompiler") continue;
|
|
62762
|
-
if ((property.name.text === "plugins" || property.name.text === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, property.name.text, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$
|
|
63334
|
+
if ((property.name.text === "plugins" || property.name.text === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, property.name.text, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === property.name.text)) continue;
|
|
62763
63335
|
const propertyAllowsCompilerTransform = property.name.text === "plugins" || property.name.text === "presets";
|
|
62764
63336
|
if (analyzeConfigNode(property.name, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
|
|
62765
63337
|
} else if (ts.isSpreadAssignment(property)) {
|
|
62766
63338
|
if (reactCompilerFlagState && getReactCompilerFlagState(property.expression, analysis) !== null) continue;
|
|
62767
|
-
if (node.properties.slice(propertyIndex + 1).some((laterProperty) => (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && (getStaticPropertyName$
|
|
63339
|
+
if (node.properties.slice(propertyIndex + 1).some((laterProperty) => (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && (getStaticPropertyName$2(laterProperty.name) === "plugins" || getStaticPropertyName$2(laterProperty.name) === "presets"))) continue;
|
|
62768
63340
|
if (analyzeConfigNode(property.expression, analysis, allowCompilerTransform, false, excludedPropertyNames)) return true;
|
|
62769
63341
|
}
|
|
62770
63342
|
return false;
|
|
@@ -62777,23 +63349,36 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62777
63349
|
});
|
|
62778
63350
|
}
|
|
62779
63351
|
if (ts.isCallExpression(node)) {
|
|
63352
|
+
const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
|
|
63353
|
+
if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
|
|
62780
63354
|
const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
|
|
62781
63355
|
if (callTargetResult !== null) return callTargetResult;
|
|
62782
|
-
const directModuleSpecifier = getRequireModuleSpecifier(node);
|
|
63356
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(node);
|
|
62783
63357
|
const isRequireShadowed = analysis.localBindings.has("require") || ts.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
|
|
62784
63358
|
if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
62785
63359
|
if (directModuleSpecifier && !isRequireShadowed) {
|
|
62786
63360
|
if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
|
|
62787
|
-
if (
|
|
62788
|
-
|
|
62789
|
-
|
|
62790
|
-
|
|
63361
|
+
if (analyzeImportedConfig({
|
|
63362
|
+
analysis,
|
|
63363
|
+
moduleSpecifier: directModuleSpecifier,
|
|
63364
|
+
exportName: "default",
|
|
63365
|
+
allowCompilerTransform
|
|
63366
|
+
})) return true;
|
|
62791
63367
|
}
|
|
62792
63368
|
if (ts.isIdentifier(node.expression)) {
|
|
62793
|
-
|
|
62794
|
-
|
|
62795
|
-
|
|
62796
|
-
|
|
63369
|
+
if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
|
|
63370
|
+
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
63371
|
+
if (importBinding) {
|
|
63372
|
+
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
63373
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
63374
|
+
analysis,
|
|
63375
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63376
|
+
exportName: importBinding.exportName,
|
|
63377
|
+
allowCompilerTransform,
|
|
63378
|
+
argumentsList: node.arguments
|
|
63379
|
+
});
|
|
63380
|
+
if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
63381
|
+
}
|
|
62797
63382
|
}
|
|
62798
63383
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
|
|
62799
63384
|
if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
|
|
@@ -62801,47 +63386,57 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62801
63386
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
|
|
62802
63387
|
}
|
|
62803
63388
|
if (ts.isPropertyAccessExpression(node)) {
|
|
62804
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
|
|
63389
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
|
|
62805
63390
|
if (requiredModuleSpecifier) {
|
|
62806
|
-
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62807
|
-
if (
|
|
62808
|
-
|
|
62809
|
-
|
|
62810
|
-
|
|
63391
|
+
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (analysis.localBindings.has(node.expression.expression.text) || getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
63392
|
+
if (analyzeImportedConfig({
|
|
63393
|
+
analysis,
|
|
63394
|
+
moduleSpecifier: requiredModuleSpecifier,
|
|
63395
|
+
exportName: node.name.text,
|
|
63396
|
+
allowCompilerTransform
|
|
63397
|
+
})) return true;
|
|
62811
63398
|
return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
|
|
62812
63399
|
}
|
|
62813
63400
|
if (ts.isIdentifier(node.expression)) {
|
|
62814
|
-
if (analysis.localBindings.has(node.expression.text)) {
|
|
62815
|
-
const
|
|
62816
|
-
return Boolean(
|
|
63401
|
+
if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
|
|
63402
|
+
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
63403
|
+
return Boolean(selectedProperty && analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform));
|
|
62817
63404
|
}
|
|
62818
63405
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62819
63406
|
if (importBinding?.isNamespace) {
|
|
62820
63407
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
|
|
62821
|
-
if (
|
|
62822
|
-
|
|
62823
|
-
|
|
62824
|
-
|
|
63408
|
+
if (analyzeImportedConfig({
|
|
63409
|
+
analysis,
|
|
63410
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63411
|
+
exportName: node.name.text,
|
|
63412
|
+
allowCompilerTransform
|
|
63413
|
+
})) return true;
|
|
62825
63414
|
return false;
|
|
62826
63415
|
}
|
|
62827
63416
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
62828
|
-
if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
63417
|
+
if (selectedProperty) return analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform);
|
|
62829
63418
|
return false;
|
|
62830
63419
|
}
|
|
62831
63420
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
62832
63421
|
}
|
|
62833
63422
|
if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
|
|
62834
63423
|
if (ts.isIdentifier(node.expression)) {
|
|
63424
|
+
if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
|
|
63425
|
+
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
63426
|
+
return Boolean(selectedProperty && analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform));
|
|
63427
|
+
}
|
|
62835
63428
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62836
63429
|
if (importBinding?.isNamespace) {
|
|
62837
63430
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
|
|
62838
|
-
|
|
62839
|
-
|
|
62840
|
-
|
|
62841
|
-
|
|
63431
|
+
return Boolean(analyzeImportedConfig({
|
|
63432
|
+
analysis,
|
|
63433
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63434
|
+
exportName: node.argumentExpression.text,
|
|
63435
|
+
allowCompilerTransform
|
|
63436
|
+
}));
|
|
62842
63437
|
}
|
|
62843
63438
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
62844
|
-
if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
63439
|
+
if (selectedProperty) return analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform);
|
|
62845
63440
|
return false;
|
|
62846
63441
|
}
|
|
62847
63442
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
@@ -62876,14 +63471,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62876
63471
|
};
|
|
62877
63472
|
const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
62878
63473
|
const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
|
|
62879
|
-
const hasCompilerInPackageJsonConfig = (
|
|
62880
|
-
|
|
63474
|
+
const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
|
|
63475
|
+
if (!isPlainObject(packageJson.babel)) return false;
|
|
63476
|
+
const packageJsonPath = Path.join(directory, "package.json");
|
|
63477
|
+
return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
63478
|
+
};
|
|
63479
|
+
const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
|
|
62881
63480
|
const hasCompilerConfigurationInAncestors = (directory) => {
|
|
62882
63481
|
if (isProjectBoundary(directory)) return false;
|
|
62883
63482
|
let ancestorDirectory = Path.dirname(directory);
|
|
62884
63483
|
while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
|
|
62885
63484
|
const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
|
|
62886
|
-
|
|
63485
|
+
const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
|
|
63486
|
+
if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
|
|
62887
63487
|
if (isProjectBoundary(ancestorDirectory)) return false;
|
|
62888
63488
|
ancestorDirectory = Path.dirname(ancestorDirectory);
|
|
62889
63489
|
}
|
|
@@ -65213,6 +65813,7 @@ const classifyPackageRole = (filename) => {
|
|
|
65213
65813
|
* Resolves the absolute path to read for a diagnostic's `filePath`,
|
|
65214
65814
|
* accounting for the various shapes oxlint emits:
|
|
65215
65815
|
*
|
|
65816
|
+
* - `file://` URL — decode to an absolute filesystem path.
|
|
65216
65817
|
* - Absolute POSIX (`/abs/path/file.tsx`) — pass through.
|
|
65217
65818
|
* - Absolute Windows (`C:/...` or `C:\...`) — pass through.
|
|
65218
65819
|
* - `./relative` or bare relative — join against `rootDirectory`.
|
|
@@ -65222,6 +65823,7 @@ const classifyPackageRole = (filename) => {
|
|
|
65222
65823
|
* use one canonical resolution path.
|
|
65223
65824
|
*/
|
|
65224
65825
|
const resolveCandidateReadPath = (rootDirectory, filePath) => {
|
|
65826
|
+
if (filePath.startsWith("file://")) return fileURLToPath(filePath);
|
|
65225
65827
|
const normalizedFile = filePath.replace(/\\/g, "/");
|
|
65226
65828
|
if (normalizedFile.startsWith("/") || /^[a-zA-Z]:\//.test(normalizedFile) || /^[a-zA-Z]:\\/.test(filePath)) return filePath;
|
|
65227
65829
|
return `${rootDirectory.replace(/\\/g, "/").replace(/\/$/, "")}/${normalizedFile.replace(/^\.\//, "")}`;
|
|
@@ -66138,7 +66740,7 @@ const warn = (message) => {
|
|
|
66138
66740
|
runSync(warn$1(message));
|
|
66139
66741
|
};
|
|
66140
66742
|
const CONFIG_BASENAME = "doctor.config";
|
|
66141
|
-
const CONFIG_EXTENSIONS = [
|
|
66743
|
+
const CONFIG_EXTENSIONS$1 = [
|
|
66142
66744
|
"ts",
|
|
66143
66745
|
"mts",
|
|
66144
66746
|
"cts",
|
|
@@ -66242,7 +66844,7 @@ const loadLegacyConfig = (directory) => {
|
|
|
66242
66844
|
};
|
|
66243
66845
|
const loadConfigFromDirectory = async (directory) => {
|
|
66244
66846
|
let sawBrokenConfigFile = false;
|
|
66245
|
-
for (const extension of CONFIG_EXTENSIONS) {
|
|
66847
|
+
for (const extension of CONFIG_EXTENSIONS$1) {
|
|
66246
66848
|
const filePath = Path.join(directory, `${CONFIG_BASENAME}.${extension}`);
|
|
66247
66849
|
if (!isFile(filePath)) continue;
|
|
66248
66850
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
@@ -66977,6 +67579,316 @@ const buildReactNativeDiagnostic = (input) => ({
|
|
|
66977
67579
|
column: input.column ?? 0,
|
|
66978
67580
|
category: input.category ?? "Correctness"
|
|
66979
67581
|
});
|
|
67582
|
+
const ANDROID_APP_BUILD_FILE_NAMES = ["build.gradle", "build.gradle.kts"];
|
|
67583
|
+
const BUILD_TYPES_BLOCK_PATTERN = /\bbuildTypes\s*\{/g;
|
|
67584
|
+
const RELEASE_STRING_MARKER = "__RD_RELEASE__";
|
|
67585
|
+
const RELEASE_BLOCK_PATTERNS = [/\brelease\s*\{/g, /\b(?:getByName|named)\s*\(\s*(?:["']release["']|__RD_RELEASE__)\s*\)\s*\{/g];
|
|
67586
|
+
const MINIFY_ASSIGNMENT_PATTERN = /\b(?:isMinifyEnabled|minifyEnabled)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
|
|
67587
|
+
const SHRINK_RESOURCES_ASSIGNMENT_PATTERN = /\b(?:isShrinkResources|shrinkResources)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
|
|
67588
|
+
const stripGradleComments = (contents) => {
|
|
67589
|
+
let result = "";
|
|
67590
|
+
let index = 0;
|
|
67591
|
+
let quote = null;
|
|
67592
|
+
while (index < contents.length) {
|
|
67593
|
+
const character = contents[index];
|
|
67594
|
+
const nextCharacter = contents[index + 1];
|
|
67595
|
+
if (quote !== null) {
|
|
67596
|
+
result += character;
|
|
67597
|
+
if (character === "\\") {
|
|
67598
|
+
result += nextCharacter ?? "";
|
|
67599
|
+
index += 2;
|
|
67600
|
+
continue;
|
|
67601
|
+
}
|
|
67602
|
+
if (character === quote) quote = null;
|
|
67603
|
+
index += 1;
|
|
67604
|
+
continue;
|
|
67605
|
+
}
|
|
67606
|
+
if (character === "\"" || character === "'") {
|
|
67607
|
+
quote = character;
|
|
67608
|
+
result += character;
|
|
67609
|
+
index += 1;
|
|
67610
|
+
continue;
|
|
67611
|
+
}
|
|
67612
|
+
if (character === "/" && nextCharacter === "/") {
|
|
67613
|
+
while (index < contents.length && contents[index] !== "\n") {
|
|
67614
|
+
result += " ";
|
|
67615
|
+
index += 1;
|
|
67616
|
+
}
|
|
67617
|
+
continue;
|
|
67618
|
+
}
|
|
67619
|
+
if (character === "/" && nextCharacter === "*") {
|
|
67620
|
+
result += " ";
|
|
67621
|
+
index += 2;
|
|
67622
|
+
while (index < contents.length && !(contents[index] === "*" && contents[index + 1] === "/")) {
|
|
67623
|
+
result += contents[index] === "\n" ? "\n" : " ";
|
|
67624
|
+
index += 1;
|
|
67625
|
+
}
|
|
67626
|
+
if (index < contents.length) {
|
|
67627
|
+
result += " ";
|
|
67628
|
+
index += 2;
|
|
67629
|
+
}
|
|
67630
|
+
continue;
|
|
67631
|
+
}
|
|
67632
|
+
result += character;
|
|
67633
|
+
index += 1;
|
|
67634
|
+
}
|
|
67635
|
+
return result;
|
|
67636
|
+
};
|
|
67637
|
+
const maskGradleStrings = (contents) => {
|
|
67638
|
+
let result = "";
|
|
67639
|
+
let index = 0;
|
|
67640
|
+
let quote = null;
|
|
67641
|
+
while (index < contents.length) {
|
|
67642
|
+
const character = contents[index];
|
|
67643
|
+
if (quote === null) {
|
|
67644
|
+
if (character === "\"" || character === "'") {
|
|
67645
|
+
quote = character;
|
|
67646
|
+
result += " ";
|
|
67647
|
+
} else result += character;
|
|
67648
|
+
index += 1;
|
|
67649
|
+
continue;
|
|
67650
|
+
}
|
|
67651
|
+
if (character === "\\") {
|
|
67652
|
+
result += " ";
|
|
67653
|
+
index += 2;
|
|
67654
|
+
continue;
|
|
67655
|
+
}
|
|
67656
|
+
if (character === quote) quote = null;
|
|
67657
|
+
result += character === "\n" ? "\n" : " ";
|
|
67658
|
+
index += 1;
|
|
67659
|
+
}
|
|
67660
|
+
return result;
|
|
67661
|
+
};
|
|
67662
|
+
const findBlockContents = (contents, pattern) => {
|
|
67663
|
+
const blocks = [];
|
|
67664
|
+
pattern.lastIndex = 0;
|
|
67665
|
+
let match = pattern.exec(contents);
|
|
67666
|
+
while (match !== null) {
|
|
67667
|
+
const openingBraceIndex = pattern.lastIndex - 1;
|
|
67668
|
+
let depth = 1;
|
|
67669
|
+
let index = openingBraceIndex + 1;
|
|
67670
|
+
let quote = null;
|
|
67671
|
+
while (index < contents.length && depth > 0) {
|
|
67672
|
+
const character = contents[index];
|
|
67673
|
+
if (quote !== null) {
|
|
67674
|
+
if (character === "\\") {
|
|
67675
|
+
index += 2;
|
|
67676
|
+
continue;
|
|
67677
|
+
}
|
|
67678
|
+
if (character === quote) quote = null;
|
|
67679
|
+
} else if (character === "\"" || character === "'") quote = character;
|
|
67680
|
+
else if (character === "{") depth += 1;
|
|
67681
|
+
else if (character === "}") depth -= 1;
|
|
67682
|
+
index += 1;
|
|
67683
|
+
}
|
|
67684
|
+
if (depth === 0) blocks.push(contents.slice(openingBraceIndex + 1, index - 1));
|
|
67685
|
+
match = pattern.exec(contents);
|
|
67686
|
+
}
|
|
67687
|
+
return blocks;
|
|
67688
|
+
};
|
|
67689
|
+
const getFinalStaticBoolean = (contents, pattern) => {
|
|
67690
|
+
pattern.lastIndex = 0;
|
|
67691
|
+
let finalValue = null;
|
|
67692
|
+
let match = pattern.exec(contents);
|
|
67693
|
+
while (match !== null) {
|
|
67694
|
+
const staticValue = match[1]?.trim().replace(/\)$/, "").trim();
|
|
67695
|
+
if (staticValue === "true") finalValue = true;
|
|
67696
|
+
else if (staticValue === "false") finalValue = false;
|
|
67697
|
+
else finalValue = null;
|
|
67698
|
+
match = pattern.exec(contents);
|
|
67699
|
+
}
|
|
67700
|
+
return finalValue;
|
|
67701
|
+
};
|
|
67702
|
+
const getReleaseBlocks = (contents) => findBlockContents(contents, BUILD_TYPES_BLOCK_PATTERN).flatMap((buildTypesBlock) => RELEASE_BLOCK_PATTERNS.flatMap((pattern) => findBlockContents(buildTypesBlock, pattern)));
|
|
67703
|
+
const readAndroidReleaseShrinking = (rootDirectory) => {
|
|
67704
|
+
for (const buildFileName of ANDROID_APP_BUILD_FILE_NAMES) {
|
|
67705
|
+
const filePath = Path.posix.join("android", "app", buildFileName);
|
|
67706
|
+
const absoluteFilePath = Path.join(rootDirectory, filePath);
|
|
67707
|
+
if (!isFile(absoluteFilePath)) continue;
|
|
67708
|
+
let contents;
|
|
67709
|
+
try {
|
|
67710
|
+
contents = stripGradleComments(NFS.readFileSync(absoluteFilePath, "utf-8"));
|
|
67711
|
+
} catch {
|
|
67712
|
+
return null;
|
|
67713
|
+
}
|
|
67714
|
+
const releaseBlocks = getReleaseBlocks(maskGradleStrings(contents.replace(/(["'])release\1/g, RELEASE_STRING_MARKER)));
|
|
67715
|
+
const [releaseBlock] = releaseBlocks;
|
|
67716
|
+
if (releaseBlock === void 0 || releaseBlocks.length !== 1) return null;
|
|
67717
|
+
const hasDisabledMinification = getFinalStaticBoolean(releaseBlock, MINIFY_ASSIGNMENT_PATTERN) === false;
|
|
67718
|
+
const hasDisabledResourceShrinking = getFinalStaticBoolean(releaseBlock, SHRINK_RESOURCES_ASSIGNMENT_PATTERN) === false;
|
|
67719
|
+
if (!hasDisabledMinification && !hasDisabledResourceShrinking) return null;
|
|
67720
|
+
return {
|
|
67721
|
+
filePath,
|
|
67722
|
+
hasDisabledMinification,
|
|
67723
|
+
hasDisabledResourceShrinking
|
|
67724
|
+
};
|
|
67725
|
+
}
|
|
67726
|
+
return null;
|
|
67727
|
+
};
|
|
67728
|
+
const checkReactNativeAndroidReleaseShrinking = (rootDirectory) => {
|
|
67729
|
+
const releaseShrinking = readAndroidReleaseShrinking(rootDirectory);
|
|
67730
|
+
if (releaseShrinking === null) return [];
|
|
67731
|
+
const disabledFeatures = [releaseShrinking.hasDisabledMinification ? "code minification" : null, releaseShrinking.hasDisabledResourceShrinking ? "resource shrinking" : null].filter((feature) => feature !== null);
|
|
67732
|
+
return [buildReactNativeDiagnostic({
|
|
67733
|
+
filePath: releaseShrinking.filePath,
|
|
67734
|
+
rule: "rn-android-release-shrinking-disabled",
|
|
67735
|
+
category: "Performance",
|
|
67736
|
+
message: `The Android release build explicitly disables ${disabledFeatures.join(" and ")}, leaving unreachable code or resources in the shipped app.`,
|
|
67737
|
+
help: "Enable release code minification and resource shrinking, then test the optimized build and add keep rules for libraries that require them."
|
|
67738
|
+
})];
|
|
67739
|
+
};
|
|
67740
|
+
const getTypescriptScriptKind = (fileName) => {
|
|
67741
|
+
if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
67742
|
+
if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
67743
|
+
if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
|
|
67744
|
+
return ts.ScriptKind.JS;
|
|
67745
|
+
};
|
|
67746
|
+
const BABEL_CONFIG_FILE_NAMES$1 = [
|
|
67747
|
+
"babel.config.js",
|
|
67748
|
+
"babel.config.cjs",
|
|
67749
|
+
"babel.config.mjs",
|
|
67750
|
+
"babel.config.ts",
|
|
67751
|
+
"babel.config.cts",
|
|
67752
|
+
"babel.config.json",
|
|
67753
|
+
".babelrc",
|
|
67754
|
+
".babelrc.js",
|
|
67755
|
+
".babelrc.cjs",
|
|
67756
|
+
".babelrc.mjs",
|
|
67757
|
+
".babelrc.cts",
|
|
67758
|
+
".babelrc.json"
|
|
67759
|
+
];
|
|
67760
|
+
const readUnknownPluginNames = (value) => {
|
|
67761
|
+
if (!Array.isArray(value)) return null;
|
|
67762
|
+
const pluginNames = [];
|
|
67763
|
+
for (const entry of value) {
|
|
67764
|
+
if (typeof entry === "string") {
|
|
67765
|
+
pluginNames.push(entry);
|
|
67766
|
+
continue;
|
|
67767
|
+
}
|
|
67768
|
+
if (Array.isArray(entry) && typeof entry[0] === "string") {
|
|
67769
|
+
pluginNames.push(entry[0]);
|
|
67770
|
+
continue;
|
|
67771
|
+
}
|
|
67772
|
+
return null;
|
|
67773
|
+
}
|
|
67774
|
+
return pluginNames;
|
|
67775
|
+
};
|
|
67776
|
+
const getStaticPropertyName$1 = (propertyName) => {
|
|
67777
|
+
if (ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName)) return propertyName.text;
|
|
67778
|
+
return null;
|
|
67779
|
+
};
|
|
67780
|
+
const getStaticPluginName = (expression) => {
|
|
67781
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
67782
|
+
if (ts.isStringLiteralLike(unwrappedExpression)) return unwrappedExpression.text;
|
|
67783
|
+
if (!ts.isArrayLiteralExpression(unwrappedExpression)) return null;
|
|
67784
|
+
const pluginExpression = unwrappedExpression.elements[0];
|
|
67785
|
+
return pluginExpression && ts.isStringLiteralLike(pluginExpression) ? pluginExpression.text : null;
|
|
67786
|
+
};
|
|
67787
|
+
const getPluginNamesFromObject = (objectExpression) => {
|
|
67788
|
+
if (objectExpression.properties.some((property) => ts.isSpreadAssignment(property))) return null;
|
|
67789
|
+
const pluginProperties = objectExpression.properties.filter((property) => ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "plugins");
|
|
67790
|
+
if (pluginProperties.length !== 1) return pluginProperties.length === 0 ? [] : null;
|
|
67791
|
+
const pluginListExpression = unwrapTypescriptExpression(pluginProperties[0].initializer);
|
|
67792
|
+
if (!ts.isArrayLiteralExpression(pluginListExpression)) return null;
|
|
67793
|
+
const pluginNames = [];
|
|
67794
|
+
for (const element of pluginListExpression.elements) {
|
|
67795
|
+
if (ts.isSpreadElement(element)) return null;
|
|
67796
|
+
const pluginName = getStaticPluginName(element);
|
|
67797
|
+
if (pluginName === null) return null;
|
|
67798
|
+
pluginNames.push(pluginName);
|
|
67799
|
+
}
|
|
67800
|
+
return pluginNames;
|
|
67801
|
+
};
|
|
67802
|
+
const isModuleExports = (expression) => ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.name.text === "exports" || ts.isElementAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.argumentExpression !== void 0 && ts.isStringLiteralLike(expression.argumentExpression) && expression.argumentExpression.text === "exports";
|
|
67803
|
+
const getDirectExportedObject = (sourceFile) => {
|
|
67804
|
+
const exportedExpressions = [];
|
|
67805
|
+
for (const statement of sourceFile.statements) {
|
|
67806
|
+
if (ts.isExportAssignment(statement)) {
|
|
67807
|
+
exportedExpressions.push(statement.expression);
|
|
67808
|
+
continue;
|
|
67809
|
+
}
|
|
67810
|
+
if (ts.isExpressionStatement(statement) && ts.isBinaryExpression(statement.expression) && statement.expression.operatorToken.kind === ts.SyntaxKind.EqualsToken && isModuleExports(statement.expression.left)) exportedExpressions.push(statement.expression.right);
|
|
67811
|
+
}
|
|
67812
|
+
if (exportedExpressions.length !== 1) return null;
|
|
67813
|
+
const exportedExpression = unwrapTypescriptExpression(exportedExpressions[0]);
|
|
67814
|
+
return ts.isObjectLiteralExpression(exportedExpression) ? exportedExpression : null;
|
|
67815
|
+
};
|
|
67816
|
+
const parseConfigPluginNames = (filePath, contents) => {
|
|
67817
|
+
try {
|
|
67818
|
+
const parsedJson = JSON.parse(contents);
|
|
67819
|
+
return isPlainObject(parsedJson) ? readUnknownPluginNames(parsedJson.plugins) : null;
|
|
67820
|
+
} catch {
|
|
67821
|
+
if (ts.transpileModule(contents, {
|
|
67822
|
+
fileName: filePath,
|
|
67823
|
+
reportDiagnostics: true,
|
|
67824
|
+
compilerOptions: { allowJs: true }
|
|
67825
|
+
}).diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) return null;
|
|
67826
|
+
const exportedObject = getDirectExportedObject(ts.createSourceFile(filePath, contents, ts.ScriptTarget.Latest, true, getTypescriptScriptKind(filePath)));
|
|
67827
|
+
return exportedObject === null ? null : getPluginNamesFromObject(exportedObject);
|
|
67828
|
+
}
|
|
67829
|
+
};
|
|
67830
|
+
const readStaticBabelPluginNames = (rootDirectory) => {
|
|
67831
|
+
for (const fileName of BABEL_CONFIG_FILE_NAMES$1) {
|
|
67832
|
+
const absoluteFilePath = Path.join(rootDirectory, fileName);
|
|
67833
|
+
if (!isFile(absoluteFilePath)) continue;
|
|
67834
|
+
try {
|
|
67835
|
+
return {
|
|
67836
|
+
filePath: fileName,
|
|
67837
|
+
pluginNames: parseConfigPluginNames(fileName, NFS.readFileSync(absoluteFilePath, "utf-8"))
|
|
67838
|
+
};
|
|
67839
|
+
} catch {
|
|
67840
|
+
return {
|
|
67841
|
+
filePath: fileName,
|
|
67842
|
+
pluginNames: null
|
|
67843
|
+
};
|
|
67844
|
+
}
|
|
67845
|
+
}
|
|
67846
|
+
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
67847
|
+
if (!isPlainObject(packageJson.babel)) return null;
|
|
67848
|
+
return {
|
|
67849
|
+
filePath: "package.json",
|
|
67850
|
+
pluginNames: readUnknownPluginNames(packageJson.babel.plugins)
|
|
67851
|
+
};
|
|
67852
|
+
};
|
|
67853
|
+
const REACT_COMPILER_PLUGIN_NAMES = new Set(["babel-plugin-react-compiler", "react-compiler"]);
|
|
67854
|
+
const REANIMATED_PLUGIN_NAME = "react-native-reanimated/plugin";
|
|
67855
|
+
const WORKLETS_PLUGIN_NAME = "react-native-worklets/plugin";
|
|
67856
|
+
const checkReactCompilerPluginOrder = (filePath, pluginNames) => {
|
|
67857
|
+
if (pluginNames.findIndex((pluginName) => REACT_COMPILER_PLUGIN_NAMES.has(pluginName)) <= 0) return [];
|
|
67858
|
+
return [buildReactNativeDiagnostic({
|
|
67859
|
+
filePath,
|
|
67860
|
+
rule: "rn-react-compiler-plugin-first",
|
|
67861
|
+
category: "Performance",
|
|
67862
|
+
message: "The React Compiler Babel plugin is not first, so an earlier transform can change component or hook code before the compiler analyzes it.",
|
|
67863
|
+
help: "Move `babel-plugin-react-compiler` to the first entry in the Babel `plugins` array."
|
|
67864
|
+
})];
|
|
67865
|
+
};
|
|
67866
|
+
const checkReanimatedPluginOrder = (project, filePath, pluginNames) => {
|
|
67867
|
+
const reanimatedMajorVersion = project.reanimatedVersion === null || project.reanimatedVersion === void 0 ? null : getLowestDependencyMajor(project.reanimatedVersion);
|
|
67868
|
+
if (reanimatedMajorVersion === null || reanimatedMajorVersion < 4) return [];
|
|
67869
|
+
const diagnostics = [];
|
|
67870
|
+
if (pluginNames.includes(REANIMATED_PLUGIN_NAME)) diagnostics.push(buildReactNativeDiagnostic({
|
|
67871
|
+
filePath,
|
|
67872
|
+
rule: "rn-reanimated-worklets-plugin-last",
|
|
67873
|
+
category: "Performance",
|
|
67874
|
+
message: "This Reanimated 4 project still uses `react-native-reanimated/plugin`, which was renamed to the Worklets Babel plugin.",
|
|
67875
|
+
help: "Replace it with `react-native-worklets/plugin` and keep that plugin last in the Babel `plugins` array."
|
|
67876
|
+
}));
|
|
67877
|
+
const workletsPluginIndex = pluginNames.lastIndexOf(WORKLETS_PLUGIN_NAME);
|
|
67878
|
+
if (workletsPluginIndex !== -1 && workletsPluginIndex !== pluginNames.length - 1) diagnostics.push(buildReactNativeDiagnostic({
|
|
67879
|
+
filePath,
|
|
67880
|
+
rule: "rn-reanimated-worklets-plugin-last",
|
|
67881
|
+
category: "Performance",
|
|
67882
|
+
message: "`react-native-worklets/plugin` is not last in the Babel `plugins` array, so later transforms can prevent worklets from being compiled correctly.",
|
|
67883
|
+
help: "Move `react-native-worklets/plugin` to the final entry in the Babel `plugins` array."
|
|
67884
|
+
}));
|
|
67885
|
+
return diagnostics;
|
|
67886
|
+
};
|
|
67887
|
+
const checkReactNativeBabelPluginOrder = (rootDirectory, project) => {
|
|
67888
|
+
const babelPlugins = readStaticBabelPluginNames(rootDirectory);
|
|
67889
|
+
if (babelPlugins === null || babelPlugins.pluginNames === null) return [];
|
|
67890
|
+
return [...checkReactCompilerPluginOrder(babelPlugins.filePath, babelPlugins.pluginNames), ...checkReanimatedPluginOrder(project, babelPlugins.filePath, babelPlugins.pluginNames)];
|
|
67891
|
+
};
|
|
66980
67892
|
const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
|
|
66981
67893
|
const isBuilderBobLibrary = (packageJson) => {
|
|
66982
67894
|
const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
|
|
@@ -67053,7 +67965,12 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
67053
67965
|
const isReactNativeProject = (project) => project.framework === "react-native" || project.framework === "expo" || project.hasReactNativeWorkspace || project.expoVersion !== null;
|
|
67054
67966
|
const checkReactNativeProject = (rootDirectory, project) => {
|
|
67055
67967
|
if (!isReactNativeProject(project)) return [];
|
|
67056
|
-
return [
|
|
67968
|
+
return [
|
|
67969
|
+
...checkReactNativeMetroBabelPreset(rootDirectory),
|
|
67970
|
+
...checkReactNativeBabelPluginOrder(rootDirectory, project),
|
|
67971
|
+
...checkReactNativeAndroidReleaseShrinking(rootDirectory),
|
|
67972
|
+
...checkReactNativeLibraryDependencies(rootDirectory)
|
|
67973
|
+
];
|
|
67057
67974
|
};
|
|
67058
67975
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
67059
67976
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
@@ -67204,17 +68121,6 @@ const checkReactServerComponentsAdvisory = (scanDirectory, project) => {
|
|
|
67204
68121
|
}
|
|
67205
68122
|
return diagnostics;
|
|
67206
68123
|
};
|
|
67207
|
-
const getTypescriptScriptKind = (fileName) => {
|
|
67208
|
-
if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
67209
|
-
if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
67210
|
-
if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
|
|
67211
|
-
return ts.ScriptKind.JS;
|
|
67212
|
-
};
|
|
67213
|
-
const unwrapTypescriptExpression = (expression) => {
|
|
67214
|
-
let currentExpression = expression;
|
|
67215
|
-
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
67216
|
-
return currentExpression;
|
|
67217
|
-
};
|
|
67218
68124
|
const EMPTY_MOTION_EXPRESSION_EVIDENCE = {
|
|
67219
68125
|
isAnimationFunction: false,
|
|
67220
68126
|
isMotionComponent: false,
|
|
@@ -67770,7 +68676,11 @@ const buildCapabilities = (project) => {
|
|
|
67770
68676
|
capabilities.add(project.framework);
|
|
67771
68677
|
if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
|
|
67772
68678
|
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
67773
|
-
if (project.expoVersion !== null)
|
|
68679
|
+
if (project.expoVersion !== null) {
|
|
68680
|
+
capabilities.add("expo");
|
|
68681
|
+
const expoSdkMajorVersion = getLowestDependencyMajor(project.expoVersion);
|
|
68682
|
+
if (expoSdkMajorVersion !== null && expoSdkMajorVersion >= 54) capabilities.add("expo:54");
|
|
68683
|
+
}
|
|
67774
68684
|
if ((project.framework === "nextjs" || project.framework === "tanstack-start" || project.framework === "remix") && !project.isStaticExport) capabilities.add("server-actions");
|
|
67775
68685
|
if (SSR_FRAMEWORKS.has(project.framework) || project.hasSsrDependency) capabilities.add("ssr");
|
|
67776
68686
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
@@ -67834,6 +68744,11 @@ const buildCapabilities = (project) => {
|
|
|
67834
68744
|
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
67835
68745
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
67836
68746
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
68747
|
+
if (project.reanimatedVersion !== void 0 && project.reanimatedVersion !== null) {
|
|
68748
|
+
capabilities.add("reanimated");
|
|
68749
|
+
const reanimatedMajorVersion = getLowestDependencyMajor(project.reanimatedVersion);
|
|
68750
|
+
if (reanimatedMajorVersion !== null && reanimatedMajorVersion >= 4) capabilities.add("reanimated:4");
|
|
68751
|
+
}
|
|
67837
68752
|
if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
|
|
67838
68753
|
if (project.styledComponentsVersion) {
|
|
67839
68754
|
capabilities.add("styled-components");
|
|
@@ -69173,7 +70088,10 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
69173
70088
|
if (argvLengthChars > spawnArgsLengthCap) return yield* foldSpawnFailure(`spawn ENAMETOOLONG (${argvLengthChars} argv chars exceed ${spawnArgsLengthCap})`);
|
|
69174
70089
|
const handle = yield* spawner.spawn(make$1(input.command, [...input.args], {
|
|
69175
70090
|
cwd: input.directory,
|
|
69176
|
-
env: input.
|
|
70091
|
+
env: input.command === "git" ? {
|
|
70092
|
+
...input.env,
|
|
70093
|
+
GIT_DIR: void 0
|
|
70094
|
+
} : input.env,
|
|
69177
70095
|
extendEnv: true
|
|
69178
70096
|
}));
|
|
69179
70097
|
const maxStdoutBytes = input.maxStdoutBytes;
|
|
@@ -69446,7 +70364,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
69446
70364
|
"--diff-filter=ACMR",
|
|
69447
70365
|
"--relative"
|
|
69448
70366
|
]).pipe(map$3((result) => {
|
|
69449
|
-
if (result.status !== 0) return
|
|
70367
|
+
if (result.status !== 0) return null;
|
|
69450
70368
|
return splitNullSeparated(result.stdout);
|
|
69451
70369
|
})),
|
|
69452
70370
|
showStagedContent: (directory, relativePath, options) => runCommand({
|
|
@@ -69731,7 +70649,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
69731
70649
|
const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
|
|
69732
70650
|
const normalizeConfigForHash = (config) => {
|
|
69733
70651
|
const clone = JSON.parse(JSON.stringify(config));
|
|
69734
|
-
if (clone?.settings?.["react-doctor"])
|
|
70652
|
+
if (clone?.settings?.["react-doctor"]) {
|
|
70653
|
+
const reactDoctorSettings = clone.settings["react-doctor"];
|
|
70654
|
+
reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
|
|
70655
|
+
if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
|
|
70656
|
+
}
|
|
69735
70657
|
if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
|
|
69736
70658
|
return clone;
|
|
69737
70659
|
};
|
|
@@ -69890,13 +70812,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
69890
70812
|
}
|
|
69891
70813
|
return enabled;
|
|
69892
70814
|
};
|
|
69893
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
70815
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, runtimeGlobals, unpluginAutoImportGlobalScopes, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
69894
70816
|
const hasIncludedTags = includedTags.size > 0;
|
|
69895
70817
|
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
69896
70818
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
69897
70819
|
const jsPlugins = [];
|
|
69898
70820
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
69899
70821
|
const capabilities = getCapabilities(project);
|
|
70822
|
+
const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
|
|
69900
70823
|
const enabledReactDoctorRules = {};
|
|
69901
70824
|
for (const registryEntry of REACT_DOCTOR_RULES) {
|
|
69902
70825
|
const rule = reactDoctorPlugin.rules[registryEntry.id];
|
|
@@ -69942,8 +70865,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
69942
70865
|
jsPlugins: [...jsPlugins, pluginPath],
|
|
69943
70866
|
settings: { "react-doctor": {
|
|
69944
70867
|
framework: project.framework,
|
|
69945
|
-
rootDirectory:
|
|
70868
|
+
rootDirectory: settingsRootDirectory,
|
|
69946
70869
|
capabilities: [...capabilities].sort(),
|
|
70870
|
+
...runtimeGlobals && runtimeGlobals.length > 0 ? { runtimeGlobals: [...runtimeGlobals] } : {},
|
|
70871
|
+
...unpluginAutoImportGlobalScopes && unpluginAutoImportGlobalScopes.length > 0 ? {
|
|
70872
|
+
unpluginAutoImportRootDirectories: [...new Set([settingsRootDirectory, project.rootDirectory])],
|
|
70873
|
+
unpluginAutoImportGlobalScopes: unpluginAutoImportGlobalScopes.map((scope) => ({
|
|
70874
|
+
directory: scope.directory,
|
|
70875
|
+
names: [...scope.names]
|
|
70876
|
+
}))
|
|
70877
|
+
} : {},
|
|
69947
70878
|
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
69948
70879
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
69949
70880
|
} },
|
|
@@ -69954,6 +70885,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
69954
70885
|
}
|
|
69955
70886
|
};
|
|
69956
70887
|
};
|
|
70888
|
+
const AUTO_IMPORT_ADAPTER_PATTERN = /^unplugin-auto-import\/(?:astro|esbuild|rollup|rolldown|rspack|vite|webpack)$/;
|
|
70889
|
+
const CONFIG_BASENAMES = [
|
|
70890
|
+
"astro.config",
|
|
70891
|
+
"esbuild.config",
|
|
70892
|
+
"rollup.config",
|
|
70893
|
+
"rolldown.config",
|
|
70894
|
+
"rspack.config",
|
|
70895
|
+
"vite.config",
|
|
70896
|
+
"webpack.config"
|
|
70897
|
+
];
|
|
70898
|
+
const CONFIG_EXTENSIONS = [
|
|
70899
|
+
".cjs",
|
|
70900
|
+
".cts",
|
|
70901
|
+
".js",
|
|
70902
|
+
".mjs",
|
|
70903
|
+
".mts",
|
|
70904
|
+
".ts"
|
|
70905
|
+
];
|
|
70906
|
+
const CONFIG_FILENAMES = new Set(CONFIG_BASENAMES.flatMap((basename) => CONFIG_EXTENSIONS.map((extension) => `${basename}${extension}`)));
|
|
70907
|
+
const DEFAULT_ESLINT_GLOBALS_PATH = ".eslintrc-auto-import.json";
|
|
70908
|
+
const SUPPORTED_GLOBAL_VALUES = new Set([
|
|
70909
|
+
true,
|
|
70910
|
+
false,
|
|
70911
|
+
"readable",
|
|
70912
|
+
"readonly",
|
|
70913
|
+
"writable",
|
|
70914
|
+
"writeable"
|
|
70915
|
+
]);
|
|
70916
|
+
const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
|
|
70917
|
+
if (ts.isSpreadAssignment(property)) return false;
|
|
70918
|
+
const name = ts.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
|
|
70919
|
+
return (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) && name.text === propertyName;
|
|
70920
|
+
}) ?? null;
|
|
70921
|
+
const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !ts.isSpreadAssignment(property) && ts.isComputedPropertyName(property.name) && !ts.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
|
|
70922
|
+
const getStaticPropertyAssignment = (objectExpression, propertyName) => {
|
|
70923
|
+
const property = getStaticProperty(objectExpression, propertyName);
|
|
70924
|
+
return property && ts.isPropertyAssignment(property) ? property : null;
|
|
70925
|
+
};
|
|
70926
|
+
const getRequireModuleSpecifier = (expression) => {
|
|
70927
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
70928
|
+
if (ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
|
|
70929
|
+
if (!ts.isCallExpression(unwrappedExpression) || !ts.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
|
|
70930
|
+
const moduleSpecifier = unwrappedExpression.arguments[0];
|
|
70931
|
+
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
70932
|
+
};
|
|
70933
|
+
const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
|
|
70934
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
70935
|
+
return ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
|
|
70936
|
+
};
|
|
70937
|
+
const isCommonJsExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
|
|
70938
|
+
const isTopLevelExpression = (node) => {
|
|
70939
|
+
let ancestor = node.parent;
|
|
70940
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
70941
|
+
if (ts.isExpressionStatement(ancestor)) return ts.isSourceFile(ancestor.parent);
|
|
70942
|
+
if (!ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isAwaitExpression(ancestor)) return false;
|
|
70943
|
+
ancestor = ancestor.parent;
|
|
70944
|
+
}
|
|
70945
|
+
return false;
|
|
70946
|
+
};
|
|
70947
|
+
const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
|
|
70948
|
+
let ancestor = node.parent;
|
|
70949
|
+
let didFindConfigProperty = false;
|
|
70950
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
70951
|
+
if (!didFindConfigProperty && !ts.isArrayLiteralExpression(ancestor) && !ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isPropertyAssignment(ancestor)) return false;
|
|
70952
|
+
if (ts.isPropertyAssignment(ancestor)) {
|
|
70953
|
+
const isConfigProperty = (ts.isIdentifier(ancestor.name) || ts.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
|
|
70954
|
+
if (didFindConfigProperty || !isConfigProperty) return false;
|
|
70955
|
+
if (!ts.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(ts.isSpreadAssignment)) return false;
|
|
70956
|
+
didFindConfigProperty = true;
|
|
70957
|
+
ancestor = ancestor.parent;
|
|
70958
|
+
continue;
|
|
70959
|
+
}
|
|
70960
|
+
if (didFindConfigProperty) {
|
|
70961
|
+
if (ts.isExportAssignment(ancestor)) return true;
|
|
70962
|
+
if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
|
|
70963
|
+
if (propertyName === "plugins" && ts.isCallExpression(ancestor) && (ts.isIdentifier(ancestor.expression) ? esbuildBindings.has(ancestor.expression.text) : ts.isPropertyAccessExpression(ancestor.expression) && ancestor.expression.name.text === "build" && (ts.isIdentifier(ancestor.expression.expression) && esbuildNamespaceBindings.has(ancestor.expression.expression.text) || getRequireModuleSpecifier(ancestor.expression.expression) === "esbuild"))) return isTopLevelExpression(ancestor);
|
|
70964
|
+
if (!(ts.isObjectLiteralExpression(ancestor) || ts.isParenthesizedExpression(ancestor) || ts.isAsExpression(ancestor) || ts.isSatisfiesExpression(ancestor) || ts.isNonNullExpression(ancestor) || ts.isTypeAssertionExpression(ancestor) || ts.isCallExpression(ancestor) && ts.isIdentifier(ancestor.expression) && ancestor.expression.text === "defineConfig")) return false;
|
|
70965
|
+
}
|
|
70966
|
+
ancestor = ancestor.parent;
|
|
70967
|
+
}
|
|
70968
|
+
return false;
|
|
70969
|
+
};
|
|
70970
|
+
const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory) => {
|
|
70971
|
+
const optionsExpression = callExpression.arguments[0];
|
|
70972
|
+
if (!optionsExpression) return null;
|
|
70973
|
+
const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
|
|
70974
|
+
if (!ts.isObjectLiteralExpression(unwrappedOptions)) return null;
|
|
70975
|
+
if (unwrappedOptions.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
|
|
70976
|
+
if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
|
|
70977
|
+
const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
|
|
70978
|
+
if (!eslintrcProperty) return null;
|
|
70979
|
+
const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
|
|
70980
|
+
if (!ts.isObjectLiteralExpression(eslintrcExpression)) return null;
|
|
70981
|
+
if (eslintrcExpression.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
|
|
70982
|
+
const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
|
|
70983
|
+
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== ts.SyntaxKind.TrueKeyword) return null;
|
|
70984
|
+
const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
|
|
70985
|
+
if (!filepathProperty) return Path.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
|
|
70986
|
+
if (!ts.isPropertyAssignment(filepathProperty)) return null;
|
|
70987
|
+
const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
|
|
70988
|
+
return ts.isStringLiteralLike(filepathExpression) ? Path.resolve(packageDirectory, filepathExpression.text) : null;
|
|
70989
|
+
};
|
|
70990
|
+
const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
70991
|
+
let sourceText;
|
|
70992
|
+
try {
|
|
70993
|
+
sourceText = NFS.readFileSync(configPath, "utf8");
|
|
70994
|
+
} catch {
|
|
70995
|
+
return {
|
|
70996
|
+
didFindActiveAutoImport: false,
|
|
70997
|
+
globalsPaths: []
|
|
70998
|
+
};
|
|
70999
|
+
}
|
|
71000
|
+
const sourceFile = ts.createSourceFile(configPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
71001
|
+
const autoImportBindings = /* @__PURE__ */ new Map();
|
|
71002
|
+
const esbuildBindings = /* @__PURE__ */ new Set();
|
|
71003
|
+
const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
|
|
71004
|
+
for (const statement of sourceFile.statements) {
|
|
71005
|
+
if (ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
71006
|
+
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
71007
|
+
if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
71008
|
+
const defaultBinding = statement.importClause?.name;
|
|
71009
|
+
if (defaultBinding) autoImportBindings.set(defaultBinding.text, moduleSpecifier);
|
|
71010
|
+
}
|
|
71011
|
+
if (moduleSpecifier === "esbuild") {
|
|
71012
|
+
const defaultBinding = statement.importClause?.name;
|
|
71013
|
+
if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
|
|
71014
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
71015
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
71016
|
+
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
|
|
71017
|
+
}
|
|
71018
|
+
if (namedBindings && ts.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
|
|
71019
|
+
}
|
|
71020
|
+
}
|
|
71021
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
71022
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
71023
|
+
if (!declaration.initializer) continue;
|
|
71024
|
+
const declarationName = ts.isIdentifier(declaration.name) ? declaration.name.text : null;
|
|
71025
|
+
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
71026
|
+
if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
|
|
71027
|
+
if (moduleSpecifier === "esbuild") {
|
|
71028
|
+
if (declarationName) esbuildNamespaceBindings.add(declarationName);
|
|
71029
|
+
if (ts.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
|
|
71030
|
+
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
71031
|
+
if (ts.isIdentifier(importedName) && importedName.text === "build" && ts.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
|
|
71032
|
+
}
|
|
71033
|
+
}
|
|
71034
|
+
if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
|
|
71035
|
+
}
|
|
71036
|
+
}
|
|
71037
|
+
const globalsPaths = /* @__PURE__ */ new Set();
|
|
71038
|
+
let didFindActiveAutoImport = false;
|
|
71039
|
+
let didFindUnsafeActiveAutoImport = false;
|
|
71040
|
+
const visit = (node) => {
|
|
71041
|
+
if (ts.isCallExpression(node)) {
|
|
71042
|
+
const moduleSpecifier = ts.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
|
|
71043
|
+
if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
71044
|
+
if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
|
|
71045
|
+
didFindActiveAutoImport = true;
|
|
71046
|
+
const globalsPath = getGlobalsPathFromActiveAutoImportCall(node, packageDirectory);
|
|
71047
|
+
if (globalsPath) globalsPaths.add(globalsPath);
|
|
71048
|
+
else didFindUnsafeActiveAutoImport = true;
|
|
71049
|
+
}
|
|
71050
|
+
}
|
|
71051
|
+
}
|
|
71052
|
+
ts.forEachChild(node, visit);
|
|
71053
|
+
};
|
|
71054
|
+
visit(sourceFile);
|
|
71055
|
+
return {
|
|
71056
|
+
didFindActiveAutoImport,
|
|
71057
|
+
globalsPaths: didFindUnsafeActiveAutoImport ? [] : [...globalsPaths]
|
|
71058
|
+
};
|
|
71059
|
+
};
|
|
71060
|
+
const collectGeneratedGlobalNames = (globalsPath, rootDirectory) => {
|
|
71061
|
+
const relativePath = Path.relative(rootDirectory, globalsPath);
|
|
71062
|
+
if (relativePath.startsWith("..") || Path.isAbsolute(relativePath)) return [];
|
|
71063
|
+
const parsed = failOpenReadJson(globalsPath, null);
|
|
71064
|
+
if (!isPlainObject(parsed) || !isPlainObject(parsed.globals)) return [];
|
|
71065
|
+
return Object.entries(parsed.globals).filter((entry) => entry[0].length > 0 && (typeof entry[1] === "boolean" || typeof entry[1] === "string") && SUPPORTED_GLOBAL_VALUES.has(entry[1])).map(([name]) => name).sort();
|
|
71066
|
+
};
|
|
71067
|
+
const findOwningPackageDirectory = (absoluteFilePath, rootDirectory, cache) => {
|
|
71068
|
+
let currentDirectory = Path.dirname(absoluteFilePath);
|
|
71069
|
+
const visitedDirectories = [];
|
|
71070
|
+
while (true) {
|
|
71071
|
+
const cachedDirectory = cache.get(currentDirectory);
|
|
71072
|
+
if (cachedDirectory !== void 0) {
|
|
71073
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, cachedDirectory);
|
|
71074
|
+
return cachedDirectory;
|
|
71075
|
+
}
|
|
71076
|
+
const relativeDirectory = Path.relative(rootDirectory, currentDirectory);
|
|
71077
|
+
if (relativeDirectory.startsWith("..") || Path.isAbsolute(relativeDirectory)) {
|
|
71078
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
71079
|
+
return null;
|
|
71080
|
+
}
|
|
71081
|
+
visitedDirectories.push(currentDirectory);
|
|
71082
|
+
if (NFS.existsSync(Path.join(currentDirectory, "package.json"))) {
|
|
71083
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, currentDirectory);
|
|
71084
|
+
return currentDirectory;
|
|
71085
|
+
}
|
|
71086
|
+
if (currentDirectory === rootDirectory) {
|
|
71087
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
71088
|
+
return null;
|
|
71089
|
+
}
|
|
71090
|
+
currentDirectory = Path.dirname(currentDirectory);
|
|
71091
|
+
}
|
|
71092
|
+
};
|
|
71093
|
+
const collectPackageGlobalNames = (packageDirectory, rootDirectory) => {
|
|
71094
|
+
let directoryEntries;
|
|
71095
|
+
try {
|
|
71096
|
+
directoryEntries = NFS.readdirSync(packageDirectory, { withFileTypes: true });
|
|
71097
|
+
} catch {
|
|
71098
|
+
return [];
|
|
71099
|
+
}
|
|
71100
|
+
const configuredGlobalsPaths = [];
|
|
71101
|
+
for (const entry of directoryEntries) {
|
|
71102
|
+
if (!entry.isFile() && !entry.isSymbolicLink() || !CONFIG_FILENAMES.has(entry.name)) continue;
|
|
71103
|
+
const configGlobalsPaths = collectGlobalsPathsFromConfig(Path.join(packageDirectory, entry.name), packageDirectory);
|
|
71104
|
+
if (configGlobalsPaths.didFindActiveAutoImport) configuredGlobalsPaths.push(configGlobalsPaths.globalsPaths.toSorted());
|
|
71105
|
+
}
|
|
71106
|
+
if (configuredGlobalsPaths.length === 0) return [];
|
|
71107
|
+
const globalsPaths = configuredGlobalsPaths[0];
|
|
71108
|
+
if (configuredGlobalsPaths.some((candidatePaths) => candidatePaths.length !== globalsPaths.length || candidatePaths.some((candidatePath, index) => candidatePath !== globalsPaths[index]))) return [];
|
|
71109
|
+
const names = /* @__PURE__ */ new Set();
|
|
71110
|
+
for (const globalsPath of globalsPaths) for (const name of collectGeneratedGlobalNames(globalsPath, rootDirectory)) names.add(name);
|
|
71111
|
+
return [...names].sort();
|
|
71112
|
+
};
|
|
71113
|
+
const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }) => {
|
|
71114
|
+
const absoluteRootDirectory = Path.resolve(rootDirectory);
|
|
71115
|
+
const packageDirectoryCache = /* @__PURE__ */ new Map();
|
|
71116
|
+
const packageDirectories = /* @__PURE__ */ new Set();
|
|
71117
|
+
for (const candidateFile of candidateFiles) {
|
|
71118
|
+
const packageDirectory = findOwningPackageDirectory(Path.resolve(absoluteRootDirectory, candidateFile), absoluteRootDirectory, packageDirectoryCache);
|
|
71119
|
+
if (packageDirectory) packageDirectories.add(packageDirectory);
|
|
71120
|
+
}
|
|
71121
|
+
const scopes = [...packageDirectories].map((packageDirectory) => ({
|
|
71122
|
+
directory: Path.relative(absoluteRootDirectory, packageDirectory).replaceAll("\\", "/"),
|
|
71123
|
+
names: collectPackageGlobalNames(packageDirectory, absoluteRootDirectory)
|
|
71124
|
+
})).sort((firstScope, secondScope) => firstScope.directory.localeCompare(secondScope.directory));
|
|
71125
|
+
return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
|
|
71126
|
+
};
|
|
69957
71127
|
const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
|
|
69958
71128
|
const decodeFileDiagnostics = (raw) => {
|
|
69959
71129
|
if (!Array.isArray(raw)) return null;
|
|
@@ -70276,6 +71446,56 @@ const appendReanimatedSharedValueHint = (help, rule, project) => {
|
|
|
70276
71446
|
if (!help) return REANIMATED_SHARED_VALUE_HINT;
|
|
70277
71447
|
return `${help}\n\n${REANIMATED_SHARED_VALUE_HINT}`;
|
|
70278
71448
|
};
|
|
71449
|
+
const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
|
|
71450
|
+
const boundedOffset = Math.min(Math.max(utf8Offset, 0), sourceBuffer.length);
|
|
71451
|
+
let lineStartOffset = boundedOffset;
|
|
71452
|
+
while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
|
|
71453
|
+
return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
|
|
71454
|
+
};
|
|
71455
|
+
const utf8OffsetFromSourcePosition = (sourceBuffer, lineNumber, zeroBasedColumn) => {
|
|
71456
|
+
if (lineNumber < 1 || zeroBasedColumn < 0) return null;
|
|
71457
|
+
const sourceLines = sourceBuffer.toString("utf8").split("\n");
|
|
71458
|
+
const sourceLine = sourceLines[lineNumber - 1];
|
|
71459
|
+
if (sourceLine === void 0 || zeroBasedColumn > sourceLine.length) return null;
|
|
71460
|
+
const precedingLines = sourceLines.slice(0, lineNumber - 1).join("\n");
|
|
71461
|
+
return (lineNumber === 1 ? 0 : Buffer.byteLength(precedingLines) + Buffer.byteLength("\n")) + Buffer.byteLength(sourceLine.slice(0, zeroBasedColumn));
|
|
71462
|
+
};
|
|
71463
|
+
const mapPreparedSourceSpan = (span, preparedSourceMap) => {
|
|
71464
|
+
const generatedLine = lineOfUtf8Offset(preparedSourceMap.generatedBuffer, span.offset);
|
|
71465
|
+
const generatedColumn = columnOfUtf8Offset(preparedSourceMap.generatedBuffer, span.offset) - 1;
|
|
71466
|
+
const originalStart = originalPositionFor(preparedSourceMap.traceMap, {
|
|
71467
|
+
line: generatedLine,
|
|
71468
|
+
column: generatedColumn
|
|
71469
|
+
});
|
|
71470
|
+
if (originalStart.source === null || originalStart.line === null || originalStart.column === null) return null;
|
|
71471
|
+
const originalOffset = utf8OffsetFromSourcePosition(preparedSourceMap.sourceBuffer, originalStart.line, originalStart.column);
|
|
71472
|
+
if (originalOffset === null) return null;
|
|
71473
|
+
const generatedSpan = preparedSourceMap.generatedBuffer.subarray(span.offset, span.offset + span.length);
|
|
71474
|
+
return {
|
|
71475
|
+
offset: originalOffset,
|
|
71476
|
+
length: preparedSourceMap.sourceBuffer.subarray(originalOffset, originalOffset + generatedSpan.length).equals(generatedSpan) ? generatedSpan.length : 0,
|
|
71477
|
+
line: originalStart.line,
|
|
71478
|
+
column: originalStart.column + 1
|
|
71479
|
+
};
|
|
71480
|
+
};
|
|
71481
|
+
const mapPreparedSourceLabels = (labels, preparedSourceMap) => {
|
|
71482
|
+
const primaryLabel = labels[0];
|
|
71483
|
+
if (primaryLabel === void 0) return null;
|
|
71484
|
+
const primarySpan = mapPreparedSourceSpan(primaryLabel.span, preparedSourceMap);
|
|
71485
|
+
if (primarySpan === null) return null;
|
|
71486
|
+
const mappedLabels = [{
|
|
71487
|
+
...primaryLabel,
|
|
71488
|
+
span: primarySpan
|
|
71489
|
+
}];
|
|
71490
|
+
for (const relatedLabel of labels.slice(1)) {
|
|
71491
|
+
const relatedSpan = mapPreparedSourceSpan(relatedLabel.span, preparedSourceMap);
|
|
71492
|
+
if (relatedSpan !== null) mappedLabels.push({
|
|
71493
|
+
...relatedLabel,
|
|
71494
|
+
span: relatedSpan
|
|
71495
|
+
});
|
|
71496
|
+
}
|
|
71497
|
+
return mappedLabels;
|
|
71498
|
+
};
|
|
70279
71499
|
const REDACTED_PLACEHOLDER = "<redacted>";
|
|
70280
71500
|
const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
|
|
70281
71501
|
const KNOWN_SECRET_RULES = [
|
|
@@ -70991,7 +72211,7 @@ const resolveMatchByOccurrence = (rule, category) => OCCURRENCE_MATCHED_CATEGORI
|
|
|
70991
72211
|
* with empty text still carry a useful jump target, so they're kept
|
|
70992
72212
|
* with a neutral message.
|
|
70993
72213
|
*/
|
|
70994
|
-
const buildRelatedLocations = (labels, filePath) => {
|
|
72214
|
+
const buildRelatedLocations = (labels, filePath, sourceBuffer) => {
|
|
70995
72215
|
if (labels.length <= 1) return [];
|
|
70996
72216
|
const related = [];
|
|
70997
72217
|
for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
|
|
@@ -70999,8 +72219,8 @@ const buildRelatedLocations = (labels, filePath) => {
|
|
|
70999
72219
|
if (!label?.span) continue;
|
|
71000
72220
|
related.push({
|
|
71001
72221
|
filePath,
|
|
71002
|
-
line: label.span.line ?? 0,
|
|
71003
|
-
column: label.span.column ?? 0,
|
|
72222
|
+
line: sourceBuffer === null ? label.span.line ?? 0 : lineOfUtf8Offset(sourceBuffer, label.span.offset),
|
|
72223
|
+
column: sourceBuffer === null ? label.span.column ?? 0 : columnOfUtf8Offset(sourceBuffer, label.span.offset),
|
|
71004
72224
|
offset: label.span.offset,
|
|
71005
72225
|
length: label.span.length,
|
|
71006
72226
|
message: label.label ?? ""
|
|
@@ -71020,7 +72240,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
|
|
|
71020
72240
|
* to the first `{`. Raises `OxlintOutputUnparseable` when the
|
|
71021
72241
|
* stdout isn't valid JSON or doesn't carry a `diagnostics` array.
|
|
71022
72242
|
*/
|
|
71023
|
-
const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
72243
|
+
const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath) => {
|
|
71024
72244
|
if (!stdout) return [];
|
|
71025
72245
|
const jsonStart = stdout.indexOf("{");
|
|
71026
72246
|
const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
|
|
@@ -71037,8 +72257,11 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71037
72257
|
const sourceBufferCache = /* @__PURE__ */ new Map();
|
|
71038
72258
|
const sourceLinesCache = /* @__PURE__ */ new Map();
|
|
71039
72259
|
const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
|
|
72260
|
+
const resolveMappedSourceFilename = (filename) => sourcePathByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
|
|
72261
|
+
const resolvePreparedSourceMap = (filename) => sourceMapByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
|
|
72262
|
+
const resolveSourceFilename = (filename) => resolveMappedSourceFilename(filename) ?? filename;
|
|
71040
72263
|
const readSourceBuffer = (filename) => {
|
|
71041
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
72264
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
71042
72265
|
const cached = sourceBufferCache.get(absolutePath);
|
|
71043
72266
|
if (cached !== void 0) return cached;
|
|
71044
72267
|
let sourceBuffer;
|
|
@@ -71051,7 +72274,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71051
72274
|
return sourceBuffer;
|
|
71052
72275
|
};
|
|
71053
72276
|
const readSourceLines = (filename) => {
|
|
71054
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
72277
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
71055
72278
|
const cached = sourceLinesCache.get(absolutePath);
|
|
71056
72279
|
if (cached !== void 0) return cached;
|
|
71057
72280
|
const sourceBuffer = readSourceBuffer(filename);
|
|
@@ -71060,27 +72283,42 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71060
72283
|
return sourceLines;
|
|
71061
72284
|
};
|
|
71062
72285
|
const isMinifiedDiagnosticFile = (filename) => {
|
|
71063
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
72286
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
71064
72287
|
const cached = minifiedFileCache.get(absolutePath);
|
|
71065
72288
|
if (cached !== void 0) return cached;
|
|
71066
72289
|
const minified = isMinifiedSource(absolutePath);
|
|
71067
72290
|
minifiedFileCache.set(absolutePath, minified);
|
|
71068
72291
|
return minified;
|
|
71069
72292
|
};
|
|
71070
|
-
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.
|
|
72293
|
+
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.flatMap((diagnostic) => {
|
|
72294
|
+
const preparedSourceMap = resolvePreparedSourceMap(diagnostic.filename);
|
|
72295
|
+
if (preparedSourceMap === void 0) return [diagnostic];
|
|
72296
|
+
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
72297
|
+
if (plugin !== "react-doctor" || !reactDoctorPlugin.rules[rule]?.tags?.includes("design")) return [];
|
|
72298
|
+
const labels = mapPreparedSourceLabels(diagnostic.labels, preparedSourceMap);
|
|
72299
|
+
const sourceFilename = resolveMappedSourceFilename(diagnostic.filename);
|
|
72300
|
+
return labels === null || sourceFilename === void 0 ? [] : [{
|
|
72301
|
+
...diagnostic,
|
|
72302
|
+
filename: sourceFilename,
|
|
72303
|
+
labels
|
|
72304
|
+
}];
|
|
72305
|
+
}).filter((diagnostic) => isMappableOxlintDiagnostic(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) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
|
|
71071
72306
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
71072
72307
|
const primaryLabel = diagnostic.labels[0];
|
|
71073
72308
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
71074
|
-
const
|
|
72309
|
+
const mappedSourceFilename = resolveMappedSourceFilename(diagnostic.filename);
|
|
72310
|
+
const normalizedFilePath = (mappedSourceFilename ?? diagnostic.filename).replaceAll("\\", "/");
|
|
71075
72311
|
const primarySpan = primaryLabel?.span;
|
|
71076
72312
|
const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
|
|
71077
|
-
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
|
|
72313
|
+
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath, mappedSourceFilename === void 0 ? null : sourceBuffer);
|
|
71078
72314
|
const category = resolveDiagnosticCategory(plugin, rule);
|
|
71079
72315
|
const matchByOccurrence = resolveMatchByOccurrence(rule, category);
|
|
71080
72316
|
const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
|
|
71081
|
-
const
|
|
72317
|
+
const primaryLineNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.line ?? 0;
|
|
72318
|
+
const primaryColumnNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? columnOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.column ?? 0;
|
|
72319
|
+
const primaryLineIndex = primarySpan ? primaryLineNumber - 1 : -1;
|
|
71082
72320
|
const primaryLine = sourceLines?.[primaryLineIndex];
|
|
71083
|
-
const primaryColumnIndex = primarySpan ?
|
|
72321
|
+
const primaryColumnIndex = primarySpan ? primaryColumnNumber - 1 : -1;
|
|
71084
72322
|
const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
|
|
71085
72323
|
const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
|
|
71086
72324
|
const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
|
|
@@ -71093,8 +72331,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71093
72331
|
message: cleaned.message,
|
|
71094
72332
|
help: cleaned.help,
|
|
71095
72333
|
url: diagnostic.url,
|
|
71096
|
-
line:
|
|
71097
|
-
column:
|
|
72334
|
+
line: primaryLineNumber,
|
|
72335
|
+
column: primaryColumnNumber,
|
|
71098
72336
|
...primarySpan ? {
|
|
71099
72337
|
offset: primarySpan.offset,
|
|
71100
72338
|
length: primarySpan.length,
|
|
@@ -71282,7 +72520,11 @@ const isParallelismRelatedSpawnError = (error) => {
|
|
|
71282
72520
|
* loop with a slimmer config in that case.
|
|
71283
72521
|
*/
|
|
71284
72522
|
const spawnLintBatches = async (input) => {
|
|
71285
|
-
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
72523
|
+
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, sourceMapByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
72524
|
+
const resolveSourcePath = (filePath) => {
|
|
72525
|
+
const absoluteFilePath = Path.isAbsolute(filePath) ? filePath : Path.resolve(rootDirectory, filePath);
|
|
72526
|
+
return sourcePathByLintPath?.get(Path.normalize(absoluteFilePath)) ?? filePath;
|
|
72527
|
+
};
|
|
71286
72528
|
const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
|
|
71287
72529
|
let rescueDeadlineEpochMs;
|
|
71288
72530
|
const isPastDeadline = () => deadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(deadlineEpochMs) === 0 || rescueDeadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(rescueDeadlineEpochMs) === 0;
|
|
@@ -71302,7 +72544,7 @@ const spawnLintBatches = async (input) => {
|
|
|
71302
72544
|
}
|
|
71303
72545
|
const batchArgs = [...baseArgs, ...batch];
|
|
71304
72546
|
try {
|
|
71305
|
-
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
|
|
72547
|
+
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath);
|
|
71306
72548
|
} catch (error) {
|
|
71307
72549
|
if (!isSplittableReactDoctorError(error)) throw error;
|
|
71308
72550
|
if (isPastDeadline()) {
|
|
@@ -71408,10 +72650,12 @@ const spawnLintBatches = async (input) => {
|
|
|
71408
72650
|
onPartialFailure(buildMessage(`${skippedFiles.slice(0, 3).join(", ")}${skippedFiles.length > 3 ? `, +${skippedFiles.length - 3} more` : ""}`));
|
|
71409
72651
|
};
|
|
71410
72652
|
const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
|
|
71411
|
-
|
|
71412
|
-
|
|
72653
|
+
const droppedSourceFiles = [...new Set(droppedFiles.map(resolveSourcePath))];
|
|
72654
|
+
const deadlineSkippedSourceFiles = [...new Set(outcome.deadlineSkippedFiles.map(resolveSourcePath))];
|
|
72655
|
+
reportSkippedFiles(droppedSourceFiles, (fileListPreview) => `${droppedSourceFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
|
|
72656
|
+
reportSkippedFiles(deadlineSkippedSourceFiles, (fileListPreview) => `${deadlineSkippedSourceFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
|
|
71413
72657
|
const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
|
|
71414
|
-
input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
|
|
72658
|
+
input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)).map(resolveSourcePath))].sort());
|
|
71415
72659
|
return dedupeDiagnostics(diagnostics);
|
|
71416
72660
|
};
|
|
71417
72661
|
let didValidate = false;
|
|
@@ -71510,6 +72754,294 @@ const planLintBatches = ({ baseArgs, files, sizeByFile }) => {
|
|
|
71510
72754
|
}
|
|
71511
72755
|
return batches.filter((batch) => batch.fileIndexes.length > 0).map((batch) => batch.fileIndexes.sort((leftIndex, rightIndex) => leftIndex - rightIndex).map((fileIndex) => files[fileIndex]));
|
|
71512
72756
|
};
|
|
72757
|
+
const THREE_MODULE_IMPORT_PATTERN = /\b(?:from\s*|import\s*(?:\(\s*)?|require\s*\(\s*)["']three(?:\/[^"']*)?["']/;
|
|
72758
|
+
const containsThreeModuleImport = (sourceText) => THREE_MODULE_IMPORT_PATTERN.test(sourceText);
|
|
72759
|
+
const COMMENT_OPEN = "<!--";
|
|
72760
|
+
const COMMENT_CLOSE = "-->";
|
|
72761
|
+
const FRONTMATTER_FENCE = "---";
|
|
72762
|
+
const SCRIPT_TAG_NAME = "script";
|
|
72763
|
+
const SCRIPT_OPEN = `<${SCRIPT_TAG_NAME}`;
|
|
72764
|
+
const SCRIPT_CLOSE = `</${SCRIPT_TAG_NAME}`;
|
|
72765
|
+
const TEMPLATE_TAG_NAME = "template";
|
|
72766
|
+
const TEMPLATE_CLOSE = `</${TEMPLATE_TAG_NAME}`;
|
|
72767
|
+
const JAVASCRIPT_MIME_TYPES = new Set([
|
|
72768
|
+
"application/ecmascript",
|
|
72769
|
+
"application/javascript",
|
|
72770
|
+
"application/x-ecmascript",
|
|
72771
|
+
"application/x-javascript",
|
|
72772
|
+
"text/ecmascript",
|
|
72773
|
+
"text/javascript",
|
|
72774
|
+
"text/javascript1.0",
|
|
72775
|
+
"text/javascript1.1",
|
|
72776
|
+
"text/javascript1.2",
|
|
72777
|
+
"text/javascript1.3",
|
|
72778
|
+
"text/javascript1.4",
|
|
72779
|
+
"text/javascript1.5",
|
|
72780
|
+
"text/jscript",
|
|
72781
|
+
"text/livescript",
|
|
72782
|
+
"text/x-ecmascript",
|
|
72783
|
+
"text/x-javascript"
|
|
72784
|
+
]);
|
|
72785
|
+
const RAW_TEXT_TAG_NAMES = new Set([
|
|
72786
|
+
"iframe",
|
|
72787
|
+
"noembed",
|
|
72788
|
+
"noframes",
|
|
72789
|
+
"noscript",
|
|
72790
|
+
"style",
|
|
72791
|
+
"textarea",
|
|
72792
|
+
"title",
|
|
72793
|
+
"xmp"
|
|
72794
|
+
]);
|
|
72795
|
+
const PLAINTEXT_TAG_NAME = "plaintext";
|
|
72796
|
+
const TAG_OPEN_UTF8_BYTE = "<".charCodeAt(0);
|
|
72797
|
+
const TAG_CLOSE_UTF8_BYTE = ">".charCodeAt(0);
|
|
72798
|
+
const SINGLE_QUOTE_UTF8_BYTE = "'".charCodeAt(0);
|
|
72799
|
+
const DOUBLE_QUOTE_UTF8_BYTE = "\"".charCodeAt(0);
|
|
72800
|
+
const ATTRIBUTE_ASSIGNMENT_UTF8_BYTE = "=".charCodeAt(0);
|
|
72801
|
+
const TAG_SELF_CLOSE_UTF8_BYTE = "/".charCodeAt(0);
|
|
72802
|
+
const TAB_UTF8_BYTE = " ".charCodeAt(0);
|
|
72803
|
+
const FORM_FEED_UTF8_BYTE = "\f".charCodeAt(0);
|
|
72804
|
+
const isHtmlWhitespace = (byte) => byte === TAB_UTF8_BYTE || byte === 10 || byte === FORM_FEED_UTF8_BYTE || byte === 13 || byte === 32;
|
|
72805
|
+
const matchesAsciiCaseInsensitive = (sourceBuffer, startByte, expected) => {
|
|
72806
|
+
if (startByte + expected.length > sourceBuffer.length) return false;
|
|
72807
|
+
for (let expectedIndex = 0; expectedIndex < expected.length; expectedIndex++) {
|
|
72808
|
+
const sourceByte = sourceBuffer[startByte + expectedIndex];
|
|
72809
|
+
if (sourceByte === void 0 || String.fromCharCode(sourceByte).toLowerCase() !== expected[expectedIndex]) return false;
|
|
72810
|
+
}
|
|
72811
|
+
return true;
|
|
72812
|
+
};
|
|
72813
|
+
const isTagBoundary = (byte) => byte === TAG_CLOSE_UTF8_BYTE || byte === TAG_SELF_CLOSE_UTF8_BYTE || isHtmlWhitespace(byte);
|
|
72814
|
+
const isPotentialTagStart = (byte) => {
|
|
72815
|
+
if (byte === void 0) return false;
|
|
72816
|
+
return /[A-Za-z!/?]/.test(String.fromCharCode(byte));
|
|
72817
|
+
};
|
|
72818
|
+
const findLineEnd = (sourceBuffer, lineStartByte) => {
|
|
72819
|
+
let byteIndex = lineStartByte;
|
|
72820
|
+
while (byteIndex < sourceBuffer.length && sourceBuffer[byteIndex] !== 10 && sourceBuffer[byteIndex] !== 13) byteIndex++;
|
|
72821
|
+
return byteIndex;
|
|
72822
|
+
};
|
|
72823
|
+
const findNextLineStart = (sourceBuffer, lineStartByte) => {
|
|
72824
|
+
const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
|
|
72825
|
+
if (sourceBuffer[lineEndByte] === 13 && sourceBuffer[lineEndByte + 1] === 10) return lineEndByte + 2;
|
|
72826
|
+
return Math.min(lineEndByte + 1, sourceBuffer.length);
|
|
72827
|
+
};
|
|
72828
|
+
const isFrontmatterFenceLine = (sourceBuffer, lineStartByte) => {
|
|
72829
|
+
if (!matchesAsciiCaseInsensitive(sourceBuffer, lineStartByte, FRONTMATTER_FENCE)) return false;
|
|
72830
|
+
const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
|
|
72831
|
+
for (let byteIndex = lineStartByte + 3; byteIndex < lineEndByte; byteIndex++) if (!isHtmlWhitespace(sourceBuffer[byteIndex])) return false;
|
|
72832
|
+
return true;
|
|
72833
|
+
};
|
|
72834
|
+
const findFrontmatterEnd = (sourceBuffer) => {
|
|
72835
|
+
if (!isFrontmatterFenceLine(sourceBuffer, 0)) return 0;
|
|
72836
|
+
const openingFenceEndByte = findLineEnd(sourceBuffer, 0);
|
|
72837
|
+
let lineStartByte = findNextLineStart(sourceBuffer, 0);
|
|
72838
|
+
while (lineStartByte < sourceBuffer.length) {
|
|
72839
|
+
if (isFrontmatterFenceLine(sourceBuffer, lineStartByte)) return findLineEnd(sourceBuffer, lineStartByte);
|
|
72840
|
+
lineStartByte = findNextLineStart(sourceBuffer, lineStartByte);
|
|
72841
|
+
}
|
|
72842
|
+
return openingFenceEndByte;
|
|
72843
|
+
};
|
|
72844
|
+
const maskByteRange = (maskedBuffer, startByte, endByte) => {
|
|
72845
|
+
for (let byteIndex = startByte; byteIndex < endByte; byteIndex++) {
|
|
72846
|
+
const byte = maskedBuffer[byteIndex];
|
|
72847
|
+
if (byte !== 10 && byte !== 13) maskedBuffer[byteIndex] = 32;
|
|
72848
|
+
}
|
|
72849
|
+
};
|
|
72850
|
+
const readStartTagName = (sourceBuffer, tagStartByte) => {
|
|
72851
|
+
const firstNameByte = sourceBuffer[tagStartByte + 1];
|
|
72852
|
+
if (firstNameByte === void 0 || !/[A-Za-z]/.test(String.fromCharCode(firstNameByte))) return null;
|
|
72853
|
+
let nameEndByte = tagStartByte + 2;
|
|
72854
|
+
while (nameEndByte < sourceBuffer.length && /[A-Za-z0-9:-]/.test(String.fromCharCode(sourceBuffer[nameEndByte] ?? 32))) nameEndByte++;
|
|
72855
|
+
return sourceBuffer.subarray(tagStartByte + 1, nameEndByte).toString("ascii").toLowerCase();
|
|
72856
|
+
};
|
|
72857
|
+
const findTagEnd = (sourceBuffer, startByte) => {
|
|
72858
|
+
let quoteByte = null;
|
|
72859
|
+
for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) {
|
|
72860
|
+
const byte = sourceBuffer[byteIndex];
|
|
72861
|
+
if (quoteByte !== null) {
|
|
72862
|
+
if (byte === quoteByte) quoteByte = null;
|
|
72863
|
+
continue;
|
|
72864
|
+
}
|
|
72865
|
+
if (byte === SINGLE_QUOTE_UTF8_BYTE || byte === DOUBLE_QUOTE_UTF8_BYTE) {
|
|
72866
|
+
quoteByte = byte;
|
|
72867
|
+
continue;
|
|
72868
|
+
}
|
|
72869
|
+
if (byte === TAG_CLOSE_UTF8_BYTE) return byteIndex;
|
|
72870
|
+
}
|
|
72871
|
+
return sourceBuffer.length;
|
|
72872
|
+
};
|
|
72873
|
+
const parseScriptAttributes = (sourceBuffer, attributesStartByte, tagEndByte) => {
|
|
72874
|
+
let byteIndex = attributesStartByte;
|
|
72875
|
+
let hasSource = false;
|
|
72876
|
+
let language = null;
|
|
72877
|
+
let scriptType = null;
|
|
72878
|
+
while (byteIndex < tagEndByte) {
|
|
72879
|
+
while (byteIndex < tagEndByte && (isHtmlWhitespace(sourceBuffer[byteIndex]) || sourceBuffer[byteIndex] === TAG_SELF_CLOSE_UTF8_BYTE)) byteIndex++;
|
|
72880
|
+
const attributeNameStartByte = byteIndex;
|
|
72881
|
+
while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== ATTRIBUTE_ASSIGNMENT_UTF8_BYTE && sourceBuffer[byteIndex] !== TAG_SELF_CLOSE_UTF8_BYTE) byteIndex++;
|
|
72882
|
+
const attributeName = sourceBuffer.subarray(attributeNameStartByte, byteIndex).toString("ascii").toLowerCase();
|
|
72883
|
+
while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
|
|
72884
|
+
let attributeValue = "";
|
|
72885
|
+
if (sourceBuffer[byteIndex] === ATTRIBUTE_ASSIGNMENT_UTF8_BYTE) {
|
|
72886
|
+
byteIndex++;
|
|
72887
|
+
while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
|
|
72888
|
+
const quoteByte = sourceBuffer[byteIndex];
|
|
72889
|
+
if (quoteByte === SINGLE_QUOTE_UTF8_BYTE || quoteByte === DOUBLE_QUOTE_UTF8_BYTE) {
|
|
72890
|
+
const valueStartByte = byteIndex + 1;
|
|
72891
|
+
byteIndex = valueStartByte;
|
|
72892
|
+
while (byteIndex < tagEndByte && sourceBuffer[byteIndex] !== quoteByte) byteIndex++;
|
|
72893
|
+
attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
|
|
72894
|
+
if (byteIndex < tagEndByte) byteIndex++;
|
|
72895
|
+
} else {
|
|
72896
|
+
const valueStartByte = byteIndex;
|
|
72897
|
+
while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== TAG_CLOSE_UTF8_BYTE) byteIndex++;
|
|
72898
|
+
attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
|
|
72899
|
+
}
|
|
72900
|
+
}
|
|
72901
|
+
if (attributeName === "src") hasSource = true;
|
|
72902
|
+
else if (attributeName === "type" && scriptType === null) scriptType = attributeValue;
|
|
72903
|
+
else if (attributeName === "language" && language === null) language = attributeValue;
|
|
72904
|
+
}
|
|
72905
|
+
return {
|
|
72906
|
+
hasSource,
|
|
72907
|
+
language,
|
|
72908
|
+
type: scriptType
|
|
72909
|
+
};
|
|
72910
|
+
};
|
|
72911
|
+
const isExecutableScript = (attributes) => {
|
|
72912
|
+
if (attributes.hasSource) return false;
|
|
72913
|
+
const type = attributes.type?.trim().toLowerCase() ?? "";
|
|
72914
|
+
if (type !== "") {
|
|
72915
|
+
const mimeType = type.split(";")[0]?.trim() ?? "";
|
|
72916
|
+
return mimeType === "module" || JAVASCRIPT_MIME_TYPES.has(mimeType);
|
|
72917
|
+
}
|
|
72918
|
+
const language = attributes.language?.trim().toLowerCase() ?? "";
|
|
72919
|
+
return language === "" || JAVASCRIPT_MIME_TYPES.has(`text/${language}`);
|
|
72920
|
+
};
|
|
72921
|
+
const findElementClose = (sourceBuffer, startByte, tagName) => {
|
|
72922
|
+
const closeTagStart = `</${tagName}`;
|
|
72923
|
+
for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) if (sourceBuffer[byteIndex] === TAG_OPEN_UTF8_BYTE && matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, closeTagStart) && isTagBoundary(sourceBuffer[byteIndex + closeTagStart.length])) return byteIndex;
|
|
72924
|
+
return sourceBuffer.length;
|
|
72925
|
+
};
|
|
72926
|
+
const prepareHtmlScriptSource = (sourceBuffer) => {
|
|
72927
|
+
const frontmatterEndByte = findFrontmatterEnd(sourceBuffer);
|
|
72928
|
+
let maskedBuffer = frontmatterEndByte > 0 ? Buffer.from(sourceBuffer) : null;
|
|
72929
|
+
if (maskedBuffer !== null) maskByteRange(maskedBuffer, 0, frontmatterEndByte);
|
|
72930
|
+
const executableScriptBodies = [];
|
|
72931
|
+
let byteIndex = frontmatterEndByte;
|
|
72932
|
+
let templateDepth = 0;
|
|
72933
|
+
while (byteIndex < sourceBuffer.length) {
|
|
72934
|
+
if (sourceBuffer[byteIndex] !== TAG_OPEN_UTF8_BYTE) {
|
|
72935
|
+
byteIndex++;
|
|
72936
|
+
continue;
|
|
72937
|
+
}
|
|
72938
|
+
if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, COMMENT_OPEN)) {
|
|
72939
|
+
const commentEndByte = sourceBuffer.indexOf(COMMENT_CLOSE, byteIndex + 4);
|
|
72940
|
+
byteIndex = commentEndByte === -1 ? sourceBuffer.length : commentEndByte + 3;
|
|
72941
|
+
continue;
|
|
72942
|
+
}
|
|
72943
|
+
if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, TEMPLATE_CLOSE) && isTagBoundary(sourceBuffer[byteIndex + TEMPLATE_CLOSE.length])) {
|
|
72944
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + TEMPLATE_CLOSE.length);
|
|
72945
|
+
if (templateDepth > 0) templateDepth--;
|
|
72946
|
+
byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
|
|
72947
|
+
continue;
|
|
72948
|
+
}
|
|
72949
|
+
if (!matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, SCRIPT_OPEN) || !isTagBoundary(sourceBuffer[byteIndex + SCRIPT_OPEN.length])) {
|
|
72950
|
+
if (!isPotentialTagStart(sourceBuffer[byteIndex + 1])) {
|
|
72951
|
+
byteIndex++;
|
|
72952
|
+
continue;
|
|
72953
|
+
}
|
|
72954
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + 1);
|
|
72955
|
+
const tagName = readStartTagName(sourceBuffer, byteIndex);
|
|
72956
|
+
if (tagName === PLAINTEXT_TAG_NAME) break;
|
|
72957
|
+
if (tagName === TEMPLATE_TAG_NAME) templateDepth++;
|
|
72958
|
+
if (tagName !== null && RAW_TEXT_TAG_NAMES.has(tagName)) {
|
|
72959
|
+
const closeTagStartByte = findElementClose(sourceBuffer, tagEndByte + 1, tagName);
|
|
72960
|
+
if (closeTagStartByte === sourceBuffer.length) break;
|
|
72961
|
+
const closeTagEndByte = findTagEnd(sourceBuffer, closeTagStartByte + tagName.length + 2);
|
|
72962
|
+
byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
|
|
72963
|
+
continue;
|
|
72964
|
+
}
|
|
72965
|
+
byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
|
|
72966
|
+
continue;
|
|
72967
|
+
}
|
|
72968
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + SCRIPT_OPEN.length);
|
|
72969
|
+
if (tagEndByte === sourceBuffer.length) break;
|
|
72970
|
+
const bodyStartByte = tagEndByte + 1;
|
|
72971
|
+
const bodyEndByte = findElementClose(sourceBuffer, bodyStartByte, SCRIPT_TAG_NAME);
|
|
72972
|
+
const attributes = parseScriptAttributes(sourceBuffer, byteIndex + SCRIPT_OPEN.length, tagEndByte);
|
|
72973
|
+
if (attributes.hasSource || templateDepth > 0) {
|
|
72974
|
+
maskedBuffer ??= Buffer.from(sourceBuffer);
|
|
72975
|
+
maskByteRange(maskedBuffer, bodyStartByte, bodyEndByte);
|
|
72976
|
+
} else if (isExecutableScript(attributes)) executableScriptBodies.push(sourceBuffer.subarray(bodyStartByte, bodyEndByte));
|
|
72977
|
+
if (bodyEndByte === sourceBuffer.length) break;
|
|
72978
|
+
const closeTagEndByte = findTagEnd(sourceBuffer, bodyEndByte + SCRIPT_CLOSE.length);
|
|
72979
|
+
byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
|
|
72980
|
+
}
|
|
72981
|
+
return {
|
|
72982
|
+
executableScriptBodies,
|
|
72983
|
+
lintBuffer: maskedBuffer ?? sourceBuffer
|
|
72984
|
+
};
|
|
72985
|
+
};
|
|
72986
|
+
const ASTRO_FILE_PATTERN = /\.astro$/;
|
|
72987
|
+
const prepareLintSources = (rootDirectory, temporaryDirectory, candidateFiles) => {
|
|
72988
|
+
const lintFiles = [];
|
|
72989
|
+
const sourcePathByLintPath = /* @__PURE__ */ new Map();
|
|
72990
|
+
const sourceMapByLintPath = /* @__PURE__ */ new Map();
|
|
72991
|
+
const sizeByLintPath = /* @__PURE__ */ new Map();
|
|
72992
|
+
const htmlSourcesDirectory = Path.join(temporaryDirectory, "html-sources");
|
|
72993
|
+
const astroSourcesDirectory = Path.join(temporaryDirectory, "astro-sources");
|
|
72994
|
+
let htmlFileIndex = 0;
|
|
72995
|
+
let astroFileIndex = 0;
|
|
72996
|
+
let hasThreeModuleImport = false;
|
|
72997
|
+
for (const candidateFile of candidateFiles) {
|
|
72998
|
+
if (!HTML_FILE_PATTERN.test(candidateFile) && !ASTRO_FILE_PATTERN.test(candidateFile)) {
|
|
72999
|
+
lintFiles.push(candidateFile);
|
|
73000
|
+
continue;
|
|
73001
|
+
}
|
|
73002
|
+
const absoluteSourcePath = Path.isAbsolute(candidateFile) ? candidateFile : Path.resolve(rootDirectory, candidateFile);
|
|
73003
|
+
const sourceBuffer = NFS.readFileSync(absoluteSourcePath);
|
|
73004
|
+
if (ASTRO_FILE_PATTERN.test(candidateFile)) {
|
|
73005
|
+
const compilerSourcePath = absoluteSourcePath.replaceAll("\\", "/");
|
|
73006
|
+
const convertedSource = convertToTSX(sourceBuffer.toString("utf8"), {
|
|
73007
|
+
filename: compilerSourcePath,
|
|
73008
|
+
sourcemap: "external",
|
|
73009
|
+
includeScripts: true
|
|
73010
|
+
});
|
|
73011
|
+
if (astroFileIndex === 0) NFS.mkdirSync(astroSourcesDirectory, { recursive: true });
|
|
73012
|
+
const lintPath = Path.join(astroSourcesDirectory, `${astroFileIndex}.tsx`);
|
|
73013
|
+
const generatedBuffer = Buffer.from(convertedSource.code);
|
|
73014
|
+
NFS.writeFileSync(lintPath, generatedBuffer);
|
|
73015
|
+
lintFiles.push(candidateFile);
|
|
73016
|
+
lintFiles.push(lintPath);
|
|
73017
|
+
sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
|
|
73018
|
+
sourceMapByLintPath.set(Path.resolve(lintPath), {
|
|
73019
|
+
traceMap: new TraceMap(JSON.stringify(convertedSource.map)),
|
|
73020
|
+
generatedBuffer,
|
|
73021
|
+
sourceBuffer
|
|
73022
|
+
});
|
|
73023
|
+
sizeByLintPath.set(lintPath, sourceBuffer.length);
|
|
73024
|
+
astroFileIndex++;
|
|
73025
|
+
continue;
|
|
73026
|
+
}
|
|
73027
|
+
const { executableScriptBodies, lintBuffer } = prepareHtmlScriptSource(sourceBuffer);
|
|
73028
|
+
if (htmlFileIndex === 0) NFS.mkdirSync(htmlSourcesDirectory, { recursive: true });
|
|
73029
|
+
const lintPath = Path.join(htmlSourcesDirectory, `${htmlFileIndex}.astro`);
|
|
73030
|
+
NFS.writeFileSync(lintPath, lintBuffer);
|
|
73031
|
+
lintFiles.push(lintPath);
|
|
73032
|
+
sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
|
|
73033
|
+
sizeByLintPath.set(lintPath, sourceBuffer.length);
|
|
73034
|
+
hasThreeModuleImport ||= executableScriptBodies.some((scriptBody) => containsThreeModuleImport(scriptBody.toString("utf8")));
|
|
73035
|
+
htmlFileIndex++;
|
|
73036
|
+
}
|
|
73037
|
+
return {
|
|
73038
|
+
lintFiles,
|
|
73039
|
+
sourcePathByLintPath,
|
|
73040
|
+
sourceMapByLintPath,
|
|
73041
|
+
sizeByLintPath,
|
|
73042
|
+
hasThreeModuleImport
|
|
73043
|
+
};
|
|
73044
|
+
};
|
|
71513
73045
|
/**
|
|
71514
73046
|
* Atomically (re)writes the generated oxlintrc.json. Used twice in
|
|
71515
73047
|
* the runner: once for the primary scan, once for the
|
|
@@ -71670,6 +73202,8 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
71670
73202
|
const runOxlint = async (options) => {
|
|
71671
73203
|
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
71672
73204
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
73205
|
+
const runtimeGlobals = Array.isArray(userConfig?.runtimeGlobals) ? userConfig.runtimeGlobals.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
73206
|
+
let unpluginAutoImportGlobalScopes = [];
|
|
71673
73207
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
71674
73208
|
validateRuleRegistration();
|
|
71675
73209
|
resetManifestCaches();
|
|
@@ -71683,21 +73217,6 @@ const runOxlint = async (options) => {
|
|
|
71683
73217
|
const pluginPath = resolvePluginPath();
|
|
71684
73218
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
71685
73219
|
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
71686
|
-
const buildConfig = (overrides) => createOxlintConfig({
|
|
71687
|
-
pluginPath,
|
|
71688
|
-
project,
|
|
71689
|
-
customRulesOnly,
|
|
71690
|
-
extendsPaths: overrides.extendsPaths,
|
|
71691
|
-
ignoredTags,
|
|
71692
|
-
includedTags,
|
|
71693
|
-
includeTagDefaults,
|
|
71694
|
-
serverAuthFunctionNames,
|
|
71695
|
-
severityControls,
|
|
71696
|
-
userPlugins,
|
|
71697
|
-
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
|
|
71698
|
-
ruleSelection: overrides.ruleSelection,
|
|
71699
|
-
sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
|
|
71700
|
-
});
|
|
71701
73220
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
71702
73221
|
const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
71703
73222
|
const configPath = Path.join(configDirectory, "oxlintrc.json");
|
|
@@ -71733,7 +73252,36 @@ const runOxlint = async (options) => {
|
|
|
71733
73252
|
await yieldToEventLoop();
|
|
71734
73253
|
const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
|
|
71735
73254
|
const candidateFiles = includePaths !== void 0 ? includePaths : (sizedScanFiles ?? []).map((entry) => entry.path);
|
|
73255
|
+
unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
|
|
73256
|
+
rootDirectory,
|
|
73257
|
+
candidateFiles
|
|
73258
|
+
});
|
|
73259
|
+
const preparedLintSources = prepareLintSources(rootDirectory, configDirectory, candidateFiles);
|
|
73260
|
+
const lintFiles = preparedLintSources.lintFiles;
|
|
73261
|
+
const hasPreparedFiles = preparedLintSources.sourcePathByLintPath.size > 0;
|
|
73262
|
+
const lintProject = !project.hasThree && preparedLintSources.hasThreeModuleImport ? {
|
|
73263
|
+
...project,
|
|
73264
|
+
hasThree: true
|
|
73265
|
+
} : project;
|
|
73266
|
+
const buildConfig = (overrides) => createOxlintConfig({
|
|
73267
|
+
pluginPath,
|
|
73268
|
+
project: lintProject,
|
|
73269
|
+
customRulesOnly,
|
|
73270
|
+
extendsPaths: overrides.extendsPaths,
|
|
73271
|
+
ignoredTags,
|
|
73272
|
+
includedTags,
|
|
73273
|
+
includeTagDefaults,
|
|
73274
|
+
runtimeGlobals,
|
|
73275
|
+
unpluginAutoImportGlobalScopes,
|
|
73276
|
+
serverAuthFunctionNames,
|
|
73277
|
+
severityControls,
|
|
73278
|
+
userPlugins,
|
|
73279
|
+
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
|
|
73280
|
+
ruleSelection: overrides.ruleSelection,
|
|
73281
|
+
sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
|
|
73282
|
+
});
|
|
71736
73283
|
const sizeByFile = sizedScanFiles !== null && lintBatchOrdering === "cost" ? new Map(sizedScanFiles.map((entry) => [entry.path, entry.sizeBytes])) : null;
|
|
73284
|
+
if (sizeByFile !== null) for (const [lintPath, sizeBytes] of preparedLintSources.sizeByLintPath) sizeByFile.set(lintPath, sizeBytes);
|
|
71737
73285
|
const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
|
|
71738
73286
|
baseArgs: passBaseArgs,
|
|
71739
73287
|
files: passFiles,
|
|
@@ -71762,7 +73310,9 @@ const runOxlint = async (options) => {
|
|
|
71762
73310
|
fileBatches: passFileBatches,
|
|
71763
73311
|
rootDirectory,
|
|
71764
73312
|
nodeBinaryPath,
|
|
71765
|
-
project,
|
|
73313
|
+
project: lintProject,
|
|
73314
|
+
sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
|
|
73315
|
+
sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
|
|
71766
73316
|
onPartialFailure: reportPartialFailure,
|
|
71767
73317
|
onAnalyzedFiles: (filePaths) => {
|
|
71768
73318
|
analyzedFiles = filePaths;
|
|
@@ -71797,7 +73347,7 @@ const runOxlint = async (options) => {
|
|
|
71797
73347
|
};
|
|
71798
73348
|
}
|
|
71799
73349
|
};
|
|
71800
|
-
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0) {
|
|
73350
|
+
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !hasPreparedFiles) {
|
|
71801
73351
|
const rulesetHash = computeRulesetHash({
|
|
71802
73352
|
config: buildConfig({
|
|
71803
73353
|
extendsPaths: [],
|
|
@@ -71955,14 +73505,16 @@ const runOxlint = async (options) => {
|
|
|
71955
73505
|
]);
|
|
71956
73506
|
}
|
|
71957
73507
|
const baseArgs = makeBaseArgs(configPath);
|
|
71958
|
-
const fileBatches = buildFileBatches(baseArgs,
|
|
73508
|
+
const fileBatches = buildFileBatches(baseArgs, lintFiles);
|
|
71959
73509
|
let analyzedFiles = [];
|
|
71960
73510
|
const runBatches = () => spawnLintBatches({
|
|
71961
73511
|
baseArgs,
|
|
71962
73512
|
fileBatches,
|
|
71963
73513
|
rootDirectory,
|
|
71964
73514
|
nodeBinaryPath,
|
|
71965
|
-
project,
|
|
73515
|
+
project: lintProject,
|
|
73516
|
+
sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
|
|
73517
|
+
sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
|
|
71966
73518
|
onPartialFailure,
|
|
71967
73519
|
onAnalyzedFiles: (filePaths) => {
|
|
71968
73520
|
analyzedFiles = filePaths;
|
|
@@ -73311,10 +74863,14 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
73311
74863
|
materializedFiles.push(relativePath);
|
|
73312
74864
|
}
|
|
73313
74865
|
yield* sync(() => {
|
|
73314
|
-
for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
73315
|
-
const sourcePath = path.join(input.directory, configFilename);
|
|
73316
|
-
const targetPath = path.
|
|
73317
|
-
if (
|
|
74866
|
+
for (const subdirectory of ["", ...input.configSubdirectories ?? []]) for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
74867
|
+
const sourcePath = path.join(input.directory, subdirectory, configFilename);
|
|
74868
|
+
const targetPath = path.resolve(resolvedTempDirectory, subdirectory, configFilename);
|
|
74869
|
+
if (!isPathInsideDirectory(targetPath, resolvedTempDirectory)) continue;
|
|
74870
|
+
if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
|
|
74871
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
74872
|
+
fs.cpSync(sourcePath, targetPath);
|
|
74873
|
+
}
|
|
73318
74874
|
}
|
|
73319
74875
|
});
|
|
73320
74876
|
return {
|
|
@@ -73335,15 +74891,17 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
73335
74891
|
static layerNode = effect(StagedFiles, gen(function* () {
|
|
73336
74892
|
const git = yield* Git;
|
|
73337
74893
|
return StagedFiles.of({
|
|
73338
|
-
discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(map$3((entries) => entries.filter(isLintableSourceFile)), withSpan("StagedFiles.discoverSourceFiles")),
|
|
73339
|
-
materialize: ({ directory, stagedFiles, tempDirectory }) => materializeSourceTree({
|
|
74894
|
+
discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(map$3((entries) => entries === null ? null : entries.filter(isLintableSourceFile)), withSpan("StagedFiles.discoverSourceFiles")),
|
|
74895
|
+
materialize: ({ directory, stagedFiles, tempDirectory, configSubdirectories }) => materializeSourceTree({
|
|
73340
74896
|
directory,
|
|
73341
74897
|
files: stagedFiles,
|
|
73342
74898
|
tempDirectory,
|
|
74899
|
+
configSubdirectories,
|
|
73343
74900
|
readContent: (relativePath) => git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES })
|
|
73344
74901
|
}).pipe(map$3((tree) => ({
|
|
73345
74902
|
tempDirectory: tree.tempDirectory,
|
|
73346
74903
|
stagedFiles: tree.materializedFiles,
|
|
74904
|
+
unmaterializedFiles: tree.unmaterializedFiles,
|
|
73347
74905
|
cleanup: tree.cleanup
|
|
73348
74906
|
})), withSpan("StagedFiles.materialize"))
|
|
73349
74907
|
});
|
|
@@ -73358,6 +74916,7 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
73358
74916
|
materialize: ({ tempDirectory }) => succeed$2({
|
|
73359
74917
|
tempDirectory,
|
|
73360
74918
|
stagedFiles: snapshot.materializedFiles ?? snapshot.sourceFiles ?? [],
|
|
74919
|
+
unmaterializedFiles: [],
|
|
73361
74920
|
cleanup: () => {}
|
|
73362
74921
|
})
|
|
73363
74922
|
}));
|
|
@@ -73884,4 +75443,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
73884
75443
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
73885
75444
|
|
|
73886
75445
|
//# sourceMappingURL=index.js.map
|
|
73887
|
-
//# debugId=
|
|
75446
|
+
//# debugId=18c61424-4926-5cae-8f2a-6001534ea755
|