Unify UnsafeInput and InvalidInput
Lauren Tan committed
Jun 15, 2023 at 15:13 UTC
501cf92f1e06cf88e4f0f2b49099f36568e794a5
3 files changed
+3
-18
compiler/forget/packages/babel-plugin-react-forget/src/CompilerError.ts
-15
@@ -16,12 +16,6 @@ export enum ErrorSeverity {
16
* Unexpected syntax or input that may not be safe to compile.
17
*/
18
InvalidInput = "InvalidInput",
19
- /**
20
- * User code contains unsafe React patterns that might not be safe to compile, but does not mean
21
- * the compiler has bugs. This typically means we can skip over the affected files, but other
22
- * files without these errors can still be compiled.
23
- */
24
- UnsafeInput = "UnsafeInput",
19
/**
20
* Unhandled syntax that we don't support yet.
21
*/
@@ -51,8 +45,6 @@ function mapSeverityToErrorCtor(severity: ErrorSeverity): CompilerErrorKind {
45
return TodoError;
46
case ErrorSeverity.Invariant:
47
return InvariantError;
54
- case ErrorSeverity.UnsafeInput:
55
- return UnsafeInputError;
48
default:
49
assertExhaustive(severity, `Unhandled severity level: ${severity}`);
50
}
@@ -75,12 +67,6 @@ class InvariantError extends Error {
67
this.name = `${ErrorSeverity.Invariant}Error`;
68
}
69
}
78
-class UnsafeInputError extends Error {
79
- constructor(message: string) {
80
- super(message);
81
- this.name = `${ErrorSeverity.UnsafeInput}Error`;
82
- }
83
-}
70
71
export function tryPrintCodeFrame(
72
options: CompilerErrorOptions
@@ -240,7 +226,6 @@ export class CompilerError extends Error {
226
case ErrorSeverity.InvalidInput:
227
return true;
228
case ErrorSeverity.Todo:
243
- case ErrorSeverity.UnsafeInput:
229
return false;
230
default:
231
assertExhaustive(detail.severity, "Unhandled error severity");
compiler/forget/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+2
-2
@@ -13,10 +13,10 @@ import {
13
ErrorSeverity,
14
} from "../CompilerError";
15
import { GeneratedSource } from "../HIR";
16
+import { getOrInsertDefault } from "../Utils/utils";
17
import { addInstrumentForget } from "./Instrumentation";
18
import { ExternalFunction, PluginOptions, parsePluginOptions } from "./Options";
19
import { compileFn } from "./Pipeline";
19
-import { getOrInsertDefault } from "../Utils/utils";
20
21
export type CompilerPass = {
22
opts: PluginOptions;
@@ -207,7 +207,7 @@ export function compileProgram(
207
new CompilerErrorDetail({
208
reason,
209
description: violation.value.trim(),
210
- severity: ErrorSeverity.UnsafeInput,
210
+ severity: ErrorSeverity.InvalidInput,
211
codeframe: null,
212
loc: violation.loc ?? null,
213
})
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] UnsafeInput: One or more React eslint rules is disabled. eslint-disable react-hooks/rules-of-hooks (1:1)
19
+[ReactForget] InvalidInput: 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