n/prefer-promises/fs
eslint-plugin-n
No autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/prefer-promises/fs": "error",
},
},
];const fs = require("fs")
function readData(filePath) {
fs.readFile(filePath, "utf8", (error, content) => {
//...
})
}import fs from "fs"
function readData(filePath) {
fs.readFile(filePath, "utf8", (error, content) => {
//...
})
}const { promises: fs } = require("fs")
async function readData(filePath) {
const content = await fs.readFile(filePath, "utf8")
//...
}import { promises as fs } from "fs"
async function readData(filePath) {
const content = await fs.readFile(filePath, "utf8")
//...
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
n/prefer-promises/fs
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/prefer-promises/fs": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Require a timeout or signal for child processes
Enforce using node:assert/strict instead of node:assert.
Enforce either URLSearchParams or require("url").URLSearchParams
Enforce either global timer functions or require("timers")