Join our Newsletter — 33% off our NHI Course
Home› Guides› ESLint Security Plugins Guide: Linting JavaScript and TypeScript…
Guide Application Security

ESLint Security Plugins Guide: Linting JavaScript and TypeScript for Risky Patterns

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 10 min read
On this page

Most JavaScript and TypeScript teams already run ESLint on every save and every pull request, yet few configure it to flag the code patterns that lead to injection and DOM XSS. Linting is the cheapest security check you can add: it runs in milliseconds, in the editor, before code review. This guide covers the security-relevant core rules, the main open source security plugins and their maintenance status as shown in their repositories, a working flat config, and how to run and triage the results in the IDE and CI. It also sets out what linting cannot find, so you can place it correctly next to SAST and dependency scanning. It is written for JavaScript and TypeScript developers and the application security engineers who support them.

Plugins are listed alphabetically by package name; order is never a ranking. Maintenance status was checked on the projects' repository pages in November 2026 and changes over time.

Key takeaways

  • Turn on the core rules first. no-eval, no-implied-eval and no-new-func cost nothing, have almost no false positives and block code-from-string patterns behind eval injection (CWE-95).
  • Add plugins for your framework and runtime. DOM sink rules for browser code, React rules for JSX, Node rules for server code, and type-aware rules for TypeScript.
  • Lint is pattern matching on one file. It sees risky calls, not data flow, so it cannot tell you whether user input reaches them. That is SAST's job.
  • Make CI the gate, the IDE the coach. Run the same config in both, fail the build on errors, and stop developers silencing rules with inline comments unreviewed.
  • Check plugin maintenance before you depend on one. One plugin covered here has been archived by its owner; a lint plugin is also a dependency that runs in your build.

What linting can and cannot find

ESLint parses each file into a syntax tree and runs rules over it. A security rule matches a shape: a call to eval, an assignment to innerHTML, a require() with a variable argument. That makes lint fast and precise about where a risky construct is, but blind to whether it is exploitable.

QuestionESLint security rulesSAST (taint analysis)Dependency scanning (SCA)
Is a dangerous API used?Yes, per file, at edit timeYesNo
Does untrusted input reach it?NoYes, across files and functionsNo
Is a library version vulnerable?NoSometimesYes
Is authorisation logic correct?NoRarelyNo
Feedback timeSeconds, in the editorMinutes, usually in CIMinutes, in CI or registry

Use lint to stop known-dangerous constructs being introduced, SAST to find exploitable flows (see the CodeQL Guide and Semgrep Guide), and SCA for the dependency tree (see the Software Composition Analysis (SCA) Guide). Business logic and access control flaws need code review and testing.

Security-relevant core rules

These ship with ESLint itself, need no plugin and rarely produce noise in modern code.

RuleWhat it flagsNotes
no-evalCalls to eval(), including indirect forms such as (0, eval)(...), aliasing eval to a variable, and window.eval or global.evalOption allowIndirect defaults to false; leave it false. Cannot see renamed globals such as const foo = window; foo.eval()
no-implied-evalsetTimeout(), setInterval() and execScript() with a string first argument, including window. formsPassing a function is correct. For TypeScript use the type-aware version (below)
no-new-funcnew Function(...), Function(...) and Function.call, .apply and .bindESLint notes the engine parses the string much as it would with eval, and CSP may block it anyway

For TypeScript, typescript-eslint provides @typescript-eslint/no-implied-eval, which uses type information to identify eval-like functions, adds setImmediate() and new Function(), and is part of the recommended-type-checked config. Its documentation says to turn the core no-implied-eval off when you enable it, because the base rule can report incorrect errors.

Security plugins overview

PackageFocusExample rulesRepository status (Nov 2026)
eslint-plugin-no-unsanitized (Mozilla)DOM XSS sinks in browser codemethod (e.g. insertAdjacentHTML(), document.write()), property (e.g. innerHTML)Active repository; flat config and configs.recommended documented
eslint-plugin-react (jsx-eslint)React and JSXno-danger, no-danger-with-children, jsx-no-script-url, jsx-no-target-blank, iframe-missing-sandboxActive repository; flat configs flat.recommended, flat.all, flat['jsx-runtime']
@microsoft/eslint-plugin-sdl (Microsoft)Baseline for projects following the Microsoft SDL; browser, Node, Angular, Electron, Reactno-inner-html, no-document-write, no-postmessage-star-origin, no-insecure-url, no-electron-node-integrationArchived by the owner on 13 August 2026 and read-only; README states it is no longer actively maintained
eslint-plugin-security (eslint-community)Node.js security hotspotsdetect-child-process, detect-non-literal-fs-filename, detect-unsafe-regex, detect-object-injection, detect-bidi-charactersActive repository; flat config configs.recommended (ESLint 8.23.0 or later)
typescript-eslintType-aware TypeScript rules@typescript-eslint/no-implied-evalActive project; type-checked configs need type information

