{"record":{"id":"52571fcf27a1a694","repo":"swc-project/swc","slug":"unexpected-at-rules-are-not-allowed-here","errorCode":null,"errorMessage":"Unexpected at-rules are not allowed here","messagePattern":"Unexpected at-rules are not allowed here","errorType":"validation","errorClass":"swc_css_parser::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_css_parser/src/parser/at_rules/mod.rs","lineNumber":582,"sourceCode":"            }\n            \"import\" => {\n                let span = self.input.cur_span();\n\n                return Err(Error::new(span, ErrorKind::Unexpected(\"'{' token\")));\n            }\n            \"keyframes\" | \"-webkit-keyframes\" | \"-moz-keyframes\" | \"-o-keyframes\"\n            | \"-ms-keyframes\" => {\n                let ctx = Ctx {\n                    block_contents_grammar: BlockContentsGrammar::RuleList,\n                    in_keyframes_at_rule: true,\n                    ..self.ctx\n                };\n                let rule_list = self.with_ctx(ctx).parse_as::<Vec<Rule>>()?;\n                let rule_list: Vec<ComponentValue> = rule_list\n                    .into_iter()\n                    .map(|rule| match rule {\n                        Rule::AtRule(at_rule) => {\n                            self.errors.push(Error::new(\n                                at_rule.span,\n                                ErrorKind::Unexpected(\"at-rules are not allowed here\"),\n                            ));\n\n                            ComponentValue::AtRule(at_rule)\n                        }\n                        Rule::QualifiedRule(qualified_rule) => {\n                            let locv = match qualified_rule.prelude {\n                                QualifiedRulePrelude::ListOfComponentValues(locv) => locv,\n                                _ => {\n                                    unreachable!();\n                                }\n                            };\n\n                            let res = self.parse_according_to_grammar(&locv, |parser| {\n                                parser.input.skip_ws();\n\n                                let child = parser.parse()?;","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_css_parser/src/parser/at_rules/mod.rs#L564-L600","documentation":"An at-rule appeared in a context where its block is not allowed (e.g. @import or @charset inside another rule's block); the parser rejects it at its span because those at-rules are only valid at the top level.","triggerScenarios":"Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:582 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the at-rule to the stylesheet's top level","Collect and report the error","Drop the disallowed at-rule during recovery"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}