---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: noInvalidPositionAtImportRule
description: Learn more about noInvalidPositionAtImportRule
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="CSS" icon="seti:css">
## Summary
- Rule available since: `v1.8.0`
- Diagnostic Category: [`lint/correctness/noInvalidPositionAtImportRule`](/reference/diagnostics#diagnostic-category)
- This rule is **recommended**, meaning it is enabled by default.
- This rule doesn't have a fix.
- The default severity of this rule is [**error**](/reference/diagnostics#error).
- Sources: 
  - Same as [`no-invalid-position-at-import-rule`](https://github.com/stylelint/stylelint/blob/main/lib/rules/no-invalid-position-at-import-rule/README.md)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"correctness": {
				"noInvalidPositionAtImportRule": "error"
			}
		}
	}
}

```
## Description
Disallow the use of `@import` at-rules in invalid positions.

Any `@import` rules must precede all other valid at-rules and style rules in a stylesheet (ignoring `@charset` and `@layer`), or else the `@import` rule is invalid.

## Examples

### Invalid

```css
a {}
@import 'foo.css';
```

<pre class="language-text"><code class="language-text">code-block.css:2:2 <a href="https://biomejs.dev/linter/rules/no-invalid-position-at-import-rule">lint/correctness/noInvalidPositionAtImportRule</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">This </span><span style="color: Tomato;"><strong>@import</strong></span><span style="color: Tomato;"> is in the wrong position.</span><br />  <br />    <strong>1 │ </strong>a &#123;&#125;<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong>@import 'foo.css';<br />   <strong>   │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>3 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Any </span><span style="color: lightgreen;"><strong>@import</strong></span><span style="color: lightgreen;"> rules must precede all other valid at-rules and style rules in a stylesheet (ignoring @charset and @layer), or else the </span><span style="color: lightgreen;"><strong>@import</strong></span><span style="color: lightgreen;"> rule is invalid.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Consider moving import position.</span><br />  <br /></code></pre>

### Valid

```css
@import 'foo.css';
a {}
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_css_analyze/src/lint/correctness/no_invalid_position_at_import_rule.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_css_analyze/tests/specs/correctness/noInvalidPositionAtImportRule)

</TabItem>
</Tabs>