Skip to main content

no-angular-innerhtml-binding

Disallow Angular [innerHTML] bindings for raw HTML without a reviewed sanitization strategy.

Targeted pattern scopeโ€‹

Angular template bindings that write raw HTML using [innerHTML].

What this rule reportsโ€‹

Template fragments containing [innerHTML]=... bindings.

Why this rule existsโ€‹

Raw HTML bindings are high-risk unless source content is tightly sanitized and policy-reviewed.

โŒ Incorrectโ€‹

const template = `<div [innerHTML]="userHtml"></div>`;

โœ… Correctโ€‹

const template = `<div>{{ safeText }}</div>`;

ESLint flat config exampleโ€‹

import sdl from "eslint-plugin-sdl-2";

export default [
{
plugins: { sdl },

rules: {
"sdl/no-angular-innerhtml-binding": "error",
},
},
];

When not to use itโ€‹

Disable only when your application has a documented, reviewed sanitization policy for the HTML source being bound.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R029