Skip to content

Commit cd87215

Browse files
committed
[compiler] Fix error description inconsistency
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.
1 parent fdac79b commit cd87215

File tree

116 files changed

+145
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+145
-156
lines changed

compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,10 @@ export class CompilerDiagnostic {
141141
}
142142

143143
printErrorMessage(source: string, options: PrintErrorMessageOptions): string {
144-
const buffer = [
145-
printErrorSummary(this.category, this.reason),
146-
'\n\n',
147-
this.description,
148-
];
144+
const buffer = [printErrorSummary(this.category, this.reason)];
145+
if (this.description != null) {
146+
buffer.push('\n\n', `${this.description}.`);
147+
}
149148
for (const detail of this.options.details) {
150149
switch (detail.kind) {
151150
case 'error': {

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Imports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export function addImportsToProgram(
256256
{
257257
reason:
258258
'Encountered conflicting import specifiers in generated program',
259-
description: `Conflict from import ${loweredImport.module}:(${loweredImport.imported} as ${loweredImport.name}).`,
259+
description: `Conflict from import ${loweredImport.module}:(${loweredImport.imported} as ${loweredImport.name})`,
260260
details: [
261261
{
262262
kind: 'error',

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/ValidateNoUntransformedReferences.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function assertValidEffectImportReference(
9696
reason:
9797
'Cannot infer dependencies of this effect. This will break your build!',
9898
description:
99-
'To resolve, either pass a dependency array or fix reported compiler bailout diagnostics.' +
99+
'To resolve, either pass a dependency array or fix reported compiler bailout diagnostics' +
100100
(maybeErrorDiagnostic ? ` ${maybeErrorDiagnostic}` : ''),
101101
details: [
102102
{
@@ -128,9 +128,7 @@ function assertValidFireImportReference(
128128
reason: '[Fire] Untransformed reference to compiler-required feature.',
129129
description:
130130
'Either remove this `fire` call or ensure it is successfully transformed by the compiler' +
131-
maybeErrorDiagnostic
132-
? ` ${maybeErrorDiagnostic}`
133-
: '',
131+
(maybeErrorDiagnostic != null ? ` ${maybeErrorDiagnostic}` : ''),
134132
details: [
135133
{
136134
kind: 'error',

compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function lower(
109109
CompilerDiagnostic.create({
110110
category: ErrorCategory.Invariant,
111111
reason: 'Could not find binding',
112-
description: `[BuildHIR] Could not find binding for param \`${param.node.name}\`.`,
112+
description: `[BuildHIR] Could not find binding for param \`${param.node.name}\``,
113113
}).withDetails({
114114
kind: 'error',
115115
loc: param.node.loc ?? null,
@@ -173,7 +173,7 @@ export function lower(
173173
CompilerDiagnostic.create({
174174
category: ErrorCategory.Todo,
175175
reason: `Handle ${param.node.type} parameters`,
176-
description: `[BuildHIR] Add support for ${param.node.type} parameters.`,
176+
description: `[BuildHIR] Add support for ${param.node.type} parameters`,
177177
}).withDetails({
178178
kind: 'error',
179179
loc: param.node.loc ?? null,
@@ -204,7 +204,7 @@ export function lower(
204204
CompilerDiagnostic.create({
205205
category: ErrorCategory.Syntax,
206206
reason: `Unexpected function body kind`,
207-
description: `Expected function body to be an expression or a block statement, got \`${body.type}\`.`,
207+
description: `Expected function body to be an expression or a block statement, got \`${body.type}\``,
208208
}).withDetails({
209209
kind: 'error',
210210
loc: body.node.loc ?? null,

compiler/packages/babel-plugin-react-compiler/src/Inference/DropManualMemoization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ export function dropManualMemoization(
460460
manualMemo.loadInstr.value.kind === 'PropertyLoad'
461461
? 'React.useMemo'
462462
: 'useMemo'
463-
} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects.`,
463+
} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`,
464464
suggestions: null,
465465
}).withDetails({
466466
kind: 'error',

compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ function applySignature(
473473
const diagnostic = CompilerDiagnostic.create({
474474
category: ErrorCategory.Immutability,
475475
reason: 'This value cannot be modified',
476-
description: `${reason}.`,
476+
description: reason,
477477
}).withDetails({
478478
kind: 'error',
479479
loc: effect.value.loc,
@@ -1094,7 +1094,7 @@ function applyEffect(
10941094
const diagnostic = CompilerDiagnostic.create({
10951095
category: ErrorCategory.Immutability,
10961096
reason: 'Cannot access variable before it is declared',
1097-
description: `${variable ?? 'This variable'} is accessed before it is declared, which prevents the earlier access from updating when this value changes over time.`,
1097+
description: `${variable ?? 'This variable'} is accessed before it is declared, which prevents the earlier access from updating when this value changes over time`,
10981098
});
10991099
if (hoistedAccess != null && hoistedAccess.loc != effect.value.loc) {
11001100
diagnostic.withDetails({
@@ -1133,7 +1133,7 @@ function applyEffect(
11331133
const diagnostic = CompilerDiagnostic.create({
11341134
category: ErrorCategory.Immutability,
11351135
reason: 'This value cannot be modified',
1136-
description: `${reason}.`,
1136+
description: reason,
11371137
}).withDetails({
11381138
kind: 'error',
11391139
loc: effect.value.loc,
@@ -2269,7 +2269,7 @@ function computeEffectsForLegacySignature(
22692269
'This API returns functions which cannot be memoized without leading to stale UI. ' +
22702270
'To prevent this, by default React Compiler will skip memoizing this component/hook. ' +
22712271
'However, you may see issues if values from this API are passed to other components/hooks that are ' +
2272-
'memoized.',
2272+
'memoized',
22732273
].join(''),
22742274
}).withDetails({
22752275
kind: 'error',

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AssertScopeInstructionsWithinScope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CheckInstructionsAgainstScopesVisitor extends ReactiveFunctionVisitor<
8383
CompilerError.invariant(false, {
8484
reason:
8585
'Encountered an instruction that should be part of a scope, but where that scope has already completed',
86-
description: `Instruction [${id}] is part of scope @${scope.id}, but that scope has already completed.`,
86+
description: `Instruction [${id}] is part of scope @${scope.id}, but that scope has already completed`,
8787
details: [
8888
{
8989
kind: 'error',

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateLocalsNotReassignedAfterRender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function validateLocalsNotReassignedAfterRender(fn: HIRFunction): void {
3939
CompilerDiagnostic.create({
4040
category: ErrorCategory.Immutability,
4141
reason: 'Cannot reassign variable after render completes',
42-
description: `Reassigning ${variable} after render has completed can cause inconsistent behavior on subsequent renders. Consider using state instead.`,
42+
description: `Reassigning ${variable} after render has completed can cause inconsistent behavior on subsequent renders. Consider using state instead`,
4343
}).withDetails({
4444
kind: 'error',
4545
loc: reassignment.loc,

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoCapitalizedCalls.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function validateNoCapitalizedCalls(
5959
CompilerError.throwInvalidReact({
6060
category: ErrorCategory.CapitalizedCalls,
6161
reason,
62-
description: `${calleeName} may be a component.`,
62+
description: `${calleeName} may be a component`,
6363
loc: value.loc,
6464
suggestions: null,
6565
});
@@ -83,7 +83,7 @@ export function validateNoCapitalizedCalls(
8383
errors.push({
8484
category: ErrorCategory.CapitalizedCalls,
8585
reason,
86-
description: `${propertyName} may be a component.`,
86+
description: `${propertyName} may be a component`,
8787
loc: value.loc,
8888
suggestions: null,
8989
});

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoFreezingKnownMutableFunctions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function validateNoFreezingKnownMutableFunctions(
6767
CompilerDiagnostic.create({
6868
category: ErrorCategory.Immutability,
6969
reason: 'Cannot modify local variables after render completes',
70-
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.`,
70+
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`,
7171
})
7272
.withDetails({
7373
kind: 'error',

0 commit comments

Comments
 (0)