Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no-invalid-position-at-import-rule false positives for @layer #6094

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/rules/no-invalid-position-at-import-rule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ a {}
* This @import */
```

Any `@import` rules must precede all other valid at-rules and style rules in a stylesheet (ignoring `@charset`), or else the `@import` rule is invalid.
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.

## Options

Expand Down Expand Up @@ -50,6 +50,12 @@ a {}
@import 'foo.css';
```

<!-- prettier-ignore -->
```css
@layer default;
@import url(theme.css) layer(theme);
```

## Optional secondary options

### `ignoreAtRules: ["/regex/", /regex/, "string"]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ testRule({
`,
description: 'case insensitive',
},
{
code: stripIndent`
@layer default;
@import url(theme.css) layer(theme);
`,
description: '@import after @layer',
},
],

reject: [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-invalid-position-at-import-rule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const rule = (primary, options) => {
(node.type === 'atrule' &&
nodeName !== 'charset' &&
nodeName !== 'import' &&
nodeName !== 'layer' &&
!optionsMatches(options, 'ignoreAtRules', node.name) &&
isStandardSyntaxAtRule(node)) ||
(node.type === 'rule' && isStandardSyntaxRule(node))
Expand Down