react-doctor 0.5.1-dev.04e72a4 → 0.5.1-dev.0f91fa3
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 +56 -27
- package/dist/index.js +51 -23
- package/dist/lsp.js +51 -23
- package/package.json +3 -3
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]="1d684d2d-e86c-59eb-9d49-df82d09c24a5")}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";
|
|
@@ -39266,6 +39266,17 @@ const checkPnpmHardening = (rootDirectory) => {
|
|
|
39266
39266
|
}));
|
|
39267
39267
|
return diagnostics;
|
|
39268
39268
|
};
|
|
39269
|
+
const buildReactNativeDiagnostic = (input) => ({
|
|
39270
|
+
filePath: input.filePath,
|
|
39271
|
+
plugin: "react-doctor",
|
|
39272
|
+
rule: input.rule,
|
|
39273
|
+
severity: input.severity ?? "warning",
|
|
39274
|
+
message: input.message,
|
|
39275
|
+
help: input.help,
|
|
39276
|
+
line: input.line ?? 0,
|
|
39277
|
+
column: input.column ?? 0,
|
|
39278
|
+
category: input.category ?? "Correctness"
|
|
39279
|
+
});
|
|
39269
39280
|
const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
|
|
39270
39281
|
const isBuilderBobLibrary = (packageJson) => {
|
|
39271
39282
|
const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
|
|
@@ -39277,17 +39288,12 @@ const checkReactNativeLibraryDependencies = (rootDirectory) => {
|
|
|
39277
39288
|
const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
|
|
39278
39289
|
if (misplaced.length === 0) return [];
|
|
39279
39290
|
const quoted = misplaced.map((name) => `"${name}"`).join(" and ");
|
|
39280
|
-
return [{
|
|
39291
|
+
return [buildReactNativeDiagnostic({
|
|
39281
39292
|
filePath: "package.json",
|
|
39282
|
-
plugin: "react-doctor",
|
|
39283
39293
|
rule: "rn-library-react-in-dependencies",
|
|
39284
|
-
severity: "warning",
|
|
39285
39294
|
message: `This react-native-builder-bob library lists ${quoted} in \`dependencies\` — that ships a second copy into consumer apps, causing "Invalid hook call" (duplicate React) and duplicate-native-module crashes.`,
|
|
39286
|
-
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development)
|
|
39287
|
-
|
|
39288
|
-
column: 0,
|
|
39289
|
-
category: "Correctness"
|
|
39290
|
-
}];
|
|
39295
|
+
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`
|
|
39296
|
+
})];
|
|
39291
39297
|
};
|
|
39292
39298
|
const BABEL_CONFIG_FILE_NAMES = [
|
|
39293
39299
|
"babel.config.js",
|
|
@@ -39299,6 +39305,8 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
39299
39305
|
".babelrc.json"
|
|
39300
39306
|
];
|
|
39301
39307
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
39308
|
+
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
39309
|
+
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
39302
39310
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
39303
39311
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
39304
39312
|
const filePath = Path.join(rootDirectory, fileName);
|
|
@@ -39309,18 +39317,20 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
39309
39317
|
} catch {
|
|
39310
39318
|
continue;
|
|
39311
39319
|
}
|
|
39312
|
-
if (
|
|
39313
|
-
return [{
|
|
39320
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
39314
39321
|
filePath: fileName,
|
|
39315
|
-
plugin: "react-doctor",
|
|
39316
39322
|
rule: "rn-no-metro-babel-preset",
|
|
39317
39323
|
severity: "error",
|
|
39318
39324
|
message: "`module:metro-react-native-babel-preset` was renamed to `@react-native/babel-preset` and is no longer installed by React Native 0.73+ — this preset reference fails to resolve and breaks the Metro/Babel transform.",
|
|
39319
|
-
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
39320
|
-
|
|
39321
|
-
|
|
39322
|
-
|
|
39323
|
-
|
|
39325
|
+
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
39326
|
+
})];
|
|
39327
|
+
if (MODERN_PRESET_REFERENCE.test(contents) && !ENABLE_BABEL_RUNTIME_VERSION.test(contents)) return [buildReactNativeDiagnostic({
|
|
39328
|
+
filePath: fileName,
|
|
39329
|
+
rule: "rn-no-metro-babel-runtime-version",
|
|
39330
|
+
severity: "warning",
|
|
39331
|
+
message: "`module:@react-native/babel-preset` has no `enableBabelRuntime` version, so Babel runtime helpers can be duplicated across files instead of imported once from @babel/runtime, increasing the JS bundle size.",
|
|
39332
|
+
help: "Set `enableBabelRuntime` to the @babel/runtime version from package.json, e.g. `['module:@react-native/babel-preset', { enableBabelRuntime: '^7.26.0' }]`."
|
|
39333
|
+
})];
|
|
39324
39334
|
}
|
|
39325
39335
|
return [];
|
|
39326
39336
|
};
|
|
@@ -41732,9 +41742,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
41732
41742
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
41733
41743
|
};
|
|
41734
41744
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
41745
|
+
const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
|
|
41746
|
+
const TRAILING_PERIOD_PATTERN = /\.$/;
|
|
41735
41747
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
41736
41748
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
41737
|
-
const
|
|
41749
|
+
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
41750
|
+
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
41751
|
+
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
41752
|
+
const buildReactCompilerMessage = (reasonSummary) => {
|
|
41753
|
+
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
41754
|
+
if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
|
|
41755
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
|
|
41756
|
+
};
|
|
41738
41757
|
const PLUGIN_CATEGORY_MAP = {
|
|
41739
41758
|
react: "Bugs",
|
|
41740
41759
|
"react-hooks": "Bugs",
|
|
@@ -41773,10 +41792,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
|
41773
41792
|
};
|
|
41774
41793
|
};
|
|
41775
41794
|
const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
41776
|
-
if (plugin === "react-hooks-js")
|
|
41777
|
-
message
|
|
41778
|
-
|
|
41779
|
-
|
|
41795
|
+
if (plugin === "react-hooks-js") {
|
|
41796
|
+
const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
|
|
41797
|
+
if (rule === "todo") return {
|
|
41798
|
+
message: REACT_COMPILER_GENERIC_MESSAGE,
|
|
41799
|
+
help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
|
|
41800
|
+
};
|
|
41801
|
+
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
41802
|
+
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
41803
|
+
return {
|
|
41804
|
+
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
41805
|
+
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
41806
|
+
};
|
|
41807
|
+
}
|
|
41780
41808
|
return {
|
|
41781
41809
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
41782
41810
|
help: help || getRuleRecommendation(rule, project) || ""
|
|
@@ -43742,7 +43770,7 @@ const makeNoopConsole = () => ({
|
|
|
43742
43770
|
});
|
|
43743
43771
|
//#endregion
|
|
43744
43772
|
//#region src/cli/utils/version.ts
|
|
43745
|
-
const VERSION = "0.5.1-dev.
|
|
43773
|
+
const VERSION = "0.5.1-dev.0f91fa3";
|
|
43746
43774
|
//#endregion
|
|
43747
43775
|
//#region src/cli/utils/json-mode.ts
|
|
43748
43776
|
let context = null;
|
|
@@ -44100,13 +44128,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
44100
44128
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
44101
44129
|
* standard `SENTRY_RELEASE` override.
|
|
44102
44130
|
*/
|
|
44103
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.
|
|
44131
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.0f91fa3`;
|
|
44104
44132
|
/**
|
|
44105
44133
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
44106
44134
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
44107
44135
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
44108
44136
|
*/
|
|
44109
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.
|
|
44137
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.0f91fa3") ? "development" : "production");
|
|
44110
44138
|
/**
|
|
44111
44139
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
44112
44140
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -48314,13 +48342,14 @@ const formatElapsedTime = (elapsedMilliseconds) => {
|
|
|
48314
48342
|
};
|
|
48315
48343
|
const formatRuleSummary = (ruleKey, ruleDiagnostics) => {
|
|
48316
48344
|
const firstDiagnostic = ruleDiagnostics[0];
|
|
48345
|
+
const distinctMessages = [...new Set(ruleDiagnostics.map((diagnostic) => diagnostic.message))];
|
|
48317
48346
|
const sections = [
|
|
48318
48347
|
`Rule: ${ruleKey}`,
|
|
48319
48348
|
`Severity: ${firstDiagnostic.severity}`,
|
|
48320
48349
|
`Category: ${firstDiagnostic.category}`,
|
|
48321
48350
|
`Count: ${ruleDiagnostics.length}`,
|
|
48322
48351
|
"",
|
|
48323
|
-
|
|
48352
|
+
distinctMessages.join("\n\n")
|
|
48324
48353
|
];
|
|
48325
48354
|
if (firstDiagnostic.help) sections.push("", `Suggestion: ${firstDiagnostic.help}`);
|
|
48326
48355
|
if (firstDiagnostic.url) sections.push("", `Docs: ${firstDiagnostic.url}`);
|
|
@@ -53781,4 +53810,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53781
53810
|
export {};
|
|
53782
53811
|
|
|
53783
53812
|
//# sourceMappingURL=cli.js.map
|
|
53784
|
-
//# debugId=
|
|
53813
|
+
//# debugId=1d684d2d-e86c-59eb-9d49-df82d09c24a5
|
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]="aec4d374-d95e-51fe-a6c6-578b187e2520")}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";
|
|
@@ -36045,6 +36045,17 @@ const checkPnpmHardening = (rootDirectory) => {
|
|
|
36045
36045
|
}));
|
|
36046
36046
|
return diagnostics;
|
|
36047
36047
|
};
|
|
36048
|
+
const buildReactNativeDiagnostic = (input) => ({
|
|
36049
|
+
filePath: input.filePath,
|
|
36050
|
+
plugin: "react-doctor",
|
|
36051
|
+
rule: input.rule,
|
|
36052
|
+
severity: input.severity ?? "warning",
|
|
36053
|
+
message: input.message,
|
|
36054
|
+
help: input.help,
|
|
36055
|
+
line: input.line ?? 0,
|
|
36056
|
+
column: input.column ?? 0,
|
|
36057
|
+
category: input.category ?? "Correctness"
|
|
36058
|
+
});
|
|
36048
36059
|
const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
|
|
36049
36060
|
const isBuilderBobLibrary = (packageJson) => {
|
|
36050
36061
|
const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
|
|
@@ -36056,17 +36067,12 @@ const checkReactNativeLibraryDependencies = (rootDirectory) => {
|
|
|
36056
36067
|
const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
|
|
36057
36068
|
if (misplaced.length === 0) return [];
|
|
36058
36069
|
const quoted = misplaced.map((name) => `"${name}"`).join(" and ");
|
|
36059
|
-
return [{
|
|
36070
|
+
return [buildReactNativeDiagnostic({
|
|
36060
36071
|
filePath: "package.json",
|
|
36061
|
-
plugin: "react-doctor",
|
|
36062
36072
|
rule: "rn-library-react-in-dependencies",
|
|
36063
|
-
severity: "warning",
|
|
36064
36073
|
message: `This react-native-builder-bob library lists ${quoted} in \`dependencies\` — that ships a second copy into consumer apps, causing "Invalid hook call" (duplicate React) and duplicate-native-module crashes.`,
|
|
36065
|
-
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development)
|
|
36066
|
-
|
|
36067
|
-
column: 0,
|
|
36068
|
-
category: "Correctness"
|
|
36069
|
-
}];
|
|
36074
|
+
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`
|
|
36075
|
+
})];
|
|
36070
36076
|
};
|
|
36071
36077
|
const BABEL_CONFIG_FILE_NAMES = [
|
|
36072
36078
|
"babel.config.js",
|
|
@@ -36078,6 +36084,8 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
36078
36084
|
".babelrc.json"
|
|
36079
36085
|
];
|
|
36080
36086
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
36087
|
+
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
36088
|
+
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
36081
36089
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
36082
36090
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
36083
36091
|
const filePath = Path.join(rootDirectory, fileName);
|
|
@@ -36088,18 +36096,20 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
36088
36096
|
} catch {
|
|
36089
36097
|
continue;
|
|
36090
36098
|
}
|
|
36091
|
-
if (
|
|
36092
|
-
return [{
|
|
36099
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
36093
36100
|
filePath: fileName,
|
|
36094
|
-
plugin: "react-doctor",
|
|
36095
36101
|
rule: "rn-no-metro-babel-preset",
|
|
36096
36102
|
severity: "error",
|
|
36097
36103
|
message: "`module:metro-react-native-babel-preset` was renamed to `@react-native/babel-preset` and is no longer installed by React Native 0.73+ — this preset reference fails to resolve and breaks the Metro/Babel transform.",
|
|
36098
|
-
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
36099
|
-
|
|
36100
|
-
|
|
36101
|
-
|
|
36102
|
-
|
|
36104
|
+
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
36105
|
+
})];
|
|
36106
|
+
if (MODERN_PRESET_REFERENCE.test(contents) && !ENABLE_BABEL_RUNTIME_VERSION.test(contents)) return [buildReactNativeDiagnostic({
|
|
36107
|
+
filePath: fileName,
|
|
36108
|
+
rule: "rn-no-metro-babel-runtime-version",
|
|
36109
|
+
severity: "warning",
|
|
36110
|
+
message: "`module:@react-native/babel-preset` has no `enableBabelRuntime` version, so Babel runtime helpers can be duplicated across files instead of imported once from @babel/runtime, increasing the JS bundle size.",
|
|
36111
|
+
help: "Set `enableBabelRuntime` to the @babel/runtime version from package.json, e.g. `['module:@react-native/babel-preset', { enableBabelRuntime: '^7.26.0' }]`."
|
|
36112
|
+
})];
|
|
36103
36113
|
}
|
|
36104
36114
|
return [];
|
|
36105
36115
|
};
|
|
@@ -38495,9 +38505,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
38495
38505
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
38496
38506
|
};
|
|
38497
38507
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
38508
|
+
const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
|
|
38509
|
+
const TRAILING_PERIOD_PATTERN = /\.$/;
|
|
38498
38510
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
38499
38511
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
38500
|
-
const
|
|
38512
|
+
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
38513
|
+
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
38514
|
+
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
38515
|
+
const buildReactCompilerMessage = (reasonSummary) => {
|
|
38516
|
+
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
38517
|
+
if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
|
|
38518
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
|
|
38519
|
+
};
|
|
38501
38520
|
const PLUGIN_CATEGORY_MAP = {
|
|
38502
38521
|
react: "Bugs",
|
|
38503
38522
|
"react-hooks": "Bugs",
|
|
@@ -38536,10 +38555,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
|
38536
38555
|
};
|
|
38537
38556
|
};
|
|
38538
38557
|
const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
38539
|
-
if (plugin === "react-hooks-js")
|
|
38540
|
-
message
|
|
38541
|
-
|
|
38542
|
-
|
|
38558
|
+
if (plugin === "react-hooks-js") {
|
|
38559
|
+
const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
|
|
38560
|
+
if (rule === "todo") return {
|
|
38561
|
+
message: REACT_COMPILER_GENERIC_MESSAGE,
|
|
38562
|
+
help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
|
|
38563
|
+
};
|
|
38564
|
+
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
38565
|
+
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
38566
|
+
return {
|
|
38567
|
+
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
38568
|
+
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
38569
|
+
};
|
|
38570
|
+
}
|
|
38543
38571
|
return {
|
|
38544
38572
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
38545
38573
|
help: help || getRuleRecommendation(rule, project) || ""
|
|
@@ -40294,4 +40322,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
40294
40322
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
40295
40323
|
|
|
40296
40324
|
//# sourceMappingURL=index.js.map
|
|
40297
|
-
//# debugId=
|
|
40325
|
+
//# debugId=aec4d374-d95e-51fe-a6c6-578b187e2520
|
package/dist/lsp.js
CHANGED
|
@@ -36031,6 +36031,17 @@ const checkPnpmHardening = (rootDirectory) => {
|
|
|
36031
36031
|
}));
|
|
36032
36032
|
return diagnostics;
|
|
36033
36033
|
};
|
|
36034
|
+
const buildReactNativeDiagnostic = (input) => ({
|
|
36035
|
+
filePath: input.filePath,
|
|
36036
|
+
plugin: "react-doctor",
|
|
36037
|
+
rule: input.rule,
|
|
36038
|
+
severity: input.severity ?? "warning",
|
|
36039
|
+
message: input.message,
|
|
36040
|
+
help: input.help,
|
|
36041
|
+
line: input.line ?? 0,
|
|
36042
|
+
column: input.column ?? 0,
|
|
36043
|
+
category: input.category ?? "Correctness"
|
|
36044
|
+
});
|
|
36034
36045
|
const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
|
|
36035
36046
|
const isBuilderBobLibrary = (packageJson) => {
|
|
36036
36047
|
const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
|
|
@@ -36042,17 +36053,12 @@ const checkReactNativeLibraryDependencies = (rootDirectory) => {
|
|
|
36042
36053
|
const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
|
|
36043
36054
|
if (misplaced.length === 0) return [];
|
|
36044
36055
|
const quoted = misplaced.map((name) => `"${name}"`).join(" and ");
|
|
36045
|
-
return [{
|
|
36056
|
+
return [buildReactNativeDiagnostic({
|
|
36046
36057
|
filePath: "package.json",
|
|
36047
|
-
plugin: "react-doctor",
|
|
36048
36058
|
rule: "rn-library-react-in-dependencies",
|
|
36049
|
-
severity: "warning",
|
|
36050
36059
|
message: `This react-native-builder-bob library lists ${quoted} in \`dependencies\` — that ships a second copy into consumer apps, causing "Invalid hook call" (duplicate React) and duplicate-native-module crashes.`,
|
|
36051
|
-
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development)
|
|
36052
|
-
|
|
36053
|
-
column: 0,
|
|
36054
|
-
category: "Correctness"
|
|
36055
|
-
}];
|
|
36060
|
+
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`
|
|
36061
|
+
})];
|
|
36056
36062
|
};
|
|
36057
36063
|
const BABEL_CONFIG_FILE_NAMES = [
|
|
36058
36064
|
"babel.config.js",
|
|
@@ -36064,6 +36070,8 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
36064
36070
|
".babelrc.json"
|
|
36065
36071
|
];
|
|
36066
36072
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
36073
|
+
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
36074
|
+
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
36067
36075
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
36068
36076
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
36069
36077
|
const filePath = Path.join(rootDirectory, fileName);
|
|
@@ -36074,18 +36082,20 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
36074
36082
|
} catch {
|
|
36075
36083
|
continue;
|
|
36076
36084
|
}
|
|
36077
|
-
if (
|
|
36078
|
-
return [{
|
|
36085
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
36079
36086
|
filePath: fileName,
|
|
36080
|
-
plugin: "react-doctor",
|
|
36081
36087
|
rule: "rn-no-metro-babel-preset",
|
|
36082
36088
|
severity: "error",
|
|
36083
36089
|
message: "`module:metro-react-native-babel-preset` was renamed to `@react-native/babel-preset` and is no longer installed by React Native 0.73+ — this preset reference fails to resolve and breaks the Metro/Babel transform.",
|
|
36084
|
-
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
36085
|
-
|
|
36086
|
-
|
|
36087
|
-
|
|
36088
|
-
|
|
36090
|
+
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
36091
|
+
})];
|
|
36092
|
+
if (MODERN_PRESET_REFERENCE.test(contents) && !ENABLE_BABEL_RUNTIME_VERSION.test(contents)) return [buildReactNativeDiagnostic({
|
|
36093
|
+
filePath: fileName,
|
|
36094
|
+
rule: "rn-no-metro-babel-runtime-version",
|
|
36095
|
+
severity: "warning",
|
|
36096
|
+
message: "`module:@react-native/babel-preset` has no `enableBabelRuntime` version, so Babel runtime helpers can be duplicated across files instead of imported once from @babel/runtime, increasing the JS bundle size.",
|
|
36097
|
+
help: "Set `enableBabelRuntime` to the @babel/runtime version from package.json, e.g. `['module:@react-native/babel-preset', { enableBabelRuntime: '^7.26.0' }]`."
|
|
36098
|
+
})];
|
|
36089
36099
|
}
|
|
36090
36100
|
return [];
|
|
36091
36101
|
};
|
|
@@ -38481,9 +38491,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
38481
38491
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
38482
38492
|
};
|
|
38483
38493
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
38494
|
+
const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
|
|
38495
|
+
const TRAILING_PERIOD_PATTERN = /\.$/;
|
|
38484
38496
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
38485
38497
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
38486
|
-
const
|
|
38498
|
+
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
38499
|
+
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
38500
|
+
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
38501
|
+
const buildReactCompilerMessage = (reasonSummary) => {
|
|
38502
|
+
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
38503
|
+
if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
|
|
38504
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
|
|
38505
|
+
};
|
|
38487
38506
|
const PLUGIN_CATEGORY_MAP = {
|
|
38488
38507
|
react: "Bugs",
|
|
38489
38508
|
"react-hooks": "Bugs",
|
|
@@ -38522,10 +38541,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
|
38522
38541
|
};
|
|
38523
38542
|
};
|
|
38524
38543
|
const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
38525
|
-
if (plugin === "react-hooks-js")
|
|
38526
|
-
message
|
|
38527
|
-
|
|
38528
|
-
|
|
38544
|
+
if (plugin === "react-hooks-js") {
|
|
38545
|
+
const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
|
|
38546
|
+
if (rule === "todo") return {
|
|
38547
|
+
message: REACT_COMPILER_GENERIC_MESSAGE,
|
|
38548
|
+
help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
|
|
38549
|
+
};
|
|
38550
|
+
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
38551
|
+
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
38552
|
+
return {
|
|
38553
|
+
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
38554
|
+
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
38555
|
+
};
|
|
38556
|
+
}
|
|
38529
38557
|
return {
|
|
38530
38558
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
38531
38559
|
help: help || getRuleRecommendation(rule, project) || ""
|
|
@@ -42079,5 +42107,5 @@ const startLanguageServer = () => {
|
|
|
42079
42107
|
};
|
|
42080
42108
|
//#endregion
|
|
42081
42109
|
export { startLanguageServer };
|
|
42082
|
-
!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]="
|
|
42083
|
-
//# debugId=
|
|
42110
|
+
!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]="1181bb4c-4d5f-57b6-a733-98f432895c80")}catch(e){}}();
|
|
42111
|
+
//# debugId=1181bb4c-4d5f-57b6-a733-98f432895c80
|
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.0f91fa3",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"agent-install": "0.0.5",
|
|
55
55
|
"conf": "^15.1.0",
|
|
56
56
|
"confbox": "^0.2.4",
|
|
57
|
-
"deslop-js": "^0.0.
|
|
57
|
+
"deslop-js": "^0.0.24",
|
|
58
58
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
59
59
|
"jiti": "^2.7.0",
|
|
60
60
|
"magicast": "^0.5.3",
|
|
@@ -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.0f91fa3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/babel__code-frame": "^7.27.0",
|