mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[eslint-plugin] Add test for invariants
Turning off this flag makes only critical errors throw, so TODO errors will no longer be surfaced by the plugin. The previously failing test for unsupported syntax is now valid.
This commit is contained in:
+24
-3
@@ -30,8 +30,6 @@ const tests: ForgetTestCases = {
|
||||
}
|
||||
`,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
name: "Unsupported syntax",
|
||||
code: normalizeIndent`
|
||||
@@ -40,8 +38,31 @@ const tests: ForgetTestCases = {
|
||||
return y * x;
|
||||
}
|
||||
`,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
name: "[Invariant] Defined after use",
|
||||
code: normalizeIndent`
|
||||
function Component(props) {
|
||||
let y = function () {
|
||||
m(x);
|
||||
};
|
||||
|
||||
let x = { a };
|
||||
m(x);
|
||||
return y;
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
"[ReactForget] Todo: (BuildHIR::lowerStatement) Handle var kinds in VariableDeclaration (3:3)",
|
||||
{
|
||||
message:
|
||||
"[ReactForget] Invariant: EnterSSA: Expected identifier to be defined before being used. Identifier x$2 is undefined (7:7)",
|
||||
line: 7,
|
||||
column: 3,
|
||||
endColumn: 17,
|
||||
endLine: 7,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ const rule: Rule.RuleModule = {
|
||||
Program(prog) {
|
||||
try {
|
||||
compileProgram(prog, {
|
||||
opts: parsePluginOptions(null), // use defaults for now
|
||||
opts: parsePluginOptions({ panicOnBailout: false }),
|
||||
filename: context.filename,
|
||||
comments: babelAST.comments ?? [],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user