Gathering detailed insights and metrics for eslint-plugin-no-unsanitized
Gathering detailed insights and metrics for eslint-plugin-no-unsanitized
Gathering detailed insights and metrics for eslint-plugin-no-unsanitized
Gathering detailed insights and metrics for eslint-plugin-no-unsanitized
Custom ESLint rule to disallows unsafe innerHTML, outerHTML, insertAdjacentHTML and alike
npm install eslint-plugin-no-unsanitized
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MPL-2.0 License
238 Stars
212 Commits
36 Forks
7 Watchers
46 Branches
42 Contributors
Updated on Jun 12, 2025
Latest Version
4.1.2
Package Id
eslint-plugin-no-unsanitized@4.1.2
Unpacked Size
64.27 kB
Size
17.30 kB
File Count
13
NPM Version
10.8.2
Node Version
20.17.0
Published on
Sep 30, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
These rules disallow unsafe coding practices that may result into security
vulnerabilities. We will disallow assignments (e.g., to innerHTML) as well as
calls (e.g., to insertAdjacentHTML) without the use of a pre-defined escaping
function. The escaping functions must be called with a template string.
The function names are hardcoded as Sanitizer.escapeHTML
and escapeHTML
.
The plugin also supports the
Sanitizer API
and calls to .setHTML()
are also allowed by default.
This plugin is built for and used within Mozilla to maintain and improve the security of our products and services.
The method rule disallows certain function calls.
E.g., document.write()
or insertAdjacentHTML()
.
See docs/rules/method.md for more.
The property rule disallows certain assignment expressions, e.g., to innerHTML
.
See docs/rules/property.md for more.
Here are a few examples of code that we do not want to allow:
1foo.innerHTML = input.value; 2bar.innerHTML = "<a href='" + url + "'>About</a>";
A few examples of allowed practices:
1foo.innerHTML = 5; 2bar.innerHTML = "<a href='/about.html'>About</a>"; 3bar.innerHTML = escapeHTML`<a href='${url}'>About</a>`;
With yarn or npm:
1$ yarn add -D eslint-plugin-no-unsanitized 2$ npm install --save-dev eslint-plugin-no-unsanitized
1import nounsanitized from "eslint-plugin-no-unsanitized"; 2 3export default config = [nounsanitized.configs.recommended];
or
1import nounsanitized from "eslint-plugin-no-unsanitized"; 2 3export default config = [ 4 { 5 files: ["**/*.js"], 6 plugins: { nounsanitized }, 7 rules: { 8 "no-unsanitized/method": "error", 9 "no-unsanitized/property": "error", 10 }, 11 }, 12];
In your .eslintrc.json
file enable this rule with the following:
1{ 2 "extends": ["plugin:no-unsanitized/recommended-legacy"] 3}
Or:
1{ 2 "plugins": ["no-unsanitized"], 3 "rules": { 4 "no-unsanitized/method": "error", 5 "no-unsanitized/property": "error" 6 } 7}
See docs/.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
all changesets reviewed
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More