Web rules
disabled-resource-integrity
Section titled “disabled-resource-integrity”Finds <script> elements that document.createElement makes and that load a versioned file from another host without an integrity hash and crossOrigin = "anonymous".
On in the recommended and all configs. It reports nothing without the type information of a TypeScript project.
Without a subresource integrity check, the page runs whatever script the other host serves, also after an attacker changes it.
What to do
Section titled “What to do”Set integrity to the hash of the expected file and crossOrigin to "anonymous".
Example
Section titled “Example”The code const script = document.createElement("script"); script.src = "https://cdn.example.com/lib@1.2.3/lib.js"; reports missingBoth. Add script.integrity = "sha384-..." and script.crossOrigin = "anonymous".
dompurify-unsafe-config
Section titled “dompurify-unsafe-config”Finds DOMPurify.sanitize configurations that let dangerous markup through, such as script in ADD_TAGS, an event handler attribute in ADD_ATTR, or ALLOW_UNKNOWN_PROTOCOLS set to true.
On in the recommended and all configs.
These options let script and event handler markup through the sanitizer, so an attacker can inject code into the page.
What to do
Section titled “What to do”Keep the default configuration, or allow only harmless tags and attributes.
Example
Section titled “Example”The call DOMPurify.sanitize(html, { ADD_TAGS: ["iframe"] }) reports unsafe. Use DOMPurify.sanitize(html).
no-any-origin-messages
Section titled “no-any-origin-messages”Finds postMessage calls on a window with the target origin *, and message listeners on a window that never compare event.origin in an if statement.
On in the recommended and all configs. It reports nothing without the type information of a TypeScript project.
A message sent to * reaches any page that the window shows, and a listener that does not check the origin accepts messages from any site.
What to do
Section titled “What to do”Pass the exact origin of the receiver to postMessage, and return early in the listener when event.origin is not a trusted origin.
Example
Section titled “Example”The call frame.contentWindow.postMessage(data, "*") reports anyTarget. Use frame.contentWindow.postMessage(data, "https://app.example.com").
no-client-environment
Section titled “no-client-environment”Finds private environment reads in client modules, such as process.env.SECRET_KEY, Bun.env, Deno.env.get, and import.meta.env. The publicPrefixes and allowedNames options name the public values.
On in the recommended and all configs.
Client code needs public configuration. Private environment values are unavailable in the browser by default, and exposing a secret to satisfy the read is unsafe.
What to do
Section titled “What to do”Keep private configuration and the work that needs it in a server-only module. Pass only public results to client code, or use NEXT_PUBLIC_ variables for values intended for the browser.
Example
Section titled “Example”In a module beginning with "use client", const key = process.env.SECRET; reports private. Move the secret read and the work that needs it to a server module. A genuinely public URL can use process.env.NEXT_PUBLIC_URL in the client. Never rename a secret to make it public. See Next.js environment variables.
Options
Section titled “Options”| Option | Type | Default | What it does |
|---|---|---|---|
client |
true or false |
false |
Treat selected files as client code without a use-client directive. |
publicPrefixes |
List | ["NEXT_PUBLIC_"] |
Prefixes allowed for public environment variables. |
allowedNames |
List | ["NODE_ENV"] |
Environment variable names allowed in client code. |
no-unsafe-sanitizer-bypass
Section titled “no-unsafe-sanitizer-bypass”Reports Angular sanitizer bypass calls whose value is not a known literal.
On in the recommended and all configs.
Bypassing sanitization lets untrusted HTML, scripts, styles, or URLs reach the browser.
What to do
Section titled “What to do”Keep Angular sanitization enabled for dynamic values. Bypass it only for a reviewed literal.
Example
Section titled “Example”Bind a dynamic value through the normal Angular template binding instead of bypassSecurityTrustHtml.
require-noopener
Section titled “require-noopener”Finds window.open and this.window.open calls that open an http or https URL without noopener in the window features.
On in the recommended and all configs.
The opened page gets a reference to the page that opened it, so it can send that page to another address, such as a phishing copy.
What to do
Section titled “What to do”Pass noopener in the window features: window.open(url, "_blank", "noopener").
Example
Section titled “Example”The call window.open("https://example.com", "_blank") reports opener. Use window.open("https://example.com", "_blank", "noopener").
require-server-only
Section titled “require-server-only”Checks that a selected server module imports “server-only” in a form that stays in the built code, or declares “use server”.
No config turns it on; turn it on in your ESLint config.
A server-only marker lets Next.js reject client imports of a module that uses private server capabilities. A marker that the compiler removes protects nothing.
What to do
Section titled “What to do”Add import “server-only” to the imports. Use “use server” only for a module that follows the Server Actions contract. If the file is not server code, remove it from the files this rule selects.
Example
Section titled “Example”A selected server module containing export const secret = 1; reports missing. With the server-only package installed, add import "server-only"; before that declaration. import type {} from "server-only", import {} from "server-only" and an import whose names are all type-only do not count, because TypeScript or Bun drop them from the output.