eslint-plugin-no-unsanitized

Two rules: method disallows calls such as document.write() and insertAdjacentHTML(), and property disallows assignments such as innerHTML. Calls to .setHTML() are allowed by default, and the escaping functions Sanitizer.escapeHTML and escapeHTML are accepted when called with a template string. Pair it with the Trusted Types and DOM XSS Prevention Guide.

eslint-plugin-react

Security-relevant rules are mostly outside the recommended config: no-danger (dangerous JSX properties such as dangerouslySetInnerHTML), jsx-no-script-url (javascript: URLs) and iframe-missing-sandbox must be enabled explicitly. no-danger-with-children and jsx-no-target-blank are in recommended. The shareable configs do not set files or globals, so add those yourself.

@microsoft/eslint-plugin-sdl

Provides configs named angular, angularjs, common, electron, node, react, recommended, required and typescript, and reuses rules from ESLint core, eslint-plugin-react, typescript-eslint, eslint-plugin-security and the node plugin alongside its own 15 @microsoft/sdl/ rules. Because the repository is archived, teams already using it can treat its rule list as a reference and enable the equivalent core and plugin rules directly.

eslint-plugin-security

Fourteen rules, all in recommended, aimed at Node.js hotspots: child process use, non-literal file paths, require() and regular expressions, unsafe regexes (see the Regular Expression Denial of Service (ReDoS) Guide), possible timing attacks and bidirectional Unicode characters. The README warns that it produces many false positives that need human triage, so treat findings as review prompts, especially detect-object-injection (see the Prototype Pollution Guide).

typescript-eslint

Supplies the parser and rules for TypeScript. Its type-checked configs, including @typescript-eslint/no-implied-eval, need type information, which makes linting slower; run them in CI even if the editor uses a lighter config.

Configuring flat config for security

ESLint's current configuration format is the flat config: an eslint.config.js (or .mjs, .cjs, .ts, .mts, .cts) in the project root exporting an array of config objects. Objects that match a file merge in order, with later objects overriding earlier ones. By default ESLint lints only **/*.js, **/*.cjs and **/*.mjs, so TypeScript and JSX need explicit files patterns. A minimal security layer for a browser and Node codebase:

1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.

Sample 1
import { defineConfig, globalIgnores } from "eslint/config";
import nounsanitized from "eslint-plugin-no-unsanitized";
import pluginSecurity from "eslint-plugin-security";

export default defineConfig([
  globalIgnores(["dist/**", "coverage/**"]),
  {
    name: "security/core",
    files: ["**/*.{js,mjs,cjs,ts,tsx}"],
    linterOptions: {
      noInlineConfig: false,
      reportUnusedDisableDirectives: "error"
    },
    rules: {
      "no-eval": "error",
      "no-implied-eval": "error",
      "no-new-func": "error"
    }
  },
  {
    name: "security/browser",
    files: ["src/client/**/*.{js,ts,tsx}"],
    plugins: { nounsanitized },
    rules: {
      "nounsanitized/method": "error",
      "nounsanitized/property": "error"
    }
  },
  {
    name: "security/server",
    files: ["src/server/**/*.{js,ts}"],
    extends: [pluginSecurity.configs.recommended]
  }
]);
  • Scope by directory: apply DOM rules to browser code and Node rules to server code, so each team sees relevant findings only.
  • TypeScript: add the typescript-eslint parser and, for type-aware rules, turn off no-implied-eval and enable @typescript-eslint/no-implied-eval in the TypeScript block.
  • Unused disables: reportUnusedDisableDirectives flags stale eslint-disable comments so suppressions do not outlive the code they covered.
  • Inline config: setting noInlineConfig: true (or the --no-inline-config flag) stops comments from changing rules. It is strict; many teams instead require a justification and code owner review for any disable comment touching a security rule.
  • Shared config: publish the security block as an internal shareable config so every repository inherits the same baseline through extends.

Running in IDE and CI

  1. Baseline: run the new rules as warn across the codebase and export results with --format json --output-file. Count findings per rule.
  2. Fix the cheap ones: core eval rules usually have few hits; fix them and promote to error straight away.
  3. Gate new code: in CI, fail on errors (exit code 1) and use --max-warnings with the current count so warnings cannot grow. Exit code 2 means a configuration or internal error; treat it as a failed build, not a pass.
  4. Editor: use the same eslint.config.js in the editor extension so developers see findings before commit; optionally add a pre-commit hook (see the Git Hooks and Pre-commit Security Guide).
  5. Cache carefully: --cache speeds up local runs, but ESLint warns it does not track dependencies between files, so type-aware results can be stale. Run CI without a stale cache.
  6. Roll back: if a rule floods a team, demote it to warn for that directory in config rather than removing it, and record a date to revisit.

Lint plugins run inside your build with whatever credentials CI has. Pin versions with a lockfile and review plugin updates like any dependency: the eslint-scope npm compromise in 2018 showed a malicious version of a widely used ESLint dependency stealing npm tokens through an install script. See the npm Install-Time Security Guide.

Triage and false positives

Finding typeTypical causeTriage action
eval, implied eval, new FunctionLegacy templating, dynamic code loading, string timersRefactor: pass functions, use JSON.parse, use a lookup table
DOM sink (innerHTML, insertAdjacentHTML, document.write)Rendering HTML stringsUse textContent, a framework binding or a vetted sanitiser; confirm the input source
Non-literal fs path, require or RegExpConfig-driven paths, plugin loadersCheck whether the value can come from a request; constrain to an allowlist or a fixed base directory
Object injection (obj[key])Any bracket access with a variableHigh noise; check only where the key comes from user input, then use Map or a key allowlist
dangerouslySetInnerHTMLRich text renderingRequire sanitisation and a justification comment reviewed by a code owner
  • Suppress narrowly: use // eslint-disable-next-line rule-name -- reason for one line and one rule, never a file-wide disable without a rule name.
  • Measure: track security rule errors on the main branch (target zero), count of security-rule disable comments and their trend, percentage of repositories on the shared security config, and time from finding to fix.
  • Feed SAST: when a lint finding turns out to be exploitable, write or enable a SAST rule for the data flow so it is caught across the codebase. See the SAST Triage Guide.
FrameworkReferenceRelevance
NIST SP 800-53 Rev 5SA-11 Developer Testing and Evaluation; SA-11(1) Static Code Analysis; SA-15 Development Process, Standards, and ToolsLint in the editor and CI is a form of static code analysis with defined tooling
NIST CSF 2.0PR.PS-06Secure development practices integrated into the life cycle
MITRE CWECWE-95 Improper Neutralization of Directives in Dynamically Evaluated Code; CWE-79 Cross-site ScriptingWeaknesses targeted by eval and DOM sink rules
ISO/IEC 27001:2022Annex A 8.28 Secure codingTool-enforced coding rules as evidence of secure coding practice

Practitioner checklist

  • Enable no-eval, no-implied-eval and no-new-func as errors in every JavaScript and TypeScript repository.
  • Use @typescript-eslint/no-implied-eval with the core rule off in type-checked TypeScript projects.
  • Add DOM sink rules for browser code and React security rules (including the ones outside recommended) for JSX.
  • Add Node.js hotspot rules for server code and plan for human triage of their findings.
  • Check each plugin's repository for archive status and recent activity before adopting it, and re-check yearly.
  • Scope rules with files patterns and publish one shared security config.
  • Fail CI on errors and on exit code 2; cap warnings with --max-warnings.
  • Report unused disable directives and require a reason on every security rule suppression.
  • Pin lint plugins in the lockfile and review their updates as dependencies.
  • Run SAST and dependency scanning alongside lint; do not treat a clean lint run as a security sign-off.

Standards and references

Related NHI Mgmt Group resources: TypeScript and JavaScript Secure Coding Guide, Cross-Site Scripting (XSS) Prevention Guide, Node.js Security Guide, SAST vs SCA.

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.