Files
ai-course/node_modules/eslint-plugin-import/docs/rules/enforce-node-protocol-usage.md
KQL ce6aa207e9 fix: 修复图片路径以适配GitHub Pages base path
- 将所有图片路径从绝对路径改为使用 process.env.PUBLIC_URL
- 修复 HomePage.tsx 中所有图片引用
- 修复 CoursePage.tsx 中所有图片引用
- 确保图片在 GitHub Pages 上正确加载

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 09:24:45 +08:00

2.1 KiB

import/enforce-node-protocol-usage

🔧 This rule is automatically fixable by the --fix CLI option.

Enforce either using, or omitting, the node: protocol when importing Node.js builtin modules.

Rule Details

This rule enforces that builtins node imports are using, or omitting, the node: protocol.

Determining whether a specifier is a core module depends on the node version being used to run eslint. This version can be specified in the configuration with the import/node-version setting.

Reasons to prefer using the protocol include:

  • the code is more explicitly and clearly referencing a Node.js built-in module

Reasons to prefer omitting the protocol include:

  • some tools don't support the node: protocol
  • the code is more portable, because import maps and automatic polyfilling can be used

Options

The rule requires a single string option which may be one of:

  • 'always' - enforces that builtins node imports are using the node: protocol.
  • 'never' - enforces that builtins node imports are not using the node: protocol.

Examples

'always'

Invalid

import fs from 'fs';
export { promises } from 'fs';
// require
const fs = require('fs/promises');

Valid

import fs from 'node:fs';
export { promises } from 'node:fs';
import * as test from 'node:test';
// require
const fs = require('node:fs/promises');

'never'

Invalid

import fs from 'node:fs';
export { promises } from 'node:fs';
// require
const fs = require('node:fs/promises');

Valid

import fs from 'fs';
export { promises } from 'fs';

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

// This rule will not enforce not using `node:` protocol when the module is only available under the `node:` protocol.
import * as test from 'node:test';

When Not To Use It

If you don't want to consistently enforce using, or omitting, the node: protocol when importing Node.js builtin modules.