Skip to content

Recognize case-insensitive import and layer at-rule names - #615

Merged
RyanZim merged 4 commits into
postcss:masterfrom
feritcemkahraman:fix-case-insensitive-at-rules
Oct 13, 2026
Merged

RyanZim merged 4 commits into
postcss:masterfrom
feritcemkahraman:fix-case-insensitive-at-rules

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

CSS at-rule names are ASCII case-insensitive, but uppercase or mixed-case @import is left unresolved. A following lowercase @import is also incorrectly warned about as out of order. An uppercase @layer statement is similarly not recognized when checking the import prelude.

Compare the relevant at-rule names without changing their original serialization. Added regressions cover uppercase imports, mixed-case consecutive imports, and an uppercase layer statement.

Validation: all three new regressions fail on the original code and pass after the fix. ESLint passes. 91 tests pass excluding the pre-existing "should contain a correct sourcemap" failure, which was separately reproduced with the original parse-statements.js; the full suite has that same single failure on this Windows setup.

Reference: https://www.w3.org/TR/css-syntax-3/#at-rules

Maintainer review addressed in a98dbcc: only import and layer names are lowercased; charset remains case-sensitive. Restored surrounding layout to reduce the diff. Added a regression confirming uppercase CHARSET remains an ordinary at-rule and correctly blocks a following import; it failed before this adjustment and passes afterwards.

@romainmenke romainmenke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @feritcemkahraman,

Can you reduce the diff a bit?
Only lowercase layer and import and try to avoid whitespace changes.

Thank you

Comment thread lib/parse-statements.js Outdated
Comment thread lib/parse-statements.js Outdated

@romainmenke romainmenke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. LGTM 👍

@RyanZim RyanZim left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of consistency nits in the tests, otherwise, looks good.

Comment thread test/lint.js Outdated
Comment thread test/lint.js Outdated
Comment thread test/lint.js Outdated
Co-authored-by: Ryan Zimmerman <opensrc@ryanzim.com>
Comment thread test/lint.js Outdated
@RyanZim
RyanZim merged commit d71cf33 into postcss:master Oct 13, 2026
3 checks passed
@RyanZim

RyanZim commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Published in postcss-import@17.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants