mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Unify UnsafeInput and InvalidInput
This commit is contained in:
@@ -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,
|
||||
})
|
||||
|
||||
+1
-1
@@ -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)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user