Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt

Use this file to discover all available pages before exploring further.

Use the node: protocol when importing Node.js built-in modules. The explicit prefix makes it unambiguous that the specifier refers to a Node.js built-in rather than a package from node_modules.
Recommendedrecommended · ☑️ unopinionated
Fixable🔧 Auto-fixable
This rule checks import declarations, export … from re-exports, dynamic import() expressions, require() calls, process.getBuiltinModule() calls, and TypeScript import() types.

Examples

import dgram from 'dgram';

export {strict as default} from 'assert';

import fs from 'fs/promises';

const fs = require('fs/promises');

const fs = process.getBuiltinModule('fs/promises');
// TypeScript import type
// ❌
type Fs = import('fs');

// ✅
type Fs = import('node:fs');
This rule uses a static list of built-in module names (via is-builtin-module) rather than the runtime node:module isBuiltin API. This ensures consistent behavior regardless of which Node.js version runs the linter.

Build docs developers (and LLMs) love