react-doctor 0.5.1-dev.7c88165 → 0.5.1-dev.9cc6555
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +94 -38
- package/dist/index.d.ts +7 -0
- package/dist/index.js +59 -20
- package/dist/lsp.js +59 -20
- package/package.json +4 -4
package/dist/cli.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]="5c7334de-5fd1-50a7-bb75-1a17b3b54e4e")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as NodeChildProcess from "node:child_process";
|
|
5
5
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -22356,6 +22356,7 @@ var Diagnostic = class extends Class("Diagnostic")({
|
|
|
22356
22356
|
endLine: optional(Number$1),
|
|
22357
22357
|
endColumn: optional(Number$1),
|
|
22358
22358
|
category: String$1,
|
|
22359
|
+
fileContext: optional(Literals(["test", "story"])),
|
|
22359
22360
|
suppressionHint: optional(String$1),
|
|
22360
22361
|
relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation))
|
|
22361
22362
|
}) {};
|
|
@@ -37767,8 +37768,10 @@ const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
|
|
|
37767
37768
|
const relativePath = toRelativePath(filePath, rootDirectory);
|
|
37768
37769
|
return patterns.some((pattern) => pattern.test(relativePath));
|
|
37769
37770
|
};
|
|
37771
|
+
const SCRIPT_EXTENSION_FRAGMENT = "[cm]?[jt]sx?";
|
|
37772
|
+
const STORY_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:stories|story)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
37773
|
+
const TEST_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:test|spec|fixture|fixtures)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
37770
37774
|
const TEST_FILE_DIRECTORY_PATTERN = /(?:^|\/)(?:__tests__|__test__|tests|test|__mocks__|cypress|e2e|playwright)\//;
|
|
37771
|
-
const TEST_FILE_SUFFIX_PATTERN = /\.(?:test|spec|stories|story|fixture|fixtures)\.(?:[cm]?[jt]sx?)$/;
|
|
37772
37775
|
const FIXTURE_PROJECT_PATTERN = /\/(?:fixtures|__fixtures__)\//;
|
|
37773
37776
|
const SOURCE_ROOT_PATTERN = /\/(?:src|app|lib|components|pages|features|modules|packages|apps|frontend|client)\//g;
|
|
37774
37777
|
const stripAboveSourceRoot = (relativePath) => {
|
|
@@ -37779,12 +37782,23 @@ const stripAboveSourceRoot = (relativePath) => {
|
|
|
37779
37782
|
if (lastIdx >= 0) return relativePath.slice(lastIdx);
|
|
37780
37783
|
return relativePath.slice(fixtureMatch.index + fixtureMatch[0].length - 1);
|
|
37781
37784
|
};
|
|
37782
|
-
|
|
37783
|
-
|
|
37785
|
+
/**
|
|
37786
|
+
* Classifies where a file sits relative to shipped code. A finding in a
|
|
37787
|
+
* `.stories.tsx` or `.spec.ts` file never runs in front of users, so
|
|
37788
|
+
* renderers label those sites instead of framing them as production
|
|
37789
|
+
* impact (`rn-no-raw-text` in a spec doesn't say users crash).
|
|
37790
|
+
*
|
|
37791
|
+
* `"story"` is the `.stories.*` / `.story.*` suffix; `"test"` is the
|
|
37792
|
+
* test/spec/fixture suffixes and test directories; `"production"` is
|
|
37793
|
+
* the default.
|
|
37794
|
+
*/
|
|
37795
|
+
const classifyFileContext = (relativePath) => {
|
|
37796
|
+
if (relativePath.length === 0) return "production";
|
|
37784
37797
|
const forwardSlashed = relativePath.replaceAll("\\", "/");
|
|
37785
|
-
if (
|
|
37798
|
+
if (STORY_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "story";
|
|
37799
|
+
if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "test";
|
|
37786
37800
|
const scoped = stripAboveSourceRoot(forwardSlashed);
|
|
37787
|
-
return TEST_FILE_DIRECTORY_PATTERN.test(scoped);
|
|
37801
|
+
return TEST_FILE_DIRECTORY_PATTERN.test(scoped) ? "test" : "production";
|
|
37788
37802
|
};
|
|
37789
37803
|
/**
|
|
37790
37804
|
* Resolves the user-configured severity override for a rule.
|
|
@@ -38004,6 +38018,8 @@ const collectStringSet = (values) => {
|
|
|
38004
38018
|
* 5. `rn-no-raw-text` suppression via configured `textComponents` and
|
|
38005
38019
|
* `rawTextWrapperComponents` (config-driven JSX enclosure checks)
|
|
38006
38020
|
* 6. inline suppressions (`// react-doctor-disable-next-line ...`)
|
|
38021
|
+
* 7. file-context stamping (`fileContext: "test" | "story"` on
|
|
38022
|
+
* survivors in non-production files, so renderers can label them)
|
|
38007
38023
|
*
|
|
38008
38024
|
* Returns `null` when the diagnostic is dropped, the (possibly
|
|
38009
38025
|
* severity-restamped) diagnostic otherwise.
|
|
@@ -38023,7 +38039,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38023
38039
|
const hasTextComponents = textComponentNames.size > 0;
|
|
38024
38040
|
const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
|
|
38025
38041
|
const fileLinesCache = /* @__PURE__ */ new Map();
|
|
38026
|
-
const
|
|
38042
|
+
const fileContextCache = /* @__PURE__ */ new Map();
|
|
38027
38043
|
const libraryFileCache = /* @__PURE__ */ new Map();
|
|
38028
38044
|
const isLibraryFile = (filePath) => {
|
|
38029
38045
|
let cached = libraryFileCache.get(filePath);
|
|
@@ -38040,11 +38056,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38040
38056
|
fileLinesCache.set(filePath, lines);
|
|
38041
38057
|
return lines;
|
|
38042
38058
|
};
|
|
38043
|
-
const
|
|
38044
|
-
let cached =
|
|
38059
|
+
const getFileContext = (filePath) => {
|
|
38060
|
+
let cached = fileContextCache.get(filePath);
|
|
38045
38061
|
if (cached === void 0) {
|
|
38046
|
-
cached =
|
|
38047
|
-
|
|
38062
|
+
cached = classifyFileContext(filePath);
|
|
38063
|
+
fileContextCache.set(filePath, cached);
|
|
38048
38064
|
}
|
|
38049
38065
|
return cached;
|
|
38050
38066
|
};
|
|
@@ -38053,7 +38069,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38053
38069
|
const rule = reactDoctorPlugin.rules[diagnostic.rule];
|
|
38054
38070
|
if (!rule?.tags?.includes("test-noise")) return false;
|
|
38055
38071
|
if (rule.tags.includes("migration-hint")) return false;
|
|
38056
|
-
return
|
|
38072
|
+
return getFileContext(diagnostic.filePath) !== "production";
|
|
38057
38073
|
};
|
|
38058
38074
|
const isRuleIgnored = (ruleIdentifier) => {
|
|
38059
38075
|
for (const ignored of ignoredRules) if (isSameRuleKey(ignored, ruleIdentifier)) return true;
|
|
@@ -38110,6 +38126,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38110
38126
|
};
|
|
38111
38127
|
}
|
|
38112
38128
|
}
|
|
38129
|
+
const fileContext = getFileContext(current.filePath);
|
|
38130
|
+
if (fileContext !== "production") current = {
|
|
38131
|
+
...current,
|
|
38132
|
+
fileContext
|
|
38133
|
+
};
|
|
38113
38134
|
return current;
|
|
38114
38135
|
} };
|
|
38115
38136
|
};
|
|
@@ -41711,9 +41732,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
41711
41732
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
41712
41733
|
};
|
|
41713
41734
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
41735
|
+
const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
|
|
41736
|
+
const TRAILING_PERIOD_PATTERN = /\.$/;
|
|
41714
41737
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
41715
41738
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
41716
|
-
const
|
|
41739
|
+
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
41740
|
+
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
41741
|
+
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
41742
|
+
const buildReactCompilerMessage = (reasonSummary) => {
|
|
41743
|
+
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
41744
|
+
if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
|
|
41745
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
|
|
41746
|
+
};
|
|
41717
41747
|
const PLUGIN_CATEGORY_MAP = {
|
|
41718
41748
|
react: "Bugs",
|
|
41719
41749
|
"react-hooks": "Bugs",
|
|
@@ -41752,10 +41782,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
|
41752
41782
|
};
|
|
41753
41783
|
};
|
|
41754
41784
|
const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
41755
|
-
if (plugin === "react-hooks-js")
|
|
41756
|
-
message
|
|
41757
|
-
|
|
41758
|
-
|
|
41785
|
+
if (plugin === "react-hooks-js") {
|
|
41786
|
+
const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
|
|
41787
|
+
if (rule === "todo") return {
|
|
41788
|
+
message: REACT_COMPILER_GENERIC_MESSAGE,
|
|
41789
|
+
help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
|
|
41790
|
+
};
|
|
41791
|
+
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
41792
|
+
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
41793
|
+
return {
|
|
41794
|
+
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
41795
|
+
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
41796
|
+
};
|
|
41797
|
+
}
|
|
41759
41798
|
return {
|
|
41760
41799
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
41761
41800
|
help: help || getRuleRecommendation(rule, project) || ""
|
|
@@ -42422,7 +42461,7 @@ const ScoreApiResponseSchema = Struct({
|
|
|
42422
42461
|
})))
|
|
42423
42462
|
});
|
|
42424
42463
|
const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
|
|
42425
|
-
const
|
|
42464
|
+
const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
|
|
42426
42465
|
const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
42427
42466
|
const describeFailure = (error) => {
|
|
42428
42467
|
if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
|
|
@@ -42435,7 +42474,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
42435
42474
|
const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
|
|
42436
42475
|
try {
|
|
42437
42476
|
const compressedBody = gzipSync(JSON.stringify({
|
|
42438
|
-
diagnostics:
|
|
42477
|
+
diagnostics: stripLocalFileFields(diagnostics),
|
|
42439
42478
|
...options.metadata?.repo ? { repo: options.metadata.repo } : {},
|
|
42440
42479
|
...options.metadata?.sha ? { sha: options.metadata.sha } : {},
|
|
42441
42480
|
...options.metadata?.framework ? { framework: options.metadata.framework } : {},
|
|
@@ -43721,7 +43760,7 @@ const makeNoopConsole = () => ({
|
|
|
43721
43760
|
});
|
|
43722
43761
|
//#endregion
|
|
43723
43762
|
//#region src/cli/utils/version.ts
|
|
43724
|
-
const VERSION = "0.5.1-dev.
|
|
43763
|
+
const VERSION = "0.5.1-dev.9cc6555";
|
|
43725
43764
|
//#endregion
|
|
43726
43765
|
//#region src/cli/utils/json-mode.ts
|
|
43727
43766
|
let context = null;
|
|
@@ -44079,13 +44118,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
44079
44118
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
44080
44119
|
* standard `SENTRY_RELEASE` override.
|
|
44081
44120
|
*/
|
|
44082
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.
|
|
44121
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.9cc6555`;
|
|
44083
44122
|
/**
|
|
44084
44123
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
44085
44124
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
44086
44125
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
44087
44126
|
*/
|
|
44088
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.
|
|
44127
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.9cc6555") ? "development" : "production");
|
|
44089
44128
|
/**
|
|
44090
44129
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
44091
44130
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -47690,6 +47729,12 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47690
47729
|
topRule = rule;
|
|
47691
47730
|
topRuleCount = count;
|
|
47692
47731
|
}
|
|
47732
|
+
let diagnosticsInTestFiles = 0;
|
|
47733
|
+
let diagnosticsInStoryFiles = 0;
|
|
47734
|
+
for (const diagnostic of result.diagnostics) {
|
|
47735
|
+
if (diagnostic.fileContext === "test") diagnosticsInTestFiles += 1;
|
|
47736
|
+
if (diagnostic.fileContext === "story") diagnosticsInStoryFiles += 1;
|
|
47737
|
+
}
|
|
47693
47738
|
const attributes = {
|
|
47694
47739
|
outcome,
|
|
47695
47740
|
exitCode: wouldBlock ? 1 : 0,
|
|
@@ -47700,6 +47745,8 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47700
47745
|
errorCount: summary.errorCount,
|
|
47701
47746
|
warningCount: summary.warningCount,
|
|
47702
47747
|
affectedFiles: summary.affectedFileCount,
|
|
47748
|
+
diagnosticsInTestFiles,
|
|
47749
|
+
diagnosticsInStoryFiles,
|
|
47703
47750
|
distinctRulesFired: countByRule.size,
|
|
47704
47751
|
topRule,
|
|
47705
47752
|
scannedFileCount: result.scannedFileCount ?? null,
|
|
@@ -48032,17 +48079,24 @@ const writeStdout = (text) => sync(() => {
|
|
|
48032
48079
|
const POINTER = isUnicodeSupported() ? "›" : ">";
|
|
48033
48080
|
const colorizeBySeverity = (text, severity) => severity === "error" ? highlighter.error(text) : highlighter.warn(text);
|
|
48034
48081
|
const collectAffectedFiles = (diagnostics) => new Set(diagnostics.map((diagnostic) => diagnostic.filePath));
|
|
48035
|
-
const
|
|
48036
|
-
|
|
48082
|
+
const formatFileContextTag = (diagnostic) => diagnostic.fileContext ? ` (${diagnostic.fileContext} file)` : "";
|
|
48083
|
+
const buildVerboseFileEntries = (diagnostics) => {
|
|
48084
|
+
const fileEntries = /* @__PURE__ */ new Map();
|
|
48037
48085
|
for (const diagnostic of diagnostics) {
|
|
48038
|
-
|
|
48039
|
-
if (
|
|
48086
|
+
let entry = fileEntries.get(diagnostic.filePath);
|
|
48087
|
+
if (entry === void 0) {
|
|
48088
|
+
entry = {
|
|
48089
|
+
contextTag: formatFileContextTag(diagnostic),
|
|
48090
|
+
sites: []
|
|
48091
|
+
};
|
|
48092
|
+
fileEntries.set(diagnostic.filePath, entry);
|
|
48093
|
+
}
|
|
48094
|
+
if (diagnostic.line > 0) entry.sites.push({
|
|
48040
48095
|
line: diagnostic.line,
|
|
48041
48096
|
suppressionHint: diagnostic.suppressionHint
|
|
48042
48097
|
});
|
|
48043
|
-
fileSites.set(diagnostic.filePath, sites);
|
|
48044
48098
|
}
|
|
48045
|
-
return
|
|
48099
|
+
return fileEntries;
|
|
48046
48100
|
};
|
|
48047
48101
|
const formatSiteCountBadge = (count) => count > 1 ? `×${count}` : "";
|
|
48048
48102
|
const formatTrailingSiteBadge = (count) => {
|
|
@@ -48131,10 +48185,11 @@ const clusterNearbyDiagnostics = (diagnostics) => {
|
|
|
48131
48185
|
return clusters;
|
|
48132
48186
|
};
|
|
48133
48187
|
const formatClusterLocation = (cluster) => {
|
|
48134
|
-
const
|
|
48135
|
-
|
|
48136
|
-
if (cluster.
|
|
48137
|
-
return `${filePath}:${cluster.startLine}`;
|
|
48188
|
+
const lead = cluster.diagnostics[0];
|
|
48189
|
+
const contextTag = formatFileContextTag(lead);
|
|
48190
|
+
if (cluster.startLine <= 0) return `${lead.filePath}${contextTag}`;
|
|
48191
|
+
if (cluster.endLine > cluster.startLine) return `${lead.filePath}:${cluster.startLine}-${cluster.endLine}${contextTag}`;
|
|
48192
|
+
return `${lead.filePath}:${cluster.startLine}${contextTag}`;
|
|
48138
48193
|
};
|
|
48139
48194
|
const buildDiagnosticClusterLines = (cluster, resolveSourceRoot, renderCodeFrame) => {
|
|
48140
48195
|
const lead = cluster.diagnostics[0];
|
|
@@ -48277,25 +48332,26 @@ const formatElapsedTime = (elapsedMilliseconds) => {
|
|
|
48277
48332
|
};
|
|
48278
48333
|
const formatRuleSummary = (ruleKey, ruleDiagnostics) => {
|
|
48279
48334
|
const firstDiagnostic = ruleDiagnostics[0];
|
|
48335
|
+
const distinctMessages = [...new Set(ruleDiagnostics.map((diagnostic) => diagnostic.message))];
|
|
48280
48336
|
const sections = [
|
|
48281
48337
|
`Rule: ${ruleKey}`,
|
|
48282
48338
|
`Severity: ${firstDiagnostic.severity}`,
|
|
48283
48339
|
`Category: ${firstDiagnostic.category}`,
|
|
48284
48340
|
`Count: ${ruleDiagnostics.length}`,
|
|
48285
48341
|
"",
|
|
48286
|
-
|
|
48342
|
+
distinctMessages.join("\n\n")
|
|
48287
48343
|
];
|
|
48288
48344
|
if (firstDiagnostic.help) sections.push("", `Suggestion: ${firstDiagnostic.help}`);
|
|
48289
48345
|
if (firstDiagnostic.url) sections.push("", `Docs: ${firstDiagnostic.url}`);
|
|
48290
48346
|
const fixRecipeLine = formatFixRecipeLine(firstDiagnostic);
|
|
48291
48347
|
if (fixRecipeLine) sections.push("", fixRecipeLine);
|
|
48292
48348
|
sections.push("", "Files:");
|
|
48293
|
-
const
|
|
48294
|
-
for (const [filePath, sites] of
|
|
48295
|
-
sections.push(` ${filePath}:${site.line}`);
|
|
48349
|
+
const fileEntries = buildVerboseFileEntries(ruleDiagnostics);
|
|
48350
|
+
for (const [filePath, { contextTag, sites }] of fileEntries) if (sites.length > 0) for (const site of sites) {
|
|
48351
|
+
sections.push(` ${filePath}:${site.line}${contextTag}`);
|
|
48296
48352
|
if (site.suppressionHint) sections.push(` ${site.suppressionHint}`);
|
|
48297
48353
|
}
|
|
48298
|
-
else sections.push(` ${filePath}`);
|
|
48354
|
+
else sections.push(` ${filePath}${contextTag}`);
|
|
48299
48355
|
return sections.join("\n") + "\n";
|
|
48300
48356
|
};
|
|
48301
48357
|
//#endregion
|
|
@@ -53744,4 +53800,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53744
53800
|
export {};
|
|
53745
53801
|
|
|
53746
53802
|
//# sourceMappingURL=cli.js.map
|
|
53747
|
-
//# debugId=
|
|
53803
|
+
//# debugId=5c7334de-5fd1-50a7-bb75-1a17b3b54e4e
|
package/dist/index.d.ts
CHANGED
|
@@ -9452,6 +9452,7 @@ interface DiagnosticRelatedLocation {
|
|
|
9452
9452
|
endColumn?: number;
|
|
9453
9453
|
message: string;
|
|
9454
9454
|
}
|
|
9455
|
+
type DiagnosticFileContext = "test" | "story" | "production";
|
|
9455
9456
|
interface Diagnostic {
|
|
9456
9457
|
filePath: string;
|
|
9457
9458
|
plugin: string;
|
|
@@ -9478,6 +9479,12 @@ interface Diagnostic {
|
|
|
9478
9479
|
/** 1-indexed end column of the primary span, when derivable. */
|
|
9479
9480
|
endColumn?: number;
|
|
9480
9481
|
category: string;
|
|
9482
|
+
/**
|
|
9483
|
+
* Set when the file never ships to users (`"test"` / `"story"`), so
|
|
9484
|
+
* renderers can label the site instead of implying production impact.
|
|
9485
|
+
* Omitted for production files (the default).
|
|
9486
|
+
*/
|
|
9487
|
+
fileContext?: Exclude<DiagnosticFileContext, "production">;
|
|
9481
9488
|
suppressionHint?: string;
|
|
9482
9489
|
/** Secondary source locations (oxlint's non-primary labels). */
|
|
9483
9490
|
relatedLocations?: DiagnosticRelatedLocation[];
|
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]="c8ddec5f-75dd-56a9-93b8-c34b1f202f7c")}catch(e){}}();
|
|
3
3
|
import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as NFS from "node:fs";
|
|
@@ -19253,6 +19253,7 @@ var Diagnostic = class extends Class("Diagnostic")({
|
|
|
19253
19253
|
endLine: optional(Number$1),
|
|
19254
19254
|
endColumn: optional(Number$1),
|
|
19255
19255
|
category: String$1,
|
|
19256
|
+
fileContext: optional(Literals(["test", "story"])),
|
|
19256
19257
|
suppressionHint: optional(String$1),
|
|
19257
19258
|
relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation))
|
|
19258
19259
|
}) {};
|
|
@@ -34570,8 +34571,10 @@ const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
|
|
|
34570
34571
|
const relativePath = toRelativePath(filePath, rootDirectory);
|
|
34571
34572
|
return patterns.some((pattern) => pattern.test(relativePath));
|
|
34572
34573
|
};
|
|
34574
|
+
const SCRIPT_EXTENSION_FRAGMENT = "[cm]?[jt]sx?";
|
|
34575
|
+
const STORY_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:stories|story)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
34576
|
+
const TEST_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:test|spec|fixture|fixtures)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
34573
34577
|
const TEST_FILE_DIRECTORY_PATTERN = /(?:^|\/)(?:__tests__|__test__|tests|test|__mocks__|cypress|e2e|playwright)\//;
|
|
34574
|
-
const TEST_FILE_SUFFIX_PATTERN = /\.(?:test|spec|stories|story|fixture|fixtures)\.(?:[cm]?[jt]sx?)$/;
|
|
34575
34578
|
const FIXTURE_PROJECT_PATTERN = /\/(?:fixtures|__fixtures__)\//;
|
|
34576
34579
|
const SOURCE_ROOT_PATTERN = /\/(?:src|app|lib|components|pages|features|modules|packages|apps|frontend|client)\//g;
|
|
34577
34580
|
const stripAboveSourceRoot = (relativePath) => {
|
|
@@ -34582,12 +34585,23 @@ const stripAboveSourceRoot = (relativePath) => {
|
|
|
34582
34585
|
if (lastIdx >= 0) return relativePath.slice(lastIdx);
|
|
34583
34586
|
return relativePath.slice(fixtureMatch.index + fixtureMatch[0].length - 1);
|
|
34584
34587
|
};
|
|
34585
|
-
|
|
34586
|
-
|
|
34588
|
+
/**
|
|
34589
|
+
* Classifies where a file sits relative to shipped code. A finding in a
|
|
34590
|
+
* `.stories.tsx` or `.spec.ts` file never runs in front of users, so
|
|
34591
|
+
* renderers label those sites instead of framing them as production
|
|
34592
|
+
* impact (`rn-no-raw-text` in a spec doesn't say users crash).
|
|
34593
|
+
*
|
|
34594
|
+
* `"story"` is the `.stories.*` / `.story.*` suffix; `"test"` is the
|
|
34595
|
+
* test/spec/fixture suffixes and test directories; `"production"` is
|
|
34596
|
+
* the default.
|
|
34597
|
+
*/
|
|
34598
|
+
const classifyFileContext = (relativePath) => {
|
|
34599
|
+
if (relativePath.length === 0) return "production";
|
|
34587
34600
|
const forwardSlashed = relativePath.replaceAll("\\", "/");
|
|
34588
|
-
if (
|
|
34601
|
+
if (STORY_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "story";
|
|
34602
|
+
if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "test";
|
|
34589
34603
|
const scoped = stripAboveSourceRoot(forwardSlashed);
|
|
34590
|
-
return TEST_FILE_DIRECTORY_PATTERN.test(scoped);
|
|
34604
|
+
return TEST_FILE_DIRECTORY_PATTERN.test(scoped) ? "test" : "production";
|
|
34591
34605
|
};
|
|
34592
34606
|
/**
|
|
34593
34607
|
* Resolves the user-configured severity override for a rule.
|
|
@@ -34811,6 +34825,8 @@ const collectStringSet = (values) => {
|
|
|
34811
34825
|
* 5. `rn-no-raw-text` suppression via configured `textComponents` and
|
|
34812
34826
|
* `rawTextWrapperComponents` (config-driven JSX enclosure checks)
|
|
34813
34827
|
* 6. inline suppressions (`// react-doctor-disable-next-line ...`)
|
|
34828
|
+
* 7. file-context stamping (`fileContext: "test" | "story"` on
|
|
34829
|
+
* survivors in non-production files, so renderers can label them)
|
|
34814
34830
|
*
|
|
34815
34831
|
* Returns `null` when the diagnostic is dropped, the (possibly
|
|
34816
34832
|
* severity-restamped) diagnostic otherwise.
|
|
@@ -34830,7 +34846,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34830
34846
|
const hasTextComponents = textComponentNames.size > 0;
|
|
34831
34847
|
const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
|
|
34832
34848
|
const fileLinesCache = /* @__PURE__ */ new Map();
|
|
34833
|
-
const
|
|
34849
|
+
const fileContextCache = /* @__PURE__ */ new Map();
|
|
34834
34850
|
const libraryFileCache = /* @__PURE__ */ new Map();
|
|
34835
34851
|
const isLibraryFile = (filePath) => {
|
|
34836
34852
|
let cached = libraryFileCache.get(filePath);
|
|
@@ -34847,11 +34863,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34847
34863
|
fileLinesCache.set(filePath, lines);
|
|
34848
34864
|
return lines;
|
|
34849
34865
|
};
|
|
34850
|
-
const
|
|
34851
|
-
let cached =
|
|
34866
|
+
const getFileContext = (filePath) => {
|
|
34867
|
+
let cached = fileContextCache.get(filePath);
|
|
34852
34868
|
if (cached === void 0) {
|
|
34853
|
-
cached =
|
|
34854
|
-
|
|
34869
|
+
cached = classifyFileContext(filePath);
|
|
34870
|
+
fileContextCache.set(filePath, cached);
|
|
34855
34871
|
}
|
|
34856
34872
|
return cached;
|
|
34857
34873
|
};
|
|
@@ -34860,7 +34876,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34860
34876
|
const rule = reactDoctorPlugin.rules[diagnostic.rule];
|
|
34861
34877
|
if (!rule?.tags?.includes("test-noise")) return false;
|
|
34862
34878
|
if (rule.tags.includes("migration-hint")) return false;
|
|
34863
|
-
return
|
|
34879
|
+
return getFileContext(diagnostic.filePath) !== "production";
|
|
34864
34880
|
};
|
|
34865
34881
|
const isRuleIgnored = (ruleIdentifier) => {
|
|
34866
34882
|
for (const ignored of ignoredRules) if (isSameRuleKey(ignored, ruleIdentifier)) return true;
|
|
@@ -34917,6 +34933,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34917
34933
|
};
|
|
34918
34934
|
}
|
|
34919
34935
|
}
|
|
34936
|
+
const fileContext = getFileContext(current.filePath);
|
|
34937
|
+
if (fileContext !== "production") current = {
|
|
34938
|
+
...current,
|
|
34939
|
+
fileContext
|
|
34940
|
+
};
|
|
34920
34941
|
return current;
|
|
34921
34942
|
} };
|
|
34922
34943
|
};
|
|
@@ -38474,9 +38495,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
38474
38495
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
38475
38496
|
};
|
|
38476
38497
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
38498
|
+
const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
|
|
38499
|
+
const TRAILING_PERIOD_PATTERN = /\.$/;
|
|
38477
38500
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
38478
38501
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
38479
|
-
const
|
|
38502
|
+
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
38503
|
+
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
38504
|
+
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
38505
|
+
const buildReactCompilerMessage = (reasonSummary) => {
|
|
38506
|
+
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
38507
|
+
if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
|
|
38508
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
|
|
38509
|
+
};
|
|
38480
38510
|
const PLUGIN_CATEGORY_MAP = {
|
|
38481
38511
|
react: "Bugs",
|
|
38482
38512
|
"react-hooks": "Bugs",
|
|
@@ -38515,10 +38545,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
|
38515
38545
|
};
|
|
38516
38546
|
};
|
|
38517
38547
|
const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
38518
|
-
if (plugin === "react-hooks-js")
|
|
38519
|
-
message
|
|
38520
|
-
|
|
38521
|
-
|
|
38548
|
+
if (plugin === "react-hooks-js") {
|
|
38549
|
+
const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
|
|
38550
|
+
if (rule === "todo") return {
|
|
38551
|
+
message: REACT_COMPILER_GENERIC_MESSAGE,
|
|
38552
|
+
help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
|
|
38553
|
+
};
|
|
38554
|
+
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
38555
|
+
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
38556
|
+
return {
|
|
38557
|
+
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
38558
|
+
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
38559
|
+
};
|
|
38560
|
+
}
|
|
38522
38561
|
return {
|
|
38523
38562
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
38524
38563
|
help: help || getRuleRecommendation(rule, project) || ""
|
|
@@ -39185,7 +39224,7 @@ const ScoreApiResponseSchema = Struct({
|
|
|
39185
39224
|
})))
|
|
39186
39225
|
});
|
|
39187
39226
|
const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
|
|
39188
|
-
const
|
|
39227
|
+
const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
|
|
39189
39228
|
const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
39190
39229
|
const describeFailure = (error) => {
|
|
39191
39230
|
if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
|
|
@@ -39198,7 +39237,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
39198
39237
|
const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
|
|
39199
39238
|
try {
|
|
39200
39239
|
const compressedBody = gzipSync(JSON.stringify({
|
|
39201
|
-
diagnostics:
|
|
39240
|
+
diagnostics: stripLocalFileFields(diagnostics),
|
|
39202
39241
|
...options.metadata?.repo ? { repo: options.metadata.repo } : {},
|
|
39203
39242
|
...options.metadata?.sha ? { sha: options.metadata.sha } : {},
|
|
39204
39243
|
...options.metadata?.framework ? { framework: options.metadata.framework } : {},
|
|
@@ -40273,4 +40312,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
40273
40312
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
40274
40313
|
|
|
40275
40314
|
//# sourceMappingURL=index.js.map
|
|
40276
|
-
//# debugId=
|
|
40315
|
+
//# debugId=c8ddec5f-75dd-56a9-93b8-c34b1f202f7c
|
package/dist/lsp.js
CHANGED
|
@@ -19283,6 +19283,7 @@ var Diagnostic = class extends Class("Diagnostic")({
|
|
|
19283
19283
|
endLine: optional(Number$1),
|
|
19284
19284
|
endColumn: optional(Number$1),
|
|
19285
19285
|
category: String$1,
|
|
19286
|
+
fileContext: optional(Literals(["test", "story"])),
|
|
19286
19287
|
suppressionHint: optional(String$1),
|
|
19287
19288
|
relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation))
|
|
19288
19289
|
}) {};
|
|
@@ -34630,8 +34631,10 @@ const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
|
|
|
34630
34631
|
const relativePath = toRelativePath(filePath, rootDirectory);
|
|
34631
34632
|
return patterns.some((pattern) => pattern.test(relativePath));
|
|
34632
34633
|
};
|
|
34634
|
+
const SCRIPT_EXTENSION_FRAGMENT = "[cm]?[jt]sx?";
|
|
34635
|
+
const STORY_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:stories|story)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
34636
|
+
const TEST_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:test|spec|fixture|fixtures)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
34633
34637
|
const TEST_FILE_DIRECTORY_PATTERN = /(?:^|\/)(?:__tests__|__test__|tests|test|__mocks__|cypress|e2e|playwright)\//;
|
|
34634
|
-
const TEST_FILE_SUFFIX_PATTERN = /\.(?:test|spec|stories|story|fixture|fixtures)\.(?:[cm]?[jt]sx?)$/;
|
|
34635
34638
|
const FIXTURE_PROJECT_PATTERN = /\/(?:fixtures|__fixtures__)\//;
|
|
34636
34639
|
const SOURCE_ROOT_PATTERN = /\/(?:src|app|lib|components|pages|features|modules|packages|apps|frontend|client)\//g;
|
|
34637
34640
|
const stripAboveSourceRoot = (relativePath) => {
|
|
@@ -34642,12 +34645,23 @@ const stripAboveSourceRoot = (relativePath) => {
|
|
|
34642
34645
|
if (lastIdx >= 0) return relativePath.slice(lastIdx);
|
|
34643
34646
|
return relativePath.slice(fixtureMatch.index + fixtureMatch[0].length - 1);
|
|
34644
34647
|
};
|
|
34645
|
-
|
|
34646
|
-
|
|
34648
|
+
/**
|
|
34649
|
+
* Classifies where a file sits relative to shipped code. A finding in a
|
|
34650
|
+
* `.stories.tsx` or `.spec.ts` file never runs in front of users, so
|
|
34651
|
+
* renderers label those sites instead of framing them as production
|
|
34652
|
+
* impact (`rn-no-raw-text` in a spec doesn't say users crash).
|
|
34653
|
+
*
|
|
34654
|
+
* `"story"` is the `.stories.*` / `.story.*` suffix; `"test"` is the
|
|
34655
|
+
* test/spec/fixture suffixes and test directories; `"production"` is
|
|
34656
|
+
* the default.
|
|
34657
|
+
*/
|
|
34658
|
+
const classifyFileContext = (relativePath) => {
|
|
34659
|
+
if (relativePath.length === 0) return "production";
|
|
34647
34660
|
const forwardSlashed = relativePath.replaceAll("\\", "/");
|
|
34648
|
-
if (
|
|
34661
|
+
if (STORY_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "story";
|
|
34662
|
+
if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "test";
|
|
34649
34663
|
const scoped = stripAboveSourceRoot(forwardSlashed);
|
|
34650
|
-
return TEST_FILE_DIRECTORY_PATTERN.test(scoped);
|
|
34664
|
+
return TEST_FILE_DIRECTORY_PATTERN.test(scoped) ? "test" : "production";
|
|
34651
34665
|
};
|
|
34652
34666
|
/**
|
|
34653
34667
|
* Resolves the user-configured severity override for a rule.
|
|
@@ -34867,6 +34881,8 @@ const collectStringSet = (values) => {
|
|
|
34867
34881
|
* 5. `rn-no-raw-text` suppression via configured `textComponents` and
|
|
34868
34882
|
* `rawTextWrapperComponents` (config-driven JSX enclosure checks)
|
|
34869
34883
|
* 6. inline suppressions (`// react-doctor-disable-next-line ...`)
|
|
34884
|
+
* 7. file-context stamping (`fileContext: "test" | "story"` on
|
|
34885
|
+
* survivors in non-production files, so renderers can label them)
|
|
34870
34886
|
*
|
|
34871
34887
|
* Returns `null` when the diagnostic is dropped, the (possibly
|
|
34872
34888
|
* severity-restamped) diagnostic otherwise.
|
|
@@ -34886,7 +34902,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34886
34902
|
const hasTextComponents = textComponentNames.size > 0;
|
|
34887
34903
|
const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
|
|
34888
34904
|
const fileLinesCache = /* @__PURE__ */ new Map();
|
|
34889
|
-
const
|
|
34905
|
+
const fileContextCache = /* @__PURE__ */ new Map();
|
|
34890
34906
|
const libraryFileCache = /* @__PURE__ */ new Map();
|
|
34891
34907
|
const isLibraryFile = (filePath) => {
|
|
34892
34908
|
let cached = libraryFileCache.get(filePath);
|
|
@@ -34903,11 +34919,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34903
34919
|
fileLinesCache.set(filePath, lines);
|
|
34904
34920
|
return lines;
|
|
34905
34921
|
};
|
|
34906
|
-
const
|
|
34907
|
-
let cached =
|
|
34922
|
+
const getFileContext = (filePath) => {
|
|
34923
|
+
let cached = fileContextCache.get(filePath);
|
|
34908
34924
|
if (cached === void 0) {
|
|
34909
|
-
cached =
|
|
34910
|
-
|
|
34925
|
+
cached = classifyFileContext(filePath);
|
|
34926
|
+
fileContextCache.set(filePath, cached);
|
|
34911
34927
|
}
|
|
34912
34928
|
return cached;
|
|
34913
34929
|
};
|
|
@@ -34916,7 +34932,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34916
34932
|
const rule = reactDoctorPlugin.rules[diagnostic.rule];
|
|
34917
34933
|
if (!rule?.tags?.includes("test-noise")) return false;
|
|
34918
34934
|
if (rule.tags.includes("migration-hint")) return false;
|
|
34919
|
-
return
|
|
34935
|
+
return getFileContext(diagnostic.filePath) !== "production";
|
|
34920
34936
|
};
|
|
34921
34937
|
const isRuleIgnored = (ruleIdentifier) => {
|
|
34922
34938
|
for (const ignored of ignoredRules) if (isSameRuleKey(ignored, ruleIdentifier)) return true;
|
|
@@ -34973,6 +34989,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
34973
34989
|
};
|
|
34974
34990
|
}
|
|
34975
34991
|
}
|
|
34992
|
+
const fileContext = getFileContext(current.filePath);
|
|
34993
|
+
if (fileContext !== "production") current = {
|
|
34994
|
+
...current,
|
|
34995
|
+
fileContext
|
|
34996
|
+
};
|
|
34976
34997
|
return current;
|
|
34977
34998
|
} };
|
|
34978
34999
|
};
|
|
@@ -38460,9 +38481,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
38460
38481
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
38461
38482
|
};
|
|
38462
38483
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
38484
|
+
const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
|
|
38485
|
+
const TRAILING_PERIOD_PATTERN = /\.$/;
|
|
38463
38486
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
38464
38487
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
38465
|
-
const
|
|
38488
|
+
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
38489
|
+
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
38490
|
+
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
38491
|
+
const buildReactCompilerMessage = (reasonSummary) => {
|
|
38492
|
+
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
38493
|
+
if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
|
|
38494
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
|
|
38495
|
+
};
|
|
38466
38496
|
const PLUGIN_CATEGORY_MAP = {
|
|
38467
38497
|
react: "Bugs",
|
|
38468
38498
|
"react-hooks": "Bugs",
|
|
@@ -38501,10 +38531,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
|
38501
38531
|
};
|
|
38502
38532
|
};
|
|
38503
38533
|
const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
38504
|
-
if (plugin === "react-hooks-js")
|
|
38505
|
-
message
|
|
38506
|
-
|
|
38507
|
-
|
|
38534
|
+
if (plugin === "react-hooks-js") {
|
|
38535
|
+
const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
|
|
38536
|
+
if (rule === "todo") return {
|
|
38537
|
+
message: REACT_COMPILER_GENERIC_MESSAGE,
|
|
38538
|
+
help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
|
|
38539
|
+
};
|
|
38540
|
+
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
38541
|
+
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
38542
|
+
return {
|
|
38543
|
+
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
38544
|
+
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
38545
|
+
};
|
|
38546
|
+
}
|
|
38508
38547
|
return {
|
|
38509
38548
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
38510
38549
|
help: help || getRuleRecommendation(rule, project) || ""
|
|
@@ -39171,7 +39210,7 @@ const ScoreApiResponseSchema = Struct({
|
|
|
39171
39210
|
})))
|
|
39172
39211
|
});
|
|
39173
39212
|
const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
|
|
39174
|
-
const
|
|
39213
|
+
const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
|
|
39175
39214
|
const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
39176
39215
|
const describeFailure = (error) => {
|
|
39177
39216
|
if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
|
|
@@ -39184,7 +39223,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
39184
39223
|
const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
|
|
39185
39224
|
try {
|
|
39186
39225
|
const compressedBody = gzipSync(JSON.stringify({
|
|
39187
|
-
diagnostics:
|
|
39226
|
+
diagnostics: stripLocalFileFields(diagnostics),
|
|
39188
39227
|
...options.metadata?.repo ? { repo: options.metadata.repo } : {},
|
|
39189
39228
|
...options.metadata?.sha ? { sha: options.metadata.sha } : {},
|
|
39190
39229
|
...options.metadata?.framework ? { framework: options.metadata.framework } : {},
|
|
@@ -42058,5 +42097,5 @@ const startLanguageServer = () => {
|
|
|
42058
42097
|
};
|
|
42059
42098
|
//#endregion
|
|
42060
42099
|
export { startLanguageServer };
|
|
42061
|
-
!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]="
|
|
42062
|
-
//# debugId=
|
|
42100
|
+
!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]="d189cded-30cd-5adf-aa54-2429b20c538b")}catch(e){}}();
|
|
42101
|
+
//# debugId=d189cded-30cd-5adf-aa54-2429b20c538b
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.5.1-dev.
|
|
3
|
+
"version": "0.5.1-dev.9cc6555",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"vscode-languageserver": "^9.0.1",
|
|
65
65
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
66
66
|
"vscode-uri": "^3.1.0",
|
|
67
|
-
"oxlint-plugin-react-doctor": "0.5.1-dev.
|
|
67
|
+
"oxlint-plugin-react-doctor": "0.5.1-dev.9cc6555"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"commander": "^14.0.3",
|
|
74
74
|
"ora": "^9.4.0",
|
|
75
75
|
"@react-doctor/api": "0.5.1",
|
|
76
|
-
"@react-doctor/
|
|
77
|
-
"@react-doctor/
|
|
76
|
+
"@react-doctor/core": "0.5.1",
|
|
77
|
+
"@react-doctor/language-server": "0.5.1"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": "^20.19.0 || >=22.13.0"
|