eslint-plugin-node-import

Disallow imports of built-in Node.js modules without the `node:` prefix

ISC 12 个版本
安装
npm install eslint-plugin-node-import
yarn add eslint-plugin-node-import
pnpm add eslint-plugin-node-import
bun add eslint-plugin-node-import
README

eslint-plugin-node-import

Disallow imports of built-in Node.js modules without the node: prefix

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-node-import:

npm install eslint-plugin-node-import --save-dev

Usage

Flat config (eslint.config.js)

Preset config

Extend this plugin's recommended config:

const nodeImport = require('eslint-plugin-node-import');

module.exports = [
	...nodeImport.configs["flat/recommended"],
	// your config
]

Manual

Add node-import to the plugins section of your configuration and configure the (only) rule under the rules section:

const nodeImport = require('eslint-plugin-node-import');

module.exports = [
	{
		plugins: {"node-import": nodeImport},
		rules: {
			"node-import/prefer-node-protocol": "error"
		}
	}
]

Legacy config (.eslintrc.*)

Preset config

Extend this plugin's recommended config:

{
	"extends": ["plugin:node-import/recommended"]
}

Manual

Add node-import to the plugins section of your .eslintrc configuration file and configure the (only) rule under the rules section:

{
	"plugins": ["node-import"],
	"rules": {
		"node-import/prefer-node-protocol": 2
	}
}

Rules

💼 Configurations enabled in.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.

Name                 Description 💼 🔧
prefer-node-protocol Prefer using the node: protocol when importing Node.js builtin modules. 🔧

Credits

This plugin is a composite of two different custom ESLint rules:

Licence

© 2023 Nikita Karamov
Licensed under the ISC License


This project is hosted on GitHub: https://github.com/kytta/eslint-plugin-node-import.git

版本列表
1.2.0 2026-02-16
1.2.0-pre.2 2026-02-09
1.2.0-pre.1 2026-02-08
1.2.0-pre.0 2026-02-08
1.1.1 2026-02-08
1.1.0 2026-02-08
1.0.5 2025-05-20
1.0.4 2023-09-12
1.0.3 2023-09-08
1.0.2 2023-09-07
1.0.1 2023-09-07
1.0.0 2023-09-07