# unsupported-syntax

Rule `react-hooks/unsupported-syntax`. Validates against syntax that we do not plan to support in React Compiler

- Source: react-hooks
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 165.2M weekly downloads of presets that enable it
- Trend: +28.2% last quarter
- Rank: #104 by reach, #1353 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react-hooks/unsupported-syntax` | yes | safe | package `eslint-plugin-react-hooks` | [docs](https://react.dev/reference/eslint-plugin-react-hooks/lints/unsupported-syntax) |
| Oxlint | `react/unsupported-syntax` | no | no | plugin `react`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/react/unsupported-syntax.html) |

## Code examples

### Incorrect: the rule reports this

```js
function Component({ code }) {
  const result = eval(code); // Can't be analyzed
  return <div>{result}</div>;
}
```

```js
function Component() {
  with (Math) { // Changes scope dynamically
    return <div>{sin(PI / 2)}</div>;
  }
}
```

```js
function Component({propName}) {
  const value = eval(`props.${propName}`);
  return <div>{value}</div>;
}
```

### Correct: the rule accepts this

```js
function Component({propName, props}) {
  const value = props[propName]; // Analyzable
  return <div>{value}</div>;
}
```

```js
function Component() {
  return <div>{Math.sin(Math.PI / 2)}</div>;
}
```

```js
import {evaluate} from 'mathjs'; // or similar library

function Calculator({expression}) {
  const [result, setResult] = useState(null);

  const calculate = () => {
    try {
      // Safe mathematical expression evaluation
      setResult(evaluate(expression));
    } catch (error) {
      setResult('Invalid expression');
    }
  };

  return (
    <div>
      <button onClick={calculate}>Calculate</button>
      {result && <div>Result: {result}</div>}
    </div>
  );
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import reactHooks from "eslint-plugin-react-hooks";

export default [
  {
    plugins: { "react-hooks": reactHooks },
    rules: {
      "react-hooks/unsupported-syntax": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "react"
  ],
  "rules": {
    "react/unsupported-syntax": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [React Hooks recommended](https://lintradar.dev/presets/react-hooks-recommended.md) | ESLint | `eslint-plugin-react-hooks` | 16 | 118.4M | +21.5% |
| [Next.js Core Web Vitals](https://lintradar.dev/presets/next-core-web-vitals.md) | ESLint | `eslint-config-next` | 62 | 46.8M | +48.8% |

## Related rules

- [react-hooks/static-components](https://lintradar.dev/rules/react-hooks/static-components.md): Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering
- [react-hooks/use-memo](https://lintradar.dev/rules/react-hooks/use-memo.md): Validates usage of the useMemo() hook against common mistakes. See `useMemo()` docs for more information.
- [react-hooks/set-state-in-render](https://lintradar.dev/rules/react-hooks/set-state-in-render.md): Validates against setting state during render, which can trigger additional renders and potential infinite render loops
- [react-hooks/config](https://lintradar.dev/rules/react-hooks/config.md): Validates the compiler configuration options
- [react-hooks/set-state-in-effect](https://lintradar.dev/rules/react-hooks/set-state-in-effect.md): Validates against calling setState synchronously in an effect. This can indicate non-local derived data, a derived event pattern, or improper external data synchronization.
- [react-hooks/gating](https://lintradar.dev/rules/react-hooks/gating.md): Validates configuration of gating mode

---

Web page: https://lintradar.dev/rules/react-hooks/unsupported-syntax. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
