Skip to content

Commit

Permalink
stricter parser
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Aug 15, 2023
1 parent 7e656ca commit e3df2ba
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/parse-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ function parseImport(result, atRule, conditions, from) {
(node.type === "word" || node.type === "function") &&
/^layer$/i.test(node.value)
) {
if (layer.length > 0) {
return result.warn(`Multiple layers in '${atRule.toString()}'`, {
node: atRule,
})
}

if (supports.length > 0) {
return result.warn(
`layers must be defined before support conditions in '${atRule.toString()}'`,
{
node: atRule,
}
)
}

if (node.nodes) {
layer = [stringify(node.nodes)]
} else {
Expand All @@ -198,6 +213,15 @@ function parseImport(result, atRule, conditions, from) {
}

if (node.type === "function" && /^supports$/i.test(node.value)) {
if (supports.length > 0) {
return result.warn(
`Multiple support conditions in '${atRule.toString()}'`,
{
node: atRule,
}
)
}

supports = [stringify(node.nodes)]

continue
Expand Down

0 comments on commit e3df2ba

Please sign in to comment.