Skip to content

Commit ae73465

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 d331a8a commit ae73465

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
@@ -110,7 +110,7 @@ export function lower(
110110
CompilerDiagnostic.create({
111111
category: ErrorCategory.Invariant,
112112
reason: 'Could not find binding',
113-
description: `[BuildHIR] Could not find binding for param \`${param.node.name}\`.`,
113+
description: `[BuildHIR] Could not find binding for param \`${param.node.name}\``,
114114
}).withDetails({
115115
kind: 'error',
116116
loc: param.node.loc ?? null,
@@ -174,7 +174,7 @@ export function lower(
174174
CompilerDiagnostic.create({
175175
category: ErrorCategory.Todo,
176176
reason: `Handle ${param.node.type} parameters`,
177-
description: `[BuildHIR] Add support for ${param.node.type} parameters.`,
177+
description: `[BuildHIR] Add support for ${param.node.type} parameters`,
178178
}).withDetails({
179179
kind: 'error',
180180
loc: param.node.loc ?? null,
@@ -205,7 +205,7 @@ export function lower(
205205
CompilerDiagnostic.create({
206206
category: ErrorCategory.Syntax,
207207
reason: `Unexpected function body kind`,
208-
description: `Expected function body to be an expression or a block statement, got \`${body.type}\`.`,
208+
description: `Expected function body to be an expression or a block statement, got \`${body.type}\``,
209209
}).withDetails({
210210
kind: 'error',
211211
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
@@ -465,7 +465,7 @@ export function dropManualMemoization(
465465
manualMemo.loadInstr.value.kind === 'PropertyLoad'
466466
? 'React.useMemo'
467467
: 'useMemo'
468-
} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects.`,
468+
} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`,
469469
suggestions: null,
470470
}).withDetails({
471471
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
@@ -475,7 +475,7 @@ function applySignature(
475475
const diagnostic = CompilerDiagnostic.create({
476476
category: ErrorCategory.Immutability,
477477
reason: 'This value cannot be modified',
478-
description: `${reason}.`,
478+
description: reason,
479479
}).withDetails({
480480
kind: 'error',
481481
loc: effect.value.loc,
@@ -1096,7 +1096,7 @@ function applyEffect(
10961096
const diagnostic = CompilerDiagnostic.create({
10971097
category: ErrorCategory.Immutability,
10981098
reason: 'Cannot access variable before it is declared',
1099-
description: `${variable ?? 'This variable'} is accessed before it is declared, which prevents the earlier access from updating when this value changes over time.`,
1099+
description: `${variable ?? 'This variable'} is accessed before it is declared, which prevents the earlier access from updating when this value changes over time`,
11001100
});
11011101
if (hoistedAccess != null && hoistedAccess.loc != effect.value.loc) {
11021102
diagnostic.withDetails({
@@ -1135,7 +1135,7 @@ function applyEffect(
11351135
const diagnostic = CompilerDiagnostic.create({
11361136
category: ErrorCategory.Immutability,
11371137
reason: 'This value cannot be modified',
1138-
description: `${reason}.`,
1138+
description: reason,
11391139
}).withDetails({
11401140
kind: 'error',
11411141
loc: effect.value.loc,
@@ -2271,7 +2271,7 @@ function computeEffectsForLegacySignature(
22712271
'This API returns functions which cannot be memoized without leading to stale UI. ' +
22722272
'To prevent this, by default React Compiler will skip memoizing this component/hook. ' +
22732273
'However, you may see issues if values from this API are passed to other components/hooks that are ' +
2274-
'memoized.',
2274+
'memoized',
22752275
].join(''),
22762276
}).withDetails({
22772277
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)