Skip to content

Commit 4edf920

Browse files
committed
[compiler] Fix error description inconsistency (#34404)
Small fix to make all descriptions consistently printed with a single period at the end. Ran `grep -rn "description:" packages/babel-plugin-react-compiler/src --include="*.ts" --exclude-dir="__tests__" | grep '\.\s*["\`]'` to find all descriptions ending in a period and manually fixed them. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34404). * #34409 * __->__ #34404 DiffTrain build for [80d7aa1](80d7aa1)
1 parent 4f18a0b commit 4edf920

35 files changed

+112
-115
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17693,11 +17693,10 @@ class CompilerDiagnostic {
1769317693
}
1769417694
printErrorMessage(source, options) {
1769517695
var _a, _b;
17696-
const buffer = [
17697-
printErrorSummary(this.category, this.reason),
17698-
'\n\n',
17699-
this.description,
17700-
];
17696+
const buffer = [printErrorSummary(this.category, this.reason)];
17697+
if (this.description != null) {
17698+
buffer.push('\n\n', `${this.description}.`);
17699+
}
1770117700
for (const detail of this.options.details) {
1770217701
switch (detail.kind) {
1770317702
case 'error': {
@@ -22939,7 +22938,7 @@ function lower(func, env, bindings = null, capturedRefs = new Map()) {
2293922938
builder.errors.pushDiagnostic(CompilerDiagnostic.create({
2294022939
category: ErrorCategory.Invariant,
2294122940
reason: 'Could not find binding',
22942-
description: `[BuildHIR] Could not find binding for param \`${param.node.name}\`.`,
22941+
description: `[BuildHIR] Could not find binding for param \`${param.node.name}\``,
2294322942
}).withDetails({
2294422943
kind: 'error',
2294522944
loc: (_a = param.node.loc) !== null && _a !== void 0 ? _a : null,
@@ -22988,7 +22987,7 @@ function lower(func, env, bindings = null, capturedRefs = new Map()) {
2298822987
builder.errors.pushDiagnostic(CompilerDiagnostic.create({
2298922988
category: ErrorCategory.Todo,
2299022989
reason: `Handle ${param.node.type} parameters`,
22991-
description: `[BuildHIR] Add support for ${param.node.type} parameters.`,
22990+
description: `[BuildHIR] Add support for ${param.node.type} parameters`,
2299222991
}).withDetails({
2299322992
kind: 'error',
2299422993
loc: (_j = param.node.loc) !== null && _j !== void 0 ? _j : null,
@@ -23018,7 +23017,7 @@ function lower(func, env, bindings = null, capturedRefs = new Map()) {
2301823017
builder.errors.pushDiagnostic(CompilerDiagnostic.create({
2301923018
category: ErrorCategory.Syntax,
2302023019
reason: `Unexpected function body kind`,
23021-
description: `Expected function body to be an expression or a block statement, got \`${body.type}\`.`,
23020+
description: `Expected function body to be an expression or a block statement, got \`${body.type}\``,
2302223021
}).withDetails({
2302323022
kind: 'error',
2302423023
loc: (_a = body.node.loc) !== null && _a !== void 0 ? _a : null,
@@ -35738,7 +35737,7 @@ class CheckInstructionsAgainstScopesVisitor extends ReactiveFunctionVisitor {
3573835737
!this.activeScopes.has(scope.id)) {
3573935738
CompilerError.invariant(false, {
3574035739
reason: 'Encountered an instruction that should be part of a scope, but where that scope has already completed',
35741-
description: `Instruction [${id}] is part of scope @${scope.id}, but that scope has already completed.`,
35740+
description: `Instruction [${id}] is part of scope @${scope.id}, but that scope has already completed`,
3574235741
details: [
3574335742
{
3574435743
kind: 'error',
@@ -40613,7 +40612,7 @@ function applySignature(context, state, signature, instruction) {
4061340612
const diagnostic = CompilerDiagnostic.create({
4061440613
category: ErrorCategory.Immutability,
4061540614
reason: 'This value cannot be modified',
40616-
description: `${reason}.`,
40615+
description: reason,
4061740616
}).withDetails({
4061840617
kind: 'error',
4061940618
loc: effect.value.loc,
@@ -41045,7 +41044,7 @@ function applyEffect(context, state, _effect, initialized, effects) {
4104541044
const diagnostic = CompilerDiagnostic.create({
4104641045
category: ErrorCategory.Immutability,
4104741046
reason: 'Cannot access variable before it is declared',
41048-
description: `${variable !== null && variable !== void 0 ? variable : 'This variable'} is accessed before it is declared, which prevents the earlier access from updating when this value changes over time.`,
41047+
description: `${variable !== null && variable !== void 0 ? variable : 'This variable'} is accessed before it is declared, which prevents the earlier access from updating when this value changes over time`,
4104941048
});
4105041049
if (hoistedAccess != null && hoistedAccess.loc != effect.value.loc) {
4105141050
diagnostic.withDetails({
@@ -41077,7 +41076,7 @@ function applyEffect(context, state, _effect, initialized, effects) {
4107741076
const diagnostic = CompilerDiagnostic.create({
4107841077
category: ErrorCategory.Immutability,
4107941078
reason: 'This value cannot be modified',
41080-
description: `${reason}.`,
41079+
description: reason,
4108141080
}).withDetails({
4108241081
kind: 'error',
4108341082
loc: effect.value.loc,
@@ -41956,7 +41955,7 @@ function computeEffectsForLegacySignature(state, signature, lvalue, receiver, ar
4195641955
'This API returns functions which cannot be memoized without leading to stale UI. ' +
4195741956
'To prevent this, by default React Compiler will skip memoizing this component/hook. ' +
4195841957
'However, you may see issues if values from this API are passed to other components/hooks that are ' +
41959-
'memoized.',
41958+
'memoized',
4196041959
].join(''),
4196141960
}).withDetails({
4196241961
kind: 'error',
@@ -44477,7 +44476,7 @@ function dropManualMemoization(func) {
4447744476
reason: 'useMemo() callbacks must return a value',
4447844477
description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad'
4447944478
? 'React.useMemo'
44480-
: 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects.`,
44479+
: 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`,
4448144480
suggestions: null,
4448244481
}).withDetails({
4448344482
kind: 'error',
@@ -48874,7 +48873,7 @@ function validateNoCapitalizedCalls(fn) {
4887448873
CompilerError.throwInvalidReact({
4887548874
category: ErrorCategory.CapitalizedCalls,
4887648875
reason,
48877-
description: `${calleeName} may be a component.`,
48876+
description: `${calleeName} may be a component`,
4887848877
loc: value.loc,
4887948878
suggestions: null,
4888048879
});
@@ -48895,7 +48894,7 @@ function validateNoCapitalizedCalls(fn) {
4889548894
errors.push({
4889648895
category: ErrorCategory.CapitalizedCalls,
4889748896
reason,
48898-
description: `${propertyName} may be a component.`,
48897+
description: `${propertyName} may be a component`,
4889948898
loc: value.loc,
4890048899
suggestions: null,
4890148900
});
@@ -49806,7 +49805,7 @@ function validateInferredDep(dep, temporaries, declsWithinMemoBlock, validDepsIn
4980649805
.map(dep => printManualMemoDependency(dep, true))
4980749806
.join(', ')}]. ${errorDiagnostic
4980849807
? getCompareDependencyResultDescription(errorDiagnostic)
49809-
: 'Inferred dependency not present in source'}.`
49808+
: 'Inferred dependency not present in source'}`
4981049809
: '',
4981149810
]
4981249811
.join('')
@@ -49966,7 +49965,7 @@ class Visitor extends ReactiveFunctionVisitor {
4996649965
reason: 'Existing memoization could not be preserved',
4996749966
description: [
4996849967
'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. ',
49969-
'This dependency may be mutated later, which could cause the value to change unexpectedly.',
49968+
'This dependency may be mutated later, which could cause the value to change unexpectedly',
4997049969
].join(''),
4997149970
}).withDetails({
4997249971
kind: 'error',
@@ -50007,7 +50006,7 @@ class Visitor extends ReactiveFunctionVisitor {
5000750006
category: ErrorCategory.PreserveManualMemo,
5000850007
reason: 'Existing memoization could not be preserved',
5000950008
description: [
50010-
'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output. ',
50009+
'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output',
5001150010
'',
5001250011
]
5001350012
.join('')
@@ -50082,7 +50081,7 @@ function validateUseMemo(fn) {
5008250081
errors.pushDiagnostic(CompilerDiagnostic.create({
5008350082
category: ErrorCategory.UseMemo,
5008450083
reason: 'useMemo() callbacks may not accept parameters',
50085-
description: 'useMemo() callbacks are called by React to cache calculations across re-renders. They should not take parameters. Instead, directly reference the props, state, or local variables needed for the computation.',
50084+
description: 'useMemo() callbacks are called by React to cache calculations across re-renders. They should not take parameters. Instead, directly reference the props, state, or local variables needed for the computation',
5008650085
suggestions: null,
5008750086
}).withDetails({
5008850087
kind: 'error',
@@ -50094,7 +50093,7 @@ function validateUseMemo(fn) {
5009450093
errors.pushDiagnostic(CompilerDiagnostic.create({
5009550094
category: ErrorCategory.UseMemo,
5009650095
reason: 'useMemo() callbacks may not be async or generator functions',
50097-
description: 'useMemo() callbacks are called once and must synchronously return a value.',
50096+
description: 'useMemo() callbacks are called once and must synchronously return a value',
5009850097
suggestions: null,
5009950098
}).withDetails({
5010050099
kind: 'error',
@@ -50122,7 +50121,7 @@ function validateLocalsNotReassignedAfterRender(fn) {
5012250121
errors.pushDiagnostic(CompilerDiagnostic.create({
5012350122
category: ErrorCategory.Immutability,
5012450123
reason: 'Cannot reassign variable after render completes',
50125-
description: `Reassigning ${variable} after render has completed can cause inconsistent behavior on subsequent renders. Consider using state instead.`,
50124+
description: `Reassigning ${variable} after render has completed can cause inconsistent behavior on subsequent renders. Consider using state instead`,
5012650125
}).withDetails({
5012750126
kind: 'error',
5012850127
loc: reassignment.loc,
@@ -51540,7 +51539,7 @@ function validateStaticComponents(fn) {
5154051539
error.pushDiagnostic(CompilerDiagnostic.create({
5154151540
category: ErrorCategory.StaticComponents,
5154251541
reason: 'Cannot create components during render',
51543-
description: `Components created during render will reset their state each time they are created. Declare components outside of render. `,
51542+
description: `Components created during render will reset their state each time they are created. Declare components outside of render`,
5154451543
})
5154551544
.withDetails({
5154651545
kind: 'error',
@@ -51577,7 +51576,7 @@ function validateNoFreezingKnownMutableFunctions(fn) {
5157751576
errors.pushDiagnostic(CompilerDiagnostic.create({
5157851577
category: ErrorCategory.Immutability,
5157951578
reason: 'Cannot modify local variables after render completes',
51580-
description: `This argument is a function which may reassign or mutate ${variable} after render, which can cause inconsistent behavior on subsequent renders. Consider using state instead.`,
51579+
description: `This argument is a function which may reassign or mutate ${variable} after render, which can cause inconsistent behavior on subsequent renders. Consider using state instead`,
5158151580
})
5158251581
.withDetails({
5158351582
kind: 'error',
@@ -53311,7 +53310,7 @@ function addImportsToProgram(path, programContext) {
5331153310
for (const [specifierName, loweredImport] of importsMap) {
5331253311
CompilerError.invariant(path.scope.getBinding(loweredImport.name) == null, {
5331353312
reason: 'Encountered conflicting import specifiers in generated program',
53314-
description: `Conflict from import ${loweredImport.module}:(${loweredImport.imported} as ${loweredImport.name}).`,
53313+
description: `Conflict from import ${loweredImport.module}:(${loweredImport.imported} as ${loweredImport.name})`,
5331553314
details: [
5331653315
{
5331753316
kind: 'error',
@@ -53579,7 +53578,7 @@ function assertValidEffectImportReference(autodepsIndex, paths, context) {
5357953578
throwInvalidReact({
5358053579
category: ErrorCategory.AutomaticEffectDependencies,
5358153580
reason: 'Cannot infer dependencies of this effect. This will break your build!',
53582-
description: 'To resolve, either pass a dependency array or fix reported compiler bailout diagnostics.' +
53581+
description: 'To resolve, either pass a dependency array or fix reported compiler bailout diagnostics' +
5358353582
(maybeErrorDiagnostic ? ` ${maybeErrorDiagnostic}` : ''),
5358453583
details: [
5358553584
{
@@ -53601,9 +53600,7 @@ function assertValidFireImportReference(paths, context) {
5360153600
category: ErrorCategory.Fire,
5360253601
reason: '[Fire] Untransformed reference to compiler-required feature.',
5360353602
description: 'Either remove this `fire` call or ensure it is successfully transformed by the compiler' +
53604-
maybeErrorDiagnostic
53605-
? ` ${maybeErrorDiagnostic}`
53606-
: '',
53603+
(maybeErrorDiagnostic != null ? ` ${maybeErrorDiagnostic}` : ''),
5360753604
details: [
5360853605
{
5360953606
kind: 'error',

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
474f25842a90f67a7aa8c6329afb5faec52181b6
1+
80d7aa17ad42efccc0ff95d2a9147ac6efe74dd5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
474f25842a90f67a7aa8c6329afb5faec52181b6
1+
80d7aa17ad42efccc0ff95d2a9147ac6efe74dd5

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ __DEV__ &&
14181418
exports.useTransition = function () {
14191419
return resolveDispatcher().useTransition();
14201420
};
1421-
exports.version = "19.2.0-www-classic-474f2584-20250906";
1421+
exports.version = "19.2.0-www-classic-80d7aa17-20250906";
14221422
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14231423
"function" ===
14241424
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ __DEV__ &&
14181418
exports.useTransition = function () {
14191419
return resolveDispatcher().useTransition();
14201420
};
1421-
exports.version = "19.2.0-www-modern-474f2584-20250906";
1421+
exports.version = "19.2.0-www-modern-80d7aa17-20250906";
14221422
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14231423
"function" ===
14241424
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-classic-474f2584-20250906";
603+
exports.version = "19.2.0-www-classic-80d7aa17-20250906";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-modern-474f2584-20250906";
603+
exports.version = "19.2.0-www-modern-80d7aa17-20250906";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-classic-474f2584-20250906";
607+
exports.version = "19.2.0-www-classic-80d7aa17-20250906";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-modern-474f2584-20250906";
607+
exports.version = "19.2.0-www-modern-80d7aa17-20250906";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19708,10 +19708,10 @@ __DEV__ &&
1970819708
(function () {
1970919709
var internals = {
1971019710
bundleType: 1,
19711-
version: "19.2.0-www-classic-474f2584-20250906",
19711+
version: "19.2.0-www-classic-80d7aa17-20250906",
1971219712
rendererPackageName: "react-art",
1971319713
currentDispatcherRef: ReactSharedInternals,
19714-
reconcilerVersion: "19.2.0-www-classic-474f2584-20250906"
19714+
reconcilerVersion: "19.2.0-www-classic-80d7aa17-20250906"
1971519715
};
1971619716
internals.overrideHookState = overrideHookState;
1971719717
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19745,7 +19745,7 @@ __DEV__ &&
1974519745
exports.Shape = Shape;
1974619746
exports.Surface = Surface;
1974719747
exports.Text = Text;
19748-
exports.version = "19.2.0-www-classic-474f2584-20250906";
19748+
exports.version = "19.2.0-www-classic-80d7aa17-20250906";
1974919749
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1975019750
"function" ===
1975119751
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)