{"record":{"id":"0364f297ee1ad6d5","repo":"swc-project/swc","slug":"invalid-scope-at-rule","errorCode":null,"errorMessage":"Invalid @scope at-rule","messagePattern":"Invalid @scope at-rule","errorType":"validation","errorClass":"swc_css_parser::error::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_css_parser/src/parser/at_rules/mod.rs","lineNumber":2652,"sourceCode":"            }\n            _ => {\n                if is_case_insensitive_ident!(self, \"to\") {\n                    bump!(self);\n\n                    self.input.skip_ws();\n\n                    expect!(self, \"(\");\n                    let end = self.parse()?;\n                    expect!(self, \")\");\n\n                    return Ok(ScopeRange {\n                        span: span!(self, span.lo),\n                        scope_start: None,\n                        scope_end: Some(end),\n                    });\n                }\n\n                return Err(Error::new(span, ErrorKind::InvalidScopeAtRule));\n            }\n        }\n    }\n}\n","sourceCodeStart":2634,"sourceCodeEnd":2657,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_css_parser/src/parser/at_rules/mod.rs#L2634-L2657","documentation":"The @scope at-rule prelude (its <scope-range>) has a fixed shape: '(<start>)', 'to (<end>)', or '(<start>) to (<end>)', where both bounds are parenthesized selector lists. The parser is at the start of the scope range and the current token is neither '(' nor the identifier 'to', so no valid scope range can begin and ErrorKind::InvalidScopeAtRule is returned.","triggerScenarios":"'@scope div { ... }' (unparenthesized scope start), '@scope to div { ... }' (missing parentheses around the end), or '@scope { ... }' is fine (EOF path) but '@scope ;;' / any junk token in the prelude triggers it.","commonSituations":"Authors writing @scope like a normal at-rule with a bare selector prelude (the parentheses are easy to forget); early adopters following draft syntax that changed to require parens; copy-pasting examples from articles that used an older syntax.","solutions":["Wrap the scope start in parentheses: '@scope (div) { ... }'","For both bounds use: '@scope (article) to (p) { ... }'","For end-only scoping use the 'to' keyword with parens: '@scope to (footer) { ... }'","If targeting draft-era examples, re-check them against the current @scope grammar"],"exampleFix":"/* before */\n@scope div { ... }\n/* after */\n@scope (div) to (p) { ... }","handlingStrategy":"validation","validationCode":"// @scope prelude must be '(...)' / 'to (...)' / '(...) to (...)'\nfunction scopePreludeOk(prelude) {\n  return /^$|^\\(.*\\)(\\s+to\\s+\\(.*\\))?$|^to\\s+\\(.*\\)$/.test(prelude.trim());\n}","typeGuard":null,"tryCatchPattern":"// JS\ntry { parse(css, opts); } catch (e) { if (/Invalid @scope/.test(e.message)) flagDraftSyntax('wrap @scope bounds in parentheses'); }","preventionTips":["Feature-detect @scope support and lint prelude shape","Pin your team to the parenthesized grammar in examples and snippets"],"tags":["css","at-rule","scope","syntax"],"backgroundTag":"css-at-rule-syntax-error","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}