Skip to content
← Back to rules

react/unsupported-syntax Restriction

What it does

Warns on syntax that React Compiler does not plan to support, such as eval; components and hooks using it are skipped, not optimized.

Powered by the React Compiler, which runs once per file and is shared with the other React Compiler rules. Port of react-hooks/unsupported-syntax.

Why is this bad?

Constructs like eval make data flow unanalyzable, so the component permanently opts out of compiler optimization.

Examples

Examples of incorrect code for this rule:

jsx
function Component(props) {
  eval("props.x = true");
  return <div />;
}

Examples of correct code for this rule:

jsx
function Component(props) {
  return <div>{props.x}</div>;
}

How to use

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["react"],
  "rules": {
    "react/unsupported-syntax": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["react"],
  rules: {
    "react/unsupported-syntax": "error",
  },
});
bash
oxlint --deny react/unsupported-syntax --react-plugin

Version

This rule was added in vnext.

References