Skip to content

fix(prefer-promises/fs): add missing fs.promises APIs (cp, glob, lutimes, opendir, rm, statfs) - #522

Merged
aladdin-add merged 1 commit into
eslint-community:masterfrom
terminalchai:fix/prefer-promises-fs-missing-apis
May 2, 2026
Merged

fix(prefer-promises/fs): add missing fs.promises APIs (cp, glob, lutimes, opendir, rm, statfs)#522
aladdin-add merged 1 commit into
eslint-community:masterfrom
terminalchai:fix/prefer-promises-fs-missing-apis

Conversation

@terminalchai

Copy link
Copy Markdown

Problem

The prefer-promises/fs rule's traceMap only covers a subset of fs callback-style methods, missing several that have had promise equivalents in Node.js for years:

Method fs.promises available since
cp Node 16.7
glob Node 22
lutimes Node 14.14
opendir Node 12.12
rm Node 14.14
statfs Node 19.6 / 21.2

Using any of these callback-style while writing otherwise promise-based code goes silently undetected by the rule, defeating its purpose.

Fix

Add the six missing methods to traceMap.fs (and, by extension, traceMap["node:fs"] which is aliased from it):

cp:      { [CALL]: true },
glob:    { [CALL]: true },
lutimes: { [CALL]: true },
opendir: { [CALL]: true },
rm:      { [CALL]: true },
statfs:  { [CALL]: true },

Tests

Added an invalid-code test case for each of the six new methods, verifying that the rule reports preferPromises for fs.cp(), fs.glob(), fs.lutimes(), fs.opendir(), fs.rm(), and fs.statfs().

@aladdin-add aladdin-add left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@aladdin-add
aladdin-add merged commit 2de9f06 into eslint-community:master May 2, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants