diff --git a/.changeset/long-olives-give.md b/.changeset/long-olives-give.md new file mode 100644 index 00000000..3787e437 --- /dev/null +++ b/.changeset/long-olives-give.md @@ -0,0 +1,13 @@ +--- +'@cloudfour/eslint-plugin': major +--- + +Enforce using the `node`: protocol for imports to node built-in modules ([`prefer-node-protocol`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/prefer-node-protocol.js)). + +❌ `require('fs')` → ✅ `require('node:fs')` +❌ `import * as fs from 'fs'` → ✅ `import * as fs from 'node:fs'` + +The `import` form is supported in node v14.13.1+. +The `require` form is supported in node v14.18.0+. + +It is auto-fixable. diff --git a/generate-changeset.mjs b/generate-changeset.mjs index 5cd4ded3..9f9a464a 100644 --- a/generate-changeset.mjs +++ b/generate-changeset.mjs @@ -1,8 +1,8 @@ // @ts-check -import { spawn } from 'child_process'; -import { promises as fs } from 'fs'; -import { join } from 'path'; +import { spawn } from 'node:child_process'; +import { promises as fs } from 'node:fs'; +import { join } from 'node:path'; import kleur from 'kleur'; import _writeChangeset from '@changesets/write'; import prompts from 'prompts'; diff --git a/src/config.js b/src/config.js index 77f00613..0db865c9 100644 --- a/src/config.js +++ b/src/config.js @@ -172,11 +172,6 @@ module.exports.configs = { // There isn't a good reason to force use of Number.POSITIVE_INFINITY instead of Infinity { checkInfinity: false }, ], - // The node: protocol for imports is supported for imports starting in node 12 - // and for require()'s starting in node 16. - // Since for most projects, we are transpiling imports to requires, - // This rule is not ready until we only support node 16+ - 'unicorn/prefer-node-protocol': 'off', // This rule suggests incorrect code with the destructured object is modified // That is a fairly common case, and it is too annoying to always disable the rule on each line 'unicorn/consistent-destructuring': 'off',