Skip to content

Commit 85de090

Browse files
committed
chore: suppress a Node.js deprecation warning
Follow up nodejs/node#37302. This PR suppress the following Node.js warning. ```console % node -v v18.10.0 % cd path/to/eslint % node Makefile mocha Running unit tests (snip) (node:63796) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead (Use `node --trace-deprecation ...` to show where the warning was created) ``` And added compatibility condition to prevent the following error when using Node.js 13 or lower. ```console % node -v v13.14.0 % npx mocha tests/lib/eslint/flat-eslint.js (snip) 1) FlatESLint lintFiles() multiple processors "after each" hook for "should lint only JavaScript blocks.": TypeError: fsp.rm is not a function ```
1 parent 94ba68d commit 85de090

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/lib/eslint/flat-eslint.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -2607,7 +2607,17 @@ describe("FlatESLint", () => {
26072607
let id;
26082608

26092609
beforeEach(() => (id = Date.now().toString()));
2610-
afterEach(async () => fsp.rmdir(root, { recursive: true, force: true }));
2610+
2611+
/*
2612+
* `fs.rmdir(path, { recursive: true })` is deprecated and will be removed.
2613+
* Use `fs.rm(path, { recursive: true })` instead.
2614+
* When supporting Node.js 14+, the compatibility condition can be removed for `fs.rmdir`.
2615+
*/
2616+
if (typeof fsp.rm === "function") {
2617+
afterEach(async () => fsp.rm(root, { recursive: true, force: true }));
2618+
} else {
2619+
afterEach(async () => fsp.rmdir(root, { recursive: true, force: true }));
2620+
}
26112621

26122622
it("should lint only JavaScript blocks.", async () => {
26132623
const teardown = createCustomTeardown({

0 commit comments

Comments
 (0)