The best ESLint security plugins in 2026 are eslint-plugin-security for Node.js injection patterns, eslint-plugin-no-unsanitized for DOM cross-site scripting, eslint-plugin-security-node for server-side rules, Microsoft SDL for web security rules, eslint-plugin-no-secrets for leaked credentials, eslint-plugin-sonarjs for bug and security hotspots, and eslint-plugin-unicorn for safer modern JavaScript. All seven are free and open source.
Key takeaways
- Start with eslint-plugin-security and eslint-plugin-no-unsanitized — they cover the most common injection and cross-site scripting patterns.
- ESLint catches patterns, not vulnerabilities: it cannot trace data across files, so pair it with a real scanner.
- Roll rules out in phases, error on the obvious ones first, or developers will ignore the warnings.
ESLint already runs in most JavaScript and TypeScript projects, usually for code style. Add the right security plugins and the same tool becomes a lightweight scanner that flags unsafe patterns while you write code, before they reach production.
How did we choose these plugins?
We chose plugins that are actively maintained, widely used, free and open source, and that cover a distinct security area: Node.js injection, DOM cross-site scripting, secrets, Microsoft SDL rules, or general bug and security hotspots.
We also weighed an independent 2026 benchmark that ran 17 plugins against 40 vulnerable code patterns and 38 safe patterns. Its headline finding matters: the median plugin detected under 10 percent of vulnerability patterns, and even the best-known plugin caught only 11 of 40. ESLint catches patterns, not vulnerabilities, and this list is honest about that limit.
Every plugin below is free. Pricing in the table is therefore the same for all of them — the real cost is the time you spend tuning rules so developers do not start ignoring warnings.
Which ESLint security plugin is best for you?
Use eslint-plugin-security for Node.js, eslint-plugin-no-unsanitized for browser code, eslint-plugin-no-secrets for leaked credentials, and SonarJS or Unicorn for broader bug and security coverage. Most teams need two or three, not all seven.
| Plugin | Best for | Free plan | Starting price | Key feature |
|---|---|---|---|---|
| eslint-plugin-security | Node.js injection | Yes, free | Free | eval, dynamic require, timing attacks |
| eslint-plugin-no-unsanitized | DOM cross-site scripting | Yes, free | Free | innerHTML and document.write checks |
| eslint-plugin-security-node | Server-side Node.js | Yes, free | Free | 22 Node.js security rules |
| Microsoft SDL | Web security rules | Yes, free | Free | Microsoft Security Development Lifecycle rules |
| eslint-plugin-no-secrets | Leaked credentials | Yes, free | Free | Detects secrets in code |
| eslint-plugin-sonarjs | Bug and security hotspots | Yes, free | Free | 269 rules, broad coverage |
| eslint-plugin-unicorn | Safer modern JavaScript | Yes, free | Free | 144 rules for modern, safe code |
Install with npm as a development dependency, for example npm install eslint-plugin-security --save-dev. See the free hash generator for checking file integrity in your build pipeline.
What does eslint-plugin-security catch?
eslint-plugin-security is the most widely used security plugin for ESLint, with about 1.5 million weekly downloads. It flags patterns commonly associated with vulnerabilities in Node.js applications.
1. eslint-plugin-security — best for Node.js injection
eslint-plugin-security is the default starting point for Node.js security linting. Its useful rules include detect-eval-with-expression, which flags eval calls with dynamic expressions, and detect-non-literal-require, which flags require calls with dynamic arguments that could load unexpected modules.
- Key features: detect-eval-with-expression, detect-non-literal-require, detect-non-literal-regexp for ReDoS risk, detect-possible-timing-attacks for string comparisons on tokens, detect-no-csrf-before-method-override for Express misconfiguration.
- Pros: most installed security plugin; covers the most common Node.js injection patterns; simple to configure.
- Cons: high false positive rate — about one false alarm for every real bug in benchmark testing; detect-object-injection flags any bracket notation and is usually too noisy to enable; caught 0 of 6 SQL injection cases in a 2026 benchmark.
Pricing: free and open source, published on npm. Install with npm install eslint-plugin-security --save-dev.
Who should pick it: every Node.js team, as the first security plugin. Enable the high-confidence rules as errors and disable the noisy ones.
2. eslint-plugin-no-unsanitized — best for DOM cross-site scripting
eslint-plugin-no-unsanitized is maintained by Mozilla and targets DOM-based cross-site scripting in browser JavaScript. It flags direct assignment to innerHTML, outerHTML and similar DOM properties, plus calls to document.write and insertAdjacentHTML.
- Key features: no-unsanitized/method and no-unsanitized/property rules; configurable allowlist for sanitizers such as DOMPurify; works with React code that mixes in vanilla DOM manipulation.
- Pros: very focused, so false positives are low; catches the most common XSS pattern in frontend code; maintained by Mozilla.
- Cons: only two rules, so coverage is narrow; not useful for backend Node.js code; caught only 2 of 40 vulnerable patterns in the 2026 benchmark, because its scope is deliberately small.
Pricing: free and open source, published on npm.
Who should pick it: any frontend team, alongside React's built-in react/no-danger rule for dangerouslySetInnerHTML and react/jsx-no-target-blank for missing rel attributes on links.
3. eslint-plugin-security-node — best for server-side Node.js
eslint-plugin-security-node is a newer plugin focused specifically on Node.js server-side security patterns, with 22 rules covering areas the older security plugin misses.
- Key features: 22 rules for server-side patterns; covers unsafe redirects, weak cryptography choices, and dangerous file and process handling.
- Pros: more modern rule set than eslint-plugin-security; works with ESLint 9; caught 7 of 40 vulnerable patterns in the 2026 benchmark.
- Cons: smaller community and fewer downloads than the older plugin; still cannot trace data flow across files.
Pricing: free and open source, published on npm.
Who should pick it: Node.js teams that want a second layer of server-side rules alongside eslint-plugin-security.
4. Microsoft SDL — best for web security rules
Microsoft SDL is the ESLint plugin for Microsoft's Security Development Lifecycle. It ships 17 rules for web code, covering unsafe HTML handling, weak random numbers, and dangerous API use.
- Key features: 17 SDL rules; covers insecure randomness, unsafe HTML and script handling, and risky API patterns; integrates with Microsoft's SDL guidance.
- Pros: highest precision in the 2026 benchmark at about 80 percent, with only one false positive; backed by Microsoft's SDL process.
- Cons: low recall — it caught only 4 of 40 vulnerable patterns, because its rule set is small and focused.
Pricing: free and open source, published on npm as @microsoft/eslint-plugin-sdl.
Who should pick it: teams that follow Microsoft's SDL, or teams that want a small, high-precision rule set with few false alarms.
5. eslint-plugin-no-secrets — best for leaked credentials
eslint-plugin-no-secrets detects potential secrets and credentials hardcoded in source code, such as API keys, tokens and passwords, by checking for high-entropy strings.
- Key features: entropy-based secret detection; configurable allowlists for test data and placeholders; works in pre-commit hooks and CI.
- Pros: catches a mistake that no other plugin in this list covers well; cheap to run; prevents secrets reaching version control.
- Cons: entropy checks can flag random-looking but harmless strings; needs tuning for each codebase.
Pricing: free and open source, published on npm.
Who should pick it: every team, because a leaked API key in git history is hard to fully revoke. Pair it with secret scanning in your repository host.
6. eslint-plugin-sonarjs — best for bug and security hotspots
eslint-plugin-sonarjs brings Sonar's rules to ESLint, with 269 rules covering bugs, code smells and security hotspots. It is the broadest plugin in this list, and the best-performing competitor in the 2026 benchmark.
- Key features: 269 rules; covers bugs, vulnerabilities and code smells; security hotspot rules for code that needs human review.
- Pros: broadest coverage of any established plugin; caught 10 of 40 vulnerable patterns in the benchmark, with 73.7 percent precision; works with ESLint 9.
- Cons: 269 rules is a lot to tune; still caught 0 of 6 SQL injection cases; many rules are about code quality, not security.
Pricing: free and open source, published on npm.
Who should pick it: teams that want one broad plugin for bugs and security together, and are willing to tune a large rule set.
7. eslint-plugin-unicorn — best for safer modern JavaScript
eslint-plugin-unicorn is not a security plugin, but it is the second-best performer in the 2026 benchmark, catching 22 of 40 vulnerable patterns with 144 rules for modern, safe JavaScript.
- Key features: 144 rules; prefers safe modern APIs; flags error handling, type coercion and unsafe patterns that often hide bugs.
- Pros: catches more vulnerable patterns than any dedicated security plugin except the benchmark author's own set; improves code quality at the same time.
- Cons: high false positive count — 23 false alarms in the benchmark; opinionated rules can annoy developers; not a substitute for a security plugin.
Pricing: free and open source, published on npm.
Who should pick it: teams already using Unicorn for code quality, who get security coverage as a side benefit. Use it alongside eslint-plugin-security, not instead of it.
How do you configure security plugins without drowning in warnings?
The biggest mistake teams make is enabling every security rule at maximum severity and then reverting when the build breaks. Roll rules out in phases instead, as Safeguard's ESLint security rules guide recommends.
Phase 1 is error on the obvious: eval detection, innerHTML assignment, and hardcoded credentials. Set these to error so they block the build, because their false positive rate is low.
Phase 2 is warn but do not block: timing attacks, non-literal regular expressions, and broader SonarJS or Unicorn rules. Let developers see these warnings for a few weeks, fix the real ones, and disable the rules that only produce noise.
Phase 3 is CI enforcement: once the warning count is low and stable, promote the rules that proved useful to error. Also pin plugin versions, because eslint-plugin-security version 2.1.1 crashes on ESLint 9, while version 4 fixes the crash.
A sample flat config starts with the security and no-unsanitized plugins, sets detect-eval-with-expression, detect-non-literal-require, no-unsanitized/method and no-unsanitized/property to error, and sets detect-possible-timing-attacks to warn. Adjust from there based on what your codebase actually triggers.
What are the limits of ESLint security plugins?
ESLint is a static analysis tool that operates on abstract syntax tree patterns in single files. It cannot track data flow across function boundaries, understand runtime behavior, or reason about complex control flow. It catches patterns, not vulnerabilities.
The 2026 benchmark makes this concrete. eslint-plugin-security caught 11 of 40 vulnerable patterns, SonarJS caught 10, and the median plugin caught under 10 percent. No established plugin caught all six SQL injection cases, because SQL injection needs data flow analysis across files, according to the benchmark of 17 ESLint security plugins.
That does not make the plugins useless. They catch real problems fast, in the editor, before code reaches CI. But they are one layer, not a security program. Pair them with npm audit for dependencies, a SAST tool such as Semgrep or Snyk Code for data flow, and dynamic testing for runtime behavior.
Also check your deployed site after you ship. Our free security headers checker verifies the headers your app actually sends, which no linter can see.
What should you avoid?
Avoid enabling every rule at once, pinning an old major version, and treating a clean lint run as proof your code is secure. Each of these is a common trap.
- Do not enable detect-object-injection blindly. It flags any bracket notation property access, which is most of JavaScript, and teams quickly learn to ignore it.
- Do not stay on eslint-plugin-security 2.1.1. It crashes on ESLint 9 flat config. Upgrade to version 4 or later.
- Do not assume a passing lint means no vulnerabilities. ESLint cannot see SQL injection, business logic flaws or vulnerable dependencies.
- Do not skip npm audit. Your own code may be clean while a dependency carries a known vulnerability.
- Do not ignore warnings for months. A warning backlog trains developers to ignore the linter entirely.
For a wider check on your web app, see our small business cybersecurity checklist and the website security platform overview.
The bottom line
Start with eslint-plugin-security and eslint-plugin-no-unsanitized, add eslint-plugin-no-secrets to catch leaked credentials, and consider SonarJS or Unicorn for broader coverage. Roll rules out in phases and pin your versions.
Remember the limit: ESLint catches unsafe patterns while you code, but it cannot trace data across files. Pair it with a real SAST scanner and dependency checks. You can verify your deployed headers with the free security headers checker.
Frequently asked questions
What is an ESLint security plugin?
An ESLint security plugin is an add-on that gives ESLint extra rules for unsafe code patterns, such as eval, unsanitized innerHTML, hardcoded secrets and unsafe regular expressions. It reports problems as you write code or in continuous integration.
Which ESLint security plugin should I install first?
Install eslint-plugin-security for Node.js projects and eslint-plugin-no-unsanitized for browser code. Together they cover eval, dynamic require, unsafe regular expressions and dangerous DOM sinks, which are the most common patterns in JavaScript.
Can ESLint find SQL injection?
Usually not. ESLint works on single files and cannot trace tainted data from an API endpoint through middleware into a database query. Independent benchmarks found that eslint-plugin-security caught none of six SQL injection cases, so use a dedicated scanner for that.
Does eslint-plugin-security work with ESLint 9?
Version 2.1.1 crashes on ESLint 9 flat config. Use version 4 or later, which fixes the crash, and pin the version in your package file so every developer and your CI server use the same release.
Are ESLint security plugins free?
Yes. Every plugin in this list is free and open source, published on npm under permissive licenses. You pay nothing, though you will spend some time tuning rules to reduce false positives.
How do I stop security lint rules from annoying developers?
Roll them out in phases. Set the highest-confidence rules to error so they block the build, set noisier rules to warn, and disable rules with high false positive rates for your codebase. A warning developers ignore is worse than no warning at all.
What is the difference between ESLint and a SAST tool?
ESLint is a linter that checks code patterns in single files. A SAST tool such as Semgrep or Snyk Code traces data flow across files and finds real vulnerabilities. Use ESLint for fast feedback while coding and SAST for deeper analysis in CI.
Do I still need npm audit if I use ESLint security plugins?
Yes. ESLint checks your own code, while npm audit checks your dependencies for known vulnerabilities. They cover different risks, so run both, plus Dependabot or a similar tool for continuous dependency monitoring.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the ESLint security plugin guides from Safeguard and Vibe Eval, MegaLinter documentation, and an independent 2026 benchmark of 17 plugins.
How we write and fact-check →