# no-empty-file

Rule `unicorn/no-empty-file`. Disallow empty files.

- Source: unicorn
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 62.8M weekly downloads of presets that enable it
- Trend: +137.2% last quarter
- Rank: #238 by reach, #81 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-empty-file` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-empty-file.md) |
| Oxlint | `unicorn/no-empty-file` | yes | no | plugin `unicorn`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-empty-file.html) |
| Biome | `suspicious/noEmptySource` | no | no | group suspicious, since 2.2.7 | [docs](https://biomejs.dev/linter/rules/no-empty-source/) |

## Code examples

### Incorrect: the rule reports this

```js
// Comment
```

```js
/* Comment */
```

```js
'use strict';
```

### Correct: the rule accepts this

```js
const x = 0;
```

```js
'use strict';
const x = 0;
```

```js
;;
const x = 0;
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-empty-file": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/no-empty-file": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noEmptySource": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Oxlint default](https://lintradar.dev/presets/oxlint-default.md) | Oxlint | `oxlint` | 111 | 50.8M | +183.6% |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/prefer-string-starts-ends-with](https://lintradar.dev/rules/unicorn/prefer-string-starts-ends-with.md): Prefer `String#startsWith()` & `String#endsWith()` over regexes, `String#indexOf() === 0`, and slice checks.
- [unicorn/no-unnecessary-await](https://lintradar.dev/rules/unicorn/no-unnecessary-await.md): Disallow awaiting non-promise values.
- [unicorn/no-new-array](https://lintradar.dev/rules/unicorn/no-new-array.md): Disallow `new Array()`.
- [unicorn/prefer-set-size](https://lintradar.dev/rules/unicorn/prefer-set-size.md): Prefer using `Set#size` instead of `Array#length`.
- [unicorn/no-useless-spread](https://lintradar.dev/rules/unicorn/no-useless-spread.md): Disallow unnecessary spread.
- [unicorn/no-useless-length-check](https://lintradar.dev/rules/unicorn/no-useless-length-check.md): Disallow useless array length check.

---

Web page: https://lintradar.dev/rules/unicorn/no-empty-file. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
