Safeguard
Developer Tools•

Which ESLint rules flag XSS sinks in React and Vue code?

react/no-danger, vue/no-v-html, no-eval and related rules catch common XSS sinks early. What each flags, how to configure it and what lint cannot see.

Safeguard Security Team
3 min read

Four rule families cover the common sinks: react/no-danger for dangerous JSX props, vue/no-v-html for the v-html directive, and the core no-eval, no-implied-eval and no-new-func rules for code built from strings. They find sinks quickly, but a reviewer still has to judge each one.

What each rule does

RulePluginWhat it reports
react/no-dangereslint-plugin-reactDangerous JSX properties, those whose behavior is a common source of vulnerabilities
vue/no-v-htmleslint-plugin-vueEvery use of the v-html directive, to reduce the risk of injecting unescaped HTML
no-evalESLint coreCalls to eval
no-implied-evalESLint coreStrings passed to timers that are compiled like eval
no-new-funcESLint coreBuilding functions from strings

OWASP recommends linting with the typescript-eslint recommended sets plus no-eval, no-implied-eval and no-new-func for TypeScript projects.

Configuration details worth knowing

The react/no-danger rule has a customComponentNames option. By default it is empty. You can pass an array of component names, or the wildcard value, to apply the rule to custom components too. This matters when a design system component forwards a dangerous prop.

The vue/no-v-html rule is included in the eslint-plugin-vue recommended presets, according to its documentation. It also has an ignorePattern option that skips directives whose variable matches a pattern, for example names that start with html. All uses are forbidden by default.

Both rules' pages say that if you are certain the content is sanitized HTML you can switch the rule off. That is a decision to document, not a quiet disable comment.

A rollout plan

  1. Turn the rules on as warnings for one week to see the count.
  2. Triage the hits using the sink review table.
  3. Fix or wrap the legitimate ones in a single helper that sanitizes, and allow the rule there with a comment explaining why.
  4. Promote the rule to an error so new uses fail the build.
  5. Require review for any new disable comment, by code owners.

What lint cannot see

Static rules inspect syntax. They do not know where a value came from. A call that passes a constant is flagged the same as one that passes a comment from a stranger. They also miss sinks hidden in dependencies, URL attributes such as href, and server side template injection. Pair lint with code scanning, dependency scanning and runtime controls like a content security policy.

Try it yourself

Click through it at your own pace, or open it full screen. Compare how a scan reports findings with how a lint rule reports a hit.

Safeguard's free scan at gold.safeguard.sh/scan covers the dependency side, which lint does not.

Quick check

Should I disable react/no-danger for sanitized content?

The rule docs allow it when you are certain the content is sanitized. Limit the disable to one helper so it is easy to audit.

Do these rules catch href problems?

Not by themselves. They target specific props and directives, so URL validation needs its own check.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.