# extensions

Rule `import/extensions`. Ensure consistent use of file extension within the import path.

- Source: import
- Technologies: Imports
- Kind: correctness
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 11.8M weekly downloads of presets that enable it
- Trend: +2.0% last quarter
- Rank: #851 by reach, #1618 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `import/extensions` | no | no | package `eslint-plugin-import` | [docs](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/extensions.md) |
| Oxlint | `import/extensions` | no | no | plugin `import`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/import/extensions.html) |
| Biome | `correctness/useImportExtensions` | no | safe | group correctness, since 1.8.0 | [docs](https://biomejs.dev/linter/rules/use-import-extensions/) |

## Code examples

### Incorrect: the rule reports this

```js
import foo from './foo.js';

import bar from './bar.json';

import Component from './Component.jsx';

import express from 'express/index.js';
```

```js
import type { Foo } from './foo.ts';

export type { Foo } from './foo.ts';
```

```js
import foo from './foo';

import bar from './bar';

import Component from './Component';

import foo from '@/foo';
```

### Correct: the rule accepts this

```js
import foo from './foo';

import bar from './bar';

import Component from './Component';

import express from 'express/index';

import * as path from 'path';
```

```js
import foo from './foo.js';

import bar from './bar.json';

import Component from './Component.jsx';

import * as path from 'path';

import foo from '@/foo.js';
```

```js
import foo from './foo.js';

import bar from './bar.json';

import Component from './Component.jsx';

import express from 'express';

import foo from '@/foo'
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { import: importPlugin },
    rules: {
      "import/extensions": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "import"
  ],
  "rules": {
    "import/extensions": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "useImportExtensions": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [Airbnb TypeScript](https://lintradar.dev/presets/airbnb-typescript.md) | ESLint | `eslint-config-airbnb-typescript` | 19 | 1.8M | +1.2% |

## Related rules

- [import/no-useless-path-segments](https://lintradar.dev/rules/import/no-useless-path-segments.md): Forbid unnecessary path segments in import and require statements.
- [import/order](https://lintradar.dev/rules/import/order.md): Enforce a convention in module import order.
- [import/no-self-import](https://lintradar.dev/rules/import/no-self-import.md): Forbid a module from importing itself.
- [import/no-cycle](https://lintradar.dev/rules/import/no-cycle.md): Forbid a module from importing a module with a dependency path back to itself.
- [import/newline-after-import](https://lintradar.dev/rules/import/newline-after-import.md): Enforce a newline after import statements.
- [import/no-extraneous-dependencies](https://lintradar.dev/rules/import/no-extraneous-dependencies.md): Forbid the use of extraneous packages.

---

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