# no-angular-bypass-sanitization

Rule `sonarjs/no-angular-bypass-sanitization`. Angular built-in sanitization should not be disabled

- 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: #1240 by reach, #541 by growth

## Linters

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

## Code examples

### Correct: the rule accepts this

```js
import { Component, OnInit } from '@angular/core';
import { DomSanitizer } from "@angular/platform-browser";
import { ActivatedRoute } from '@angular/router';

@Component({
  template: '<div id="hello"><h1>Hello {{name}}</h1></div>',
})
export class HelloComponent implements OnInit {
  name: string;

  constructor(private sanitizer: DomSanitizer, private route: ActivatedRoute) { }

  ngOnInit(): void {
    this.name = this.route.snapshot.queryParams.name;
  }
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-angular-bypass-sanitization": "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/no-alphabetical-sort](https://lintradar.dev/rules/sonarjs/no-alphabetical-sort.md): "Array.prototype.sort()" and "Array.prototype.toSorted()" should use a compare function
- [sonarjs/no-array-delete](https://lintradar.dev/rules/sonarjs/no-array-delete.md): "delete" should not be used on arrays
- [sonarjs/no-all-duplicated-branches](https://lintradar.dev/rules/sonarjs/no-all-duplicated-branches.md): All branches in a conditional structure should not have exactly the same implementation
- [sonarjs/no-associative-arrays](https://lintradar.dev/rules/sonarjs/no-associative-arrays.md): Array indexes should be numeric
- [sonarjs/new-operator-misuse](https://lintradar.dev/rules/sonarjs/new-operator-misuse.md): "new" should only be used with functions and classes
- [sonarjs/no-async-constructor](https://lintradar.dev/rules/sonarjs/no-async-constructor.md): Constructors should not contain asynchronous operations

---

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