π Prefer using the node: protocol when importing Node.js builtin modules.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
When getting builtin modules, it's better to use the node: protocol as it makes it perfectly clear that the package is a Node.js builtin module.
// β
import dgram from 'dgram';
// β
import dgram from 'node:dgram';// β
export {strict as default} from 'assert';
// β
export {strict as default} from 'node:assert';// β
import fs from 'fs/promises';
// β
import fs from 'node:fs/promises';// β
const fs = require('fs/promises');
// β
const fs = require('node:fs/promises');// β
const fs = process.getBuiltinModule('fs/promises');
// β
const fs = process.getBuiltinModule('node:fs/promises');// β
type Fs = import('fs');
// β
type Fs = import('node:fs');