Unify UnsafeInput and InvalidInput

This commit is contained in:
Lauren Tan
2023-06-15 15:13:37 -04:00
parent 0d01d5f69c
commit 501cf92f1e
3 changed files with 3 additions and 18 deletions
@@ -16,12 +16,6 @@ export enum ErrorSeverity {
* Unexpected syntax or input that may not be safe to compile.
*/
InvalidInput = "InvalidInput",
/**
* User code contains unsafe React patterns that might not be safe to compile, but does not mean
* the compiler has bugs. This typically means we can skip over the affected files, but other
* files without these errors can still be compiled.
*/
UnsafeInput = "UnsafeInput",
/**
* Unhandled syntax that we don't support yet.
*/
@@ -51,8 +45,6 @@ function mapSeverityToErrorCtor(severity: ErrorSeverity): CompilerErrorKind {
return TodoError;
case ErrorSeverity.Invariant:
return InvariantError;
case ErrorSeverity.UnsafeInput:
return UnsafeInputError;
default:
assertExhaustive(severity, `Unhandled severity level: ${severity}`);
}
@@ -75,12 +67,6 @@ class InvariantError extends Error {
this.name = `${ErrorSeverity.Invariant}Error`;
}
}
class UnsafeInputError extends Error {
constructor(message: string) {
super(message);
this.name = `${ErrorSeverity.UnsafeInput}Error`;
}
}
export function tryPrintCodeFrame(
options: CompilerErrorOptions
@@ -240,7 +226,6 @@ export class CompilerError extends Error {
case ErrorSeverity.InvalidInput:
return true;
case ErrorSeverity.Todo:
case ErrorSeverity.UnsafeInput:
return false;
default:
assertExhaustive(detail.severity, "Unhandled error severity");
@@ -13,10 +13,10 @@ import {
ErrorSeverity,
} from "../CompilerError";
import { GeneratedSource } from "../HIR";
import { getOrInsertDefault } from "../Utils/utils";
import { addInstrumentForget } from "./Instrumentation";
import { ExternalFunction, PluginOptions, parsePluginOptions } from "./Options";
import { compileFn } from "./Pipeline";
import { getOrInsertDefault } from "../Utils/utils";
export type CompilerPass = {
opts: PluginOptions;
@@ -207,7 +207,7 @@ export function compileProgram(
new CompilerErrorDetail({
reason,
description: violation.value.trim(),
severity: ErrorSeverity.UnsafeInput,
severity: ErrorSeverity.InvalidInput,
codeframe: null,
loc: violation.loc ?? null,
})
@@ -16,7 +16,7 @@ function lowercasecomponent() {
## Error
```
[ReactForget] UnsafeInput: One or more React eslint rules is disabled. eslint-disable react-hooks/rules-of-hooks (1:1)
[ReactForget] InvalidInput: One or more React eslint rules is disabled. eslint-disable react-hooks/rules-of-hooks (1:1)
```