# no-unassigned-import

Rule `import/no-unassigned-import`. Forbid unassigned imports

- Source: import
- Technologies: Imports
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 413K weekly downloads of presets that enable it
- Trend: −5.0% last quarter
- Rank: #1617 by reach, #1628 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `import/no-unassigned-import` | no | no | package `eslint-plugin-import` | [docs](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-unassigned-import.md) |
| Oxlint | `import/no-unassigned-import` | no | no | plugin `import`, category suspicious | [docs](https://oxc.rs/docs/guide/usage/linter/rules/import/no-unassigned-import.html) |

## Code examples

### Incorrect: the rule reports this

```js
import 'should'
require('should')

// In <PROJECT_ROOT>/src/app.js
import '../styles/app.css'
// {"allow": ["styles/*.css"]}
```

### Correct: the rule accepts this

```js
import _ from 'foo'
import _, {foo} from 'foo'
import _, {foo as bar} from 'foo'
import {foo as bar} from 'foo'
import * as _ from 'foo'

const _ = require('foo')
const {foo} = require('foo')
const {foo: bar} = require('foo')
const [a, b] = require('foo')
const _ = require('foo')

// Module is not assigned, but it is used
bar(require('foo'))
require('foo').bar
require('foo').bar()
require('foo')()

// With allow option set
import './style.css' // {"allow": ["**/*.css"]}
import 'babel-register' // {"allow": ["babel-register"]}

// In <PROJECT_ROOT>/src/app.js
import './styles/app.css'
import '../scripts/register.js'
// {"allow": ["src/styles/**", "**/scripts/*.js"]}
```

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/no-unassigned-import": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "import"
  ],
  "rules": {
    "import/no-unassigned-import": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [import/exports-last](https://lintradar.dev/rules/import/exports-last.md): Ensure all exports appear after other statements.
- [import/no-commonjs](https://lintradar.dev/rules/import/no-commonjs.md): Forbid CommonJS `require` calls and `module.exports` or `exports.*`.
- [import/no-default-export](https://lintradar.dev/rules/import/no-default-export.md): Forbid default exports.
- [import/no-nodejs-modules](https://lintradar.dev/rules/import/no-nodejs-modules.md): Forbid Node.js builtin modules.
- [import/group-exports](https://lintradar.dev/rules/import/group-exports.md): Prefer named exports to be grouped together in a single export declaration
- [import/max-dependencies](https://lintradar.dev/rules/import/max-dependencies.md): Enforce the maximum number of dependencies a module can have.

---

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