# noPrivateImports

Rule `biome/noPrivateImports`. Restrict imports of private exports.

- Source: biome
- Technologies: Imports
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 28.5M weekly downloads of presets that enable it
- Trend: +106.8% last quarter
- Rank: #620 by reach, #257 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Biome | `correctness/noPrivateImports` | yes | no | group correctness, since 2.0.0 | [docs](https://biomejs.dev/linter/rules/no-private-imports/) |

## Code examples

### Incorrect: the rule reports this

```js
/**
 * @package
 */
export const fooPackageVariable = 1;
```

```js
// Attempt to import package private variable from `sub/foo.js` from
// outside its `sub` module:
import { fooPackageVariable } from "./sub/foo.js";

/**
 * @private For test purposes only!
 */
export function getTestStuff() {}
```

```js
// Attempt to import a private export. To allow this, you probably want
// to configure an `override` to disable this rule in test files.
// See: https://biomejs.dev/reference/configuration/#overrides
import { getTestStuff } from "./bar.js";
```

### Correct: the rule accepts this

```js
// Package-private exports can be imported from inside the same module.
import { fooPackageVariable } from "./foo.js";

// Resources (anything other than JS/TS files) are always exempt.
import { barResource } from "../resources/bar.png";

/** @private */
export const subPrivateVariable = 2;
```

```js
// Private exports are accessible within the same module only, but
// modules can be nested. So the following works because you can always
// import from the index file of a parent module:
import { subPrivateVariable } from "../index.js";
```

Examples from the Biome documentation.

## Enable it

### Biome: `biome.json`

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

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |

## Related rules

- [biome/noImportantStyles](https://lintradar.dev/rules/biome/noImportantStyles.md): Disallow `!important` declarations.
- [biome/noUndeclaredEnvVars](https://lintradar.dev/rules/biome/noUndeclaredEnvVars.md): Disallow the use of undeclared environment variables.
- [biome/useTanstackQueryStableQueryClient](https://lintradar.dev/rules/biome/useTanstackQueryStableQueryClient.md): Require the TanStack Query `QueryClient` to be created once, not on every render.
- [biome/useTanstackQueryQueryOptions](https://lintradar.dev/rules/biome/useTanstackQueryQueryOptions.md): Require TanStack Query options to be created with `queryOptions()`.
- [biome/useTanstackQueryMutationPropertyOrder](https://lintradar.dev/rules/biome/useTanstackQueryMutationPropertyOrder.md): Enforce that `onMutate` comes before `onError` and `onSettled` in the options of TanStack Query mutations.
- [biome/useTanstackQueryInfiniteQueryPropertyOrder](https://lintradar.dev/rules/biome/useTanstackQueryInfiniteQueryPropertyOrder.md): Enforce a consistent property order in the options of TanStack Query infinite query functions.

---

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