# code-eval

Rule `sonarjs/code-eval`. Dynamic code execution should not use user-controlled data

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1192 by reach, #493 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/code-eval` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-1523/) |

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/code-eval": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/class-name](https://lintradar.dev/rules/sonarjs/class-name.md): Class names should comply with a naming convention
- [sonarjs/comma-or-logical-or-case](https://lintradar.dev/rules/sonarjs/comma-or-logical-or-case.md): Comma and logical OR operators should not be used in switch cases
- [sonarjs/chai-determinate-assertion](https://lintradar.dev/rules/sonarjs/chai-determinate-assertion.md): Chai assertions should have only one reason to succeed
- [sonarjs/concise-regex](https://lintradar.dev/rules/sonarjs/concise-regex.md): Regular expression quantifiers and character classes should be used concisely
- [sonarjs/call-argument-line](https://lintradar.dev/rules/sonarjs/call-argument-line.md): Function call arguments should not start on new lines
- [sonarjs/constructor-for-side-effects](https://lintradar.dev/rules/sonarjs/constructor-for-side-effects.md): Objects should not be created to be dropped immediately without being used

---

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