{"record":{"id":"2ceb7b6a5f3f1b2f","repo":"swc-project/swc","slug":"expected-indent-token","errorCode":null,"errorMessage":"Expected indent token","messagePattern":"Expected indent token","errorType":"validation","errorClass":"swc_css_parser::error::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_css_parser/src/parser/at_rules/mod.rs","lineNumber":2535,"sourceCode":"                Ok(SizeFeatureValue::Function(function))\n            }\n            _ => Err(Error::new(\n                span,\n                ErrorKind::Expected(\"number, ident, dimension or function token\"),\n            )),\n        }\n    }\n}\n\nimpl<I> Parse<ExtensionName> for Parser<I>\nwhere\n    I: ParserInput,\n{\n    fn parse(&mut self) -> PResult<ExtensionName> {\n        let span = self.input.cur_span();\n\n        if !is!(self, Ident) {\n            return Err(Error::new(span, ErrorKind::Expected(\"indent token\")));\n        }\n\n        // All extensions defined in this specification use a common syntax for defining\n        // their ”names”: the <extension-name> production. An <extension-name> is any\n        // identifier that starts with two dashes (U+002D HYPHEN-MINUS), like --foo, or\n        // even exotic names like -- or ------. The CSS language will never use\n        // identifiers of this form for any language-defined purpose, so it’s safe to\n        // use them for author-defined purposes without ever having to worry about\n        // colliding with CSS-defined names.\n        match bump!(self) {\n            Token::Ident { value, raw, .. } => {\n                if !value.starts_with(\"--\") {\n                    return Err(Error::new(\n                        span,\n                        ErrorKind::Expected(\"Extension name should start with '--'\"),\n                    ));\n                }\n","sourceCodeStart":2517,"sourceCodeEnd":2553,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_css_parser/src/parser/at_rules/mod.rs#L2517-L2553","documentation":"An <extension-name> (used for names in @custom-media and @container-style extensions) must start as an identifier token. The parser found a non-Ident token (number, hash, delimiter, string) where the extension name was expected. The message text 'indent token' is a typo in the parser for 'ident token'.","triggerScenarios":"'@custom-media 123wide (min-width: 100px);', '@custom-media \"--wide\" ...', or any extension-name slot whose first token is not an identifier.","commonSituations":"Naming custom media starting with a digit, quoting the name, or omitting the name so the next token (e.g. '(' of the media condition) is read as the name; generator code that interpolates an empty or numeric name.","solutions":["Give the extension a valid identifier starting with '--': '@custom-media --wide (min-width: 100px);'","Do not quote extension names","If the name was omitted, add it before the media query","Sanitize generated names so they match /--?[A-Za-z_][A-Za-z0-9_-]*/"],"exampleFix":"/* before */\n@custom-media 123wide (min-width: 100px);\n/* after */\n@custom-media --wide (min-width: 100px);","handlingStrategy":"validation","validationCode":"function isValidExtensionNameToken(src) {\n  return /^--?[A-Za-z_-][\\w-]*/.test(src); // starts as an identifier (ideally with '--')\n}","typeGuard":"// Rust\nfn is_extension_name_ident(s: &str) -> bool {\n  let mut c = s.chars();\n  matches!(c.next(), Some(a if a.is_ascii_alphabetic() || a == '_' || a == '-'))\n}","tryCatchPattern":"// Rust\nlet name = if is_extension_name_ident(&raw) { raw } else { format!(\"--{raw}\") }; // normalize, then parse","preventionTips":["Never quote extension names","Generate custom-media names from a slugify helper that guarantees an identifier start"],"tags":["css","custom-media","syntax","naming"],"backgroundTag":"css-custom-ident-naming","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"}