Skip to content

linter: react/react-compiler throws error on a for loop without a variable-declaration initializer #24842

Description

@mds-ant

What version of Oxlint are you using?

1.75.0

What command did you run?

No response

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "categories": {
    "correctness": "off"
  },
  "plugins": ["react"],
  "rules": {
    "react/react-compiler": "error"
  }
}

What happened?

Repro

import { useEffect } from "react";

function Component() {
  useEffect(() => {
    let i = 0;
    for (; i < 3; i++) {
      console.log(i);
    }
  });
  return null;
}

Output

Actual output

  x react(react-compiler): Invariant: Expected a variable declaration
    ,-[repro.tsx:3:1]
  2 |     
  3 | ,-> function Component() {
  4 | |     useEffect(() => {
  5 | |       let i = 0;
  6 | |       for (; i < 3; i++) {
  7 | |         console.log(i);
  8 | |       }
  9 | |     });
 10 | |     return null;
 11 | `-> }
    `----

Found 0 warnings and 1 error.

Metadata

Metadata

Assignees

Labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions