# disabled-auto-escaping

Rule `sonarjs/disabled-auto-escaping`. Auto-escaping in HTML template engines should not be disabled

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

## Linters

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

## Code examples

### Correct: the rule accepts this

```js
let Mustache = require("mustache");

let rendered = Mustache.render(template, { name: inputName }); // Compliant autoescaping is on by default
```

```js
const Handlebars = require('handlebars');

let source = "<p>attack {{name}}</p>";
let data = { "name": "<b>Alan</b>" };

let template = Handlebars.compile(source); // Compliant by default noEscape is set to false
```

```js
let md = require('markdown-it')(); // Compliant by default html is set to false

let result = md.render('# <b>attack</b>');
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/disabled-auto-escaping": "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/different-types-comparison](https://lintradar.dev/rules/sonarjs/different-types-comparison.md): Strict equality operators should not be used with dissimilar types
- [sonarjs/disabled-resource-integrity](https://lintradar.dev/rules/sonarjs/disabled-resource-integrity.md): Remote artifacts should not be used without integrity checks
- [sonarjs/deprecation](https://lintradar.dev/rules/sonarjs/deprecation.md): Deprecated APIs should not be used
- [sonarjs/disabled-timeout](https://lintradar.dev/rules/sonarjs/disabled-timeout.md): Disabling Mocha timeouts should be explicit
- [sonarjs/csrf](https://lintradar.dev/rules/sonarjs/csrf.md): CSRF protections should not be disabled
- [sonarjs/dompurify-unsafe-config](https://lintradar.dev/rules/sonarjs/dompurify-unsafe-config.md): DOMPurify configuration should not be bypassable

---

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