# prefer-promises/fs

Rule `node/prefer-promises/fs`. Enforce `require("fs").promises`

- Source: node
- Technologies: Node.js
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1995 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `n/prefer-promises/fs` | no | no | package `eslint-plugin-n` | [docs](https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/fs.md) |

## Code examples

### Incorrect: the rule reports this

```js
const fs = require("fs")

function readData(filePath) {
    fs.readFile(filePath, "utf8", (error, content) => {
        //...
    })
}
```

```js
import fs from "fs"

function readData(filePath) {
    fs.readFile(filePath, "utf8", (error, content) => {
        //...
    })
}
```

### Correct: the rule accepts this

```js
const { promises: fs } = require("fs")

async function readData(filePath) {
    const content = await fs.readFile(filePath, "utf8")
    //...
}
```

```js
import { promises as fs } from "fs"

async function readData(filePath) {
    const content = await fs.readFile(filePath, "utf8")
    //...
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import n from "eslint-plugin-n";

export default [
  {
    plugins: { n },
    rules: {
      "n/prefer-promises/fs": "error",
    },
  },
];
```

## Related rules

- [node/prefer-promises/dns](https://lintradar.dev/rules/node/prefer-promises/dns.md): Enforce `require("dns").promises`
- [node/require-child-process-timeout](https://lintradar.dev/rules/node/require-child-process-timeout.md): Require a timeout or signal for child processes
- [node/prefer-import/assert-strict](https://lintradar.dev/rules/node/prefer-import/assert-strict.md): Enforce using `node:assert/strict` instead of `node:assert`.
- [node/prefer-global/url-search-params](https://lintradar.dev/rules/node/prefer-global/url-search-params.md): Enforce either `URLSearchParams` or `require("url").URLSearchParams`
- [node/prefer-global/url](https://lintradar.dev/rules/node/prefer-global/url.md): Enforce either `URL` or `require("url").URL`
- [node/prefer-global/timers](https://lintradar.dev/rules/node/prefer-global/timers.md): Enforce either global timer functions or `require("timers")`

---

Web page: https://lintradar.dev/rules/node/prefer-promises/fs. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
