> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# prefer-promises/dns

[Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, nodePlugin } from '@rslint/core';

export default defineConfig([
  nodePlugin.configs.recommended,
  {
    rules: {
      'node/prefer-promises/dns': 'error',
    },
  },
]);
```

Prefer the promise API of Node.js's `dns` module.

## Rule Details

This rule reports calls to the callback DNS API and construction of `dns.Resolver`.
It follows CommonJS imports, ES module imports, `process.getBuiltinModule`, and
local aliases, including the `node:dns` module name.

Examples of **incorrect** code for this rule:

```javascript
const dns = require('node:dns');
dns.lookup(hostname, (error, address, family) => {});
new dns.Resolver();
```

Examples of **correct** code for this rule:

```javascript
const { promises: dns } = require('node:dns');
const { address, family } = await dns.lookup(hostname);
new dns.Resolver();
```

```javascript
import dns from 'node:dns/promises';
const addresses = await dns.resolve4(hostname);
```

The rule also reports `getServers()` and `setServers()` on the callback module,
matching upstream behavior. Reading a method without calling it is allowed.

## Options

This rule has no options and does not provide automatic fixes or suggestions.

## Original Documentation

- [eslint-plugin-n: prefer-promises/dns](https://github.com/eslint-community/eslint-plugin-n/blob/v18.3.0/docs/rules/prefer-promises/dns.md)
- [Source code](https://github.com/eslint-community/eslint-plugin-n/blob/v18.3.0/lib/rules/prefer-promises/dns.js)
