Add InvalidReact and InvalidConfig error severities
Lauren Tan committed
Jun 27, 2023 at 14:01 UTC
6c4318e5c2a1b40e71e9cfb5330022dc63916119
57 files changed
+119
-74
compiler/forget/packages/babel-plugin-react-forget/src/CompilerError.ts
+44
@@ -14,6 +14,14 @@ export enum ErrorSeverity {
14
* Unexpected syntax or input that may not be safe to compile.
15
*/
16
InvalidInput = "InvalidInput",
17
+ /**
18
+ * Code that breaks the rules of React.
19
+ */
20
+ InvalidReact = "InvalidReact",
21
+ /**
22
+ * Incorrect configuration of the compiler.
23
+ */
24
+ InvalidConfig = "InvalidConfig",
25
/**
26
* Unhandled syntax that we don't support yet.
27
*/
@@ -123,6 +131,40 @@ export class CompilerError extends Error {
131
throw errors;
132
}
133
134
+ static invalidReact(
135
+ reason: string,
136
+ loc: SourceLocation | null,
137
+ description: string | null = null
138
+ ): never {
139
+ const errors = new CompilerError();
140
+ errors.pushErrorDetail(
141
+ new CompilerErrorDetail({
142
+ description,
143
+ loc,
144
+ reason,
145
+ severity: ErrorSeverity.InvalidReact,
146
+ })
147
+ );
148
+ throw errors;
149
+ }
150
+
151
+ static invalidConfig(
152
+ reason: string,
153
+ loc: SourceLocation | null,
154
+ description: string | null = null
155
+ ): never {
156
+ const errors = new CompilerError();
157
+ errors.pushErrorDetail(
158
+ new CompilerErrorDetail({
159
+ description,
160
+ loc,
161
+ reason,
162
+ severity: ErrorSeverity.InvalidConfig,
163
+ })
164
+ );
165
+ throw errors;
166
+ }
167
+
168
constructor(...args: any[]) {
169
super(...args);
170
this.name = "ReactForgetCompilerError";
@@ -167,6 +209,8 @@ export class CompilerError extends Error {
209
switch (detail.severity) {
210
case ErrorSeverity.Invariant:
211
case ErrorSeverity.InvalidInput:
212
+ case ErrorSeverity.InvalidReact:
213
+ case ErrorSeverity.InvalidConfig:
214
return true;
215
case ErrorSeverity.Todo:
216
return false;
compiler/forget/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+5
-5
@@ -210,7 +210,7 @@ export function compileProgram(
210
new CompilerErrorDetail({
211
reason,
212
description: violation.value.trim(),
213
- severity: ErrorSeverity.InvalidInput,
213
+ severity: ErrorSeverity.InvalidReact,
214
loc: violation.loc ?? null,
215
})
216
);
@@ -426,14 +426,14 @@ function addImportsToProgram(
426
// Codegen currently does not rename import specifiers, so we do additional
427
// validation here
428
if (identifiers.has(importSpecifierName)) {
429
- CompilerError.invalidInput(
430
- `[InvalidConfig] Encountered conflicting import specifier for ${importSpecifierName} in Forget config.`,
429
+ CompilerError.invalidConfig(
430
+ `Encountered conflicting import specifier for ${importSpecifierName} in Forget config.`,
431
GeneratedSource
432
);
433
}
434
if (path.scope.hasBinding(importSpecifierName)) {
435
- CompilerError.invalidInput(
436
- `[InvalidConfig] Encountered conflicting import specifiers for ${importSpecifierName} in generated program.`,
435
+ CompilerError.invalidConfig(
436
+ `Encountered conflicting import specifiers for ${importSpecifierName} in generated program.`,
437
GeneratedSource
438
);
439
}
compiler/forget/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts
+1
-1
@@ -2481,7 +2481,7 @@ function lowerIdentifierForAssignment(
2481
// Trying to reassign a global is not allowed
2482
builder.errors.push({
2483
reason: `(BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported.`,
2484
- severity: ErrorSeverity.InvalidInput,
2484
+ severity: ErrorSeverity.InvalidReact,
2485
loc: path.node.loc ?? null,
2486
});
2487
} else {
compiler/forget/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts
+2
-2
@@ -315,7 +315,7 @@ class InferenceState {
315
) {
316
effect = Effect.Mutate;
317
} else {
318
- CompilerError.invalidInput(
318
+ CompilerError.invalidReact(
319
`InferReferenceEffects: inferred mutation of known immutable value`,
320
place.loc,
321
`Found mutation of ${printIdentifier(place.identifier)}${printType(
@@ -330,7 +330,7 @@ class InferenceState {
330
valueKind !== ValueKind.Mutable &&
331
valueKind !== ValueKind.Context
332
) {
333
- CompilerError.invalidInput(
333
+ CompilerError.invalidReact(
334
`InferReferenceEffects: inferred mutation of known immutable value`,
335
place.loc,
336
`Found mutation of ${printIdentifier(place.identifier)}${printType(
compiler/forget/packages/babel-plugin-react-forget/src/Inference/InlineUseMemo.ts
+2
-2
@@ -100,14 +100,14 @@ export function inlineUseMemo(fn: HIRFunction): void {
100
}
101
102
if (body.loweredFunc.params.length > 0) {
103
- CompilerError.invalidInput(
103
+ CompilerError.invalidReact(
104
"useMemo callbacks may not accept any arguments",
105
body.loc
106
);
107
}
108
109
if (body.loweredFunc.async || body.loweredFunc.generator) {
110
- CompilerError.invalidInput(
110
+ CompilerError.invalidReact(
111
"useMemo callbacks may not be async or generator functions",
112
body.loc
113
);
compiler/forget/packages/babel-plugin-react-forget/src/Validation/ValidateFrozenLambdas.ts
+1
-1
@@ -137,7 +137,7 @@ function validateOperand(
137
loc: typeof operand.loc !== "symbol" ? operand.loc : null,
138
reason:
139
"Cannot use a mutable function where an immutable value is expected",
140
- severity: ErrorSeverity.InvalidInput,
140
+ severity: ErrorSeverity.InvalidReact,
141
});
142
}
143
}
compiler/forget/packages/babel-plugin-react-forget/src/Validation/ValidateHooksUsage.ts
+1
-1
@@ -30,7 +30,7 @@ export function validateHooksUsage(fn: HIRFunction): void {
30
reason:
31
"Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning)",
32
loc: typeof place.loc !== "symbol" ? place.loc : null,
33
- severity: ErrorSeverity.InvalidInput,
33
+ severity: ErrorSeverity.InvalidReact,
34
})
35
);
36
};
compiler/forget/packages/babel-plugin-react-forget/src/Validation/ValidateNoRefAccesInRender.ts
+2
-2
@@ -108,7 +108,7 @@ function validateNonRefValue(error: CompilerError, operand: Place): void {
108
loc: typeof operand.loc !== "symbol" ? operand.loc : null,
109
reason:
110
"Ref values (the `current` property) may not be accessed during render",
111
- severity: ErrorSeverity.InvalidInput,
111
+ severity: ErrorSeverity.InvalidReact,
112
})
113
);
114
}
@@ -123,7 +123,7 @@ function validateNonRefObject(error: CompilerError, operand: Place): void {
123
loc: typeof operand.loc !== "symbol" ? operand.loc : null,
124
reason:
125
"Ref values may not be passed to functions because they could read the ref value (`current` property) during render",
126
- severity: ErrorSeverity.InvalidInput,
126
+ severity: ErrorSeverity.InvalidReact,
127
})
128
);
129
}
compiler/forget/packages/babel-plugin-react-forget/src/Validation/ValidateUnconditionalHooks.ts
+1
-1
@@ -97,7 +97,7 @@ export function validateUnconditionalHooks(
97
reason:
98
"Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning)",
99
loc,
100
- severity: ErrorSeverity.InvalidInput,
100
+ severity: ErrorSeverity.InvalidReact,
101
})
102
);
103
}
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.codegen-error-on-conflicting-imports.expect.md
+1
-1
@@ -15,7 +15,7 @@ function useFoo(props) {
15
## Error
16
17
```
18
-[ReactForget] InvalidInput: [InvalidConfig] Encountered conflicting import specifiers for makeReadOnly in generated program.
18
+[ReactForget] InvalidConfig: Encountered conflicting import specifiers for makeReadOnly in generated program.
19
```
20
21
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-access-ref-during-render.expect.md
+1
-1
@@ -15,7 +15,7 @@ function Component(props) {
15
## Error
16
17
```
18
-[ReactForget] InvalidInput: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $22:TObject<BuiltInRefValue> (5:5)
18
+[ReactForget] InvalidReact: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $22:TObject<BuiltInRefValue> (5:5)
19
```
20
21
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md
+1
-1
@@ -15,7 +15,7 @@ function Component(props) {
15
## Error
16
17
```
18
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $19:TObject<BuiltInArray> (frozen) (4:4)
18
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $19:TObject<BuiltInArray> (frozen) (4:4)
19
```
20
21
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-assign-hook-to-local.expect.md
+1
-1
@@ -14,7 +14,7 @@ function Component(props) {
14
## Error
15
16
```
17
-[ReactForget] InvalidInput: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
17
+[ReactForget] InvalidReact: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
18
```
19
20
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-capture-func-passed-to-jsx.expect.md
+1
-1
@@ -20,7 +20,7 @@ function component(a, b) {
20
## Error
21
22
```
23
-[ReactForget] InvalidInput: Cannot use a mutable function where an immutable value is expected (8:8)
23
+[ReactForget] InvalidReact: Cannot use a mutable function where an immutable value is expected (8:8)
24
```
25
26
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-computed-store-to-frozen-value.expect.md
+1
-1
@@ -16,7 +16,7 @@ function Component(props) {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $21 (frozen) (5:5)
19
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $21 (frozen) (5:5)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-computed-property-of-frozen-value.expect.md
+1
-1
@@ -16,7 +16,7 @@ function Component(props) {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $19 (frozen) (5:5)
19
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $19 (frozen) (5:5)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-delete-property-of-frozen-value.expect.md
+1
-1
@@ -16,7 +16,7 @@ function Component(props) {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $18 (frozen) (5:5)
19
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $18 (frozen) (5:5)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-destructure-assignment-to-global.expect.md
+1
-1
@@ -13,7 +13,7 @@ function useFoo(props) {
13
## Error
14
15
```
16
-[ReactForget] InvalidInput: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (2:2)
16
+[ReactForget] InvalidReact: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (2:2)
17
```
18
19
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-destructure-to-local-global-variables.expect.md
+1
-1
@@ -15,7 +15,7 @@ function Component(props) {
15
## Error
16
17
```
18
-[ReactForget] InvalidInput: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (3:3)
18
+[ReactForget] InvalidReact: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (3:3)
19
```
20
21
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-freeze-conditionally-mutable-lambda.expect.md
+1
-1
@@ -25,7 +25,7 @@ function Component(props) {
25
## Error
26
27
```
28
-[ReactForget] InvalidInput: Cannot use a mutable function where an immutable value is expected (15:15)
28
+[ReactForget] InvalidReact: Cannot use a mutable function where an immutable value is expected (15:15)
29
```
30
31
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-freeze-mutable-lambda-mutate-local.expect.md
+1
-1
@@ -18,7 +18,7 @@ function Component(props) {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: Cannot use a mutable function where an immutable value is expected (8:8)
21
+[ReactForget] InvalidReact: Cannot use a mutable function where an immutable value is expected (8:8)
22
```
23
24
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-freeze-mutable-lambda-reassign-local.expect.md
+1
-1
@@ -16,7 +16,7 @@ function Component(props) {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: Cannot use a mutable function where an immutable value is expected (6:6)
19
+[ReactForget] InvalidReact: Cannot use a mutable function where an immutable value is expected (6:6)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-function-expression-mutates-immutable-value.expect.md
+1
-1
@@ -18,7 +18,7 @@ function Component(props) {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $39 (frozen) (5:5)
21
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $39 (frozen) (5:5)
22
```
23
24
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md
+1
-1
@@ -25,7 +25,7 @@ function Component(props) {
25
## Error
26
27
```
28
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $44:TObject<BuiltInArray> (frozen) (13:13)
28
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $44:TObject<BuiltInArray> (frozen) (13:13)
29
```
30
31
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md
+1
-1
@@ -19,7 +19,7 @@ function Component(props) {
19
## Error
20
21
```
22
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $26:TObject<BuiltInArray> (frozen) (7:7)
22
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $26:TObject<BuiltInArray> (frozen) (7:7)
23
```
24
25
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-pass-hook-as-call-arg.expect.md
+1
-1
@@ -12,7 +12,7 @@ function Component(props) {
12
## Error
13
14
```
15
-[ReactForget] InvalidInput: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
15
+[ReactForget] InvalidReact: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
16
```
17
18
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-pass-hook-as-prop.expect.md
+1
-1
@@ -12,7 +12,7 @@ function Component(props) {
12
## Error
13
14
```
15
-[ReactForget] InvalidInput: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
15
+[ReactForget] InvalidReact: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
16
```
17
18
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-pass-ref-to-function.expect.md
+1
-1
@@ -14,7 +14,7 @@ function Component(props) {
14
## Error
15
16
```
17
-[ReactForget] InvalidInput: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at mutate? $21[6:8]:TObject<BuiltInUseRefId> (3:3)
17
+[ReactForget] InvalidReact: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at mutate? $21[6:8]:TObject<BuiltInUseRefId> (3:3)
18
```
19
20
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-property-store-to-frozen-value.expect.md
+1
-1
@@ -16,7 +16,7 @@ function Component(props) {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $20 (frozen) (5:5)
19
+[ReactForget] InvalidReact: InferReferenceEffects: inferred mutation of known immutable value. Found mutation of $20 (frozen) (5:5)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-ref-in-callback-invoked-during-render.expect.md
+1
-1
@@ -18,7 +18,7 @@ function Component(props) {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at capture $42[6:16]:TObject<BuiltInRefValue> (5:5)
21
+[ReactForget] InvalidReact: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at capture $42[6:16]:TObject<BuiltInRefValue> (5:5)
22
```
23
24
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-ref-value-as-props.expect.md
+1
-1
@@ -13,7 +13,7 @@ function Component(props) {
13
## Error
14
15
```
16
-[ReactForget] InvalidInput: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $19:TObject<BuiltInRefValue> (3:3)
16
+[ReactForget] InvalidReact: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $19:TObject<BuiltInRefValue> (3:3)
17
```
18
19
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-set-and-read-ref-during-render.expect.md
+2
-2
@@ -14,9 +14,9 @@ function Component(props) {
14
## Error
15
16
```
17
-[ReactForget] InvalidInput: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at store $21[7:9]:TObject<BuiltInUseRefId> (3:3)
17
+[ReactForget] InvalidReact: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at store $21[7:9]:TObject<BuiltInUseRefId> (3:3)
18
19
-[ReactForget] InvalidInput: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $24:TObject<BuiltInRefValue> (4:4)
19
+[ReactForget] InvalidReact: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $24:TObject<BuiltInRefValue> (4:4)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-sketchy-code-use-forget.expect.md
+1
-1
@@ -16,7 +16,7 @@ function lowercasecomponent() {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: One or more React eslint rules is disabled. eslint-disable react-hooks/rules-of-hooks (1:1)
19
+[ReactForget] InvalidReact: One or more React eslint rules is disabled. eslint-disable react-hooks/rules-of-hooks (1:1)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-ternary-with-hook-values.expect.md
+2
-2
@@ -13,9 +13,9 @@ function Component(props) {
13
## Error
14
15
```
16
-[ReactForget] InvalidInput: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
16
+[ReactForget] InvalidReact: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
17
18
-[ReactForget] InvalidInput: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
18
+[ReactForget] InvalidReact: Hooks may not be referenced as normal values, they must be called. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (2:2)
19
```
20
21
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-use-ref-added-to-dep-without-type-info.expect.md
+1
-1
@@ -21,7 +21,7 @@ function Foo({ a }) {
21
## Error
22
23
```
24
-[ReactForget] InvalidInput: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at capture $29:TObject<BuiltInUseRefId> (4:4)
24
+[ReactForget] InvalidReact: Ref values may not be passed to functions because they could read the ref value (`current` property) during render. Cannot access ref object at capture $29:TObject<BuiltInUseRefId> (4:4)
25
```
26
27
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-useMemo-async-callback.expect.md
+1
-1
@@ -15,7 +15,7 @@ function component(a, b) {
15
## Error
16
17
```
18
-[ReactForget] InvalidInput: useMemo callbacks may not be async or generator functions (2:4)
18
+[ReactForget] InvalidReact: useMemo callbacks may not be async or generator functions (2:4)
19
```
20
21
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.invalid-useMemo-callback-args.expect.md
+1
-1
@@ -13,7 +13,7 @@ function component(a, b) {
13
## Error
14
15
```
16
-[ReactForget] InvalidInput: useMemo callbacks may not accept any arguments (2:2)
16
+[ReactForget] InvalidReact: useMemo callbacks may not accept any arguments (2:2)
17
```
18
19
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md
+2
-2
@@ -127,9 +127,9 @@ let moduleLocal = false;
127
128
[ReactForget] Todo: (BuildHIR::node.lowerReorderableExpression) Expression type 'BinaryExpression' cannot be safely reordered (53:53)
129
130
-[ReactForget] InvalidInput: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (64:64)
130
+[ReactForget] InvalidReact: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (64:64)
131
132
-[ReactForget] InvalidInput: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (65:65)
132
+[ReactForget] InvalidReact: (BuildHIR::lowerAssignment) Assigning to an identifier defined outside the function scope is not supported. (65:65)
133
```
134
135
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-hook-after-early-return.expect.md
+1
-1
@@ -15,7 +15,7 @@ function Component(props) {
15
## Error
16
17
```
18
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
18
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
19
```
20
21
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-hook-for.expect.md
+3
-3
@@ -16,11 +16,11 @@ function Component(props) {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (3:3)
19
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (3:3)
20
21
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (4:4)
21
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (4:4)
22
23
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (3:3)
23
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (3:3)
24
```
25
26
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-hook-if-alternate.expect.md
+1
-1
@@ -17,7 +17,7 @@ function Component(props) {
17
## Error
18
19
```
20
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
20
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
21
```
22
23
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-hook-if-consequent.expect.md
+1
-1
@@ -16,7 +16,7 @@ function Component(props) {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (4:4)
19
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (4:4)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.expect.md
+4
-4
@@ -25,13 +25,13 @@ function useHookInLoops() {
25
## Error
26
27
```
28
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
28
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
29
30
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (9:9)
30
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (9:9)
31
32
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
32
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
33
34
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (14:14)
34
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (14:14)
35
```
36
37
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.expect.md
+1
-1
@@ -18,7 +18,7 @@ function ComponentWithConditionalHook() {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
21
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.expect.md
+1
-1
@@ -19,7 +19,7 @@ function useLabeledBlock() {
19
## Error
20
21
```
22
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (8:8)
22
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (8:8)
23
```
24
25
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.expect.md
+1
-1
@@ -18,7 +18,7 @@ function ComponentWithHookInsideLoop() {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
21
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.expect.md
+1
-1
@@ -22,7 +22,7 @@ function useHook() {
22
## Error
23
24
```
25
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
25
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
26
```
27
28
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.expect.md
+2
-2
@@ -17,9 +17,9 @@ function useHook() {
17
## Error
18
19
```
20
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
20
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
21
22
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
23
```
24
25
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.expect.md
+1
-1
@@ -16,7 +16,7 @@ function ComponentWithTernaryHook() {
16
## Error
17
18
```
19
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
19
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
20
```
21
22
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.expect.md
+1
-1
@@ -17,7 +17,7 @@ function useHook() {
17
## Error
18
19
```
20
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
20
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
21
```
22
23
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.expect.md
+1
-1
@@ -18,7 +18,7 @@ function normalFunctionWithConditionalHook() {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
21
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.expect.md
+2
-2
@@ -20,9 +20,9 @@ function useHookInLoops() {
20
## Error
21
22
```
23
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
23
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
24
25
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (9:9)
25
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (9:9)
26
```
27
28
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.expect.md
+1
-1
@@ -18,7 +18,7 @@ function useHookWithConditionalHook() {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
21
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.expect.md
+1
-1
@@ -22,7 +22,7 @@ function useHook() {
22
## Error
23
24
```
25
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
25
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
26
```
27
28
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.expect.md
+3
-3
@@ -18,11 +18,11 @@ function useHook({ bar }) {
18
## Error
19
20
```
21
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
21
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
22
23
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
23
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
24
25
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (8:8)
25
+[ReactForget] InvalidReact: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (8:8)
26
```
27
28
\ No newline at end of file
compiler/forget/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
+1
-1
@@ -72,7 +72,7 @@ const tests: ForgetTestCases = {
72
errors: [
73
{
74
message:
75
- "[ReactForget] InvalidInput: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $22:TObject<BuiltInRefValue> (6:6)",
75
+ "[ReactForget] InvalidReact: Ref values (the `current` property) may not be accessed during render. Cannot access ref value at freeze $22:TObject<BuiltInRefValue> (6:6)",
76
line: 6,
77
column: 10,
78
endColumn: 15,
compiler/forget/packages/eslint-plugin-react-forget/src/rules/ReactForgetDiagnostics.ts
+1
@@ -29,6 +29,7 @@ function isReportableDiagnostic(
29
): detail is CompilerErrorDetailWithLoc {
30
let isCorrectSeverity = false;
31
switch (detail.severity) {
32
+ case ErrorSeverity.InvalidReact:
33
case ErrorSeverity.InvalidInput:
34
isCorrectSeverity = true;
35
break;