Getting Started
Install the plugin:
npm install --save-dev eslint-plugin-sdl-2
Enable one preset in your Flat Config:
import sdl from "eslint-plugin-sdl-2";
export default [...sdl.configs.recommended];
Layering presetsâ
recommended already includes:
- browser/security baseline (
common) - framework/runtime overlays (
angular,angularjs,electron,node) - TypeScript parser integration (
typescript)
Alternative: manual scoped setupâ
If you prefer to apply plugin rules inside your own file-scoped config object, spread the preset rules manually.
import sdl from "eslint-plugin-sdl-2";
export default [
...sdl.configs.typescript,
{
files: ["**/*.{ts,tsx,mts,cts}"],
plugins: {
sdl,
},
rules: {
"sdl/no-insecure-random": "error",
"sdl/no-insecure-url": "error",
},
},
];
Use this pattern only when you need strict per-glob control. In most projects,
prefer ...sdl.configs.<preset> directly.
Recommended rolloutâ
- Start with
...sdl.configs.recommended. - Fix violations in small batches.
- Add framework/runtime presets (
angular,react,electron, etc.) as needed. - Keep
typescriptenabled for TS projects.
Need a narrower subset?â
- Use
...sdl.configs.commonfor browser-centric checks. - Use
...sdl.configs.nodefor Node-specific checks. - Use
...sdl.configs.angular/...sdl.configs.angularjsfor framework overlays.
See Presets for full examples and rules per preset.