Skip to content

Runtime

The runtime option controls which global variables are available during linting. Picking the wrong runtime leads to false positives for globals that are not available in your actual execution environment.

eslint.config.mjs
import { defineConfig, Runtime } from '@santi020k/eslint-config-basic'
export default await defineConfig({
runtime: Runtime.Node
})
RuntimeEnumUse It When
UniversalRuntime.UniversalFull-stack projects, or when you are unsure — adds both Node.js and browser globals.
BrowserRuntime.BrowserFront-end-only code. Removes Node.js globals to prevent accidental server-side assumptions.
NodeRuntime.NodeBack-end-only code (APIs, CLIs, scripts). Removes browser globals.
WorkerRuntime.WorkerGeneric service workers and edge runtimes — adds Fetch API and worker globals.
CloudflareRuntime.CloudflareCloudflare Workers projects — adds worker globals plus Cloudflare-specific globals such as DurableObject and WebSocketPair.
BunRuntime.BunBun runtime projects.
DenoRuntime.DenoDeno runtime projects.

Adds both Node.js and browser globals. This is the default when no explicit runtime is set and auto-detection cannot determine a clear signal.

Use this when your project is truly full-stack and source files mix server and client code (for example a Remix app with API routes and React components in the same tree).

import { defineConfig, Runtime } from '@santi020k/eslint-config-basic'
export default await defineConfig({
runtime: Runtime.Universal
})

Adds browser globals: window, document, navigator, location, history, localStorage, fetch, XMLHttpRequest, CustomEvent, and the full DOM API surface.

Does not include Node.js-specific globals like process, Buffer, __dirname, or require.

import { defineConfig, Runtime } from '@santi020k/eslint-config-basic'
export default await defineConfig({
frameworks: { vue: true },
runtime: Runtime.Browser
})

[!TIP] Most framework presets (React, Vue, Svelte, Solid, Angular, Astro) automatically narrow to Browser runtime. You usually do not need to set this explicitly for UI projects.

Adds Node.js globals: process, Buffer, __dirname, __filename, require, module, exports, global, setTimeout, setInterval, setImmediate, and clearImmediate.

Does not include browser DOM globals.

import { defineConfig, Runtime } from '@santi020k/eslint-config-basic'
export default await defineConfig({
frameworks: { nest: true },
runtime: Runtime.Node
})

Use Runtime.Node for: Express / Fastify / Hono APIs, NestJS applications, CLI tools and scripts, and Node.js cron jobs.

Adds service worker and Fetch API globals: self, fetch, Request, Response, Headers, URL, URLSearchParams, ReadableStream, WritableStream, TransformStream, caches, crypto, and CryptoKey.

Does not include window (workers have no DOM access) and does not include Node.js-specific globals.

import { defineConfig, Runtime } from '@santi020k/eslint-config-basic'
export default await defineConfig({
frameworks: { hono: true },
runtime: Runtime.Worker
})

Use Runtime.Worker for: generic edge functions, Next.js middleware, and browser service workers.

Adds service worker globals plus Cloudflare Workers-specific globals such as DurableObject, WebSocketPair, and caches.

import { defineConfig, Runtime } from '@santi020k/eslint-config-basic'
export default await defineConfig({
runtime: Runtime.Cloudflare
})

Hono projects with wrangler, @cloudflare/workers-types, or @cloudflare/vitest-pool-workers are detected as Cloudflare automatically. Browser frameworks deployed with Wrangler stay browser-first unless you explicitly choose Runtime.Cloudflare.

Adds Bun, Node, and browser-compatible globals. Detection looks for Bun runtime types or Bun runtime configuration.

Adds Deno and browser-compatible globals. Detection looks for Deno config files or the Deno ESLint plugin.

When no runtime is set explicitly, auto-detection reads package.json and the project file tree for signals:

SignalDetected Runtime
Presence of next, astro, vite, solid-js, svelte, vueBrowser
Presence of @nestjs/coreNode
Presence of Hono plus wrangler, @cloudflare/workers-types, or @cloudflare/vitest-pool-workersCloudflare
Presence of Cloudflare worker signals without a browser frameworkCloudflare
Presence of Bun runtime config/typesBun
Presence of Deno config/plugin signalsDeno
No clear signalUniversal

Detection precedence (highest wins): Cloudflare > Bun/Deno > Worker > Node > Browser > Universal.

Use detection: { runtime: false } to disable runtime auto-detection and rely solely on your explicit runtime option.

Use the projects option to assign different runtimes to different workspace packages:

import { defineConfig, Preset, Runtime } from '@santi020k/eslint-config-basic'
export default await defineConfig({
preset: Preset.Monorepo,
projects: {
'apps/edge-api': { runtime: Runtime.Worker },
'apps/web': { frameworks: { next: true }, runtime: Runtime.Browser },
'packages/cli': { runtime: Runtime.Node },
'packages/sdk': { runtime: Runtime.Universal }
}
})

Did this page help?

One click helps us spot documentation that needs another pass. No personal data is sent.