# dynamically-constructed-templates

Rule `sonarjs/dynamically-constructed-templates`. Templates should not be constructed dynamically

- 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: #1208 by reach, #509 by growth

## Linters

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

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/dynamically-constructed-templates": "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/duplicates-in-character-class](https://lintradar.dev/rules/sonarjs/duplicates-in-character-class.md): Character classes in regular expressions should not contain the same character twice
- [sonarjs/empty-string-repetition](https://lintradar.dev/rules/sonarjs/empty-string-repetition.md): Repeated patterns in regular expressions should not match the empty string
- [sonarjs/dompurify-unsafe-config](https://lintradar.dev/rules/sonarjs/dompurify-unsafe-config.md): DOMPurify configuration should not be bypassable
- [sonarjs/encryption-secure-mode](https://lintradar.dev/rules/sonarjs/encryption-secure-mode.md): Encryption algorithms should be used with secure mode and padding scheme
- [sonarjs/disabled-timeout](https://lintradar.dev/rules/sonarjs/disabled-timeout.md): Disabling Mocha timeouts should be explicit
- [sonarjs/existing-groups](https://lintradar.dev/rules/sonarjs/existing-groups.md): Replacement strings should reference existing regular expression groups

---

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