n/prefer-promises/dns
eslint-plugin-n
No autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/prefer-promises/dns": "error",
},
},
];const dns = require("dns")
function lookup(hostname) {
dns.lookup(hostname, (error, address, family) => {
//...
})
}import dns from "dns"
function lookup(hostname) {
dns.lookup(hostname, (error, address, family) => {
//...
})
}const { promises: dns } = require("dns")
async function lookup(hostname) {
const { address, family } = await dns.lookup(hostname)
//...
}import { promises as dns } from "dns"
async function lookup(hostname) {
const { address, family } = await dns.lookup(hostname)
//...
}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/dns
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/prefer-promises/dns": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Enforce using node:assert/strict instead of node:assert.
Enforce either URLSearchParams or require("url").URLSearchParams
Require a timeout or signal for child processes
Enforce either global timer functions or require("timers")