Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/long-olives-give.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions generate-changeset.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
5 changes: 0 additions & 5 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down