swc-project/swc · error · Error
Expected '--' at the start of custom property name
Error message
Expected '--' at the start of custom property name
What it means
Fired while parsing a CustomPropertyName: an Ident token was present, but its value did not start with `--`, which the CSS custom properties spec requires for custom property names. Input at fault is a declaration whose property looks like a custom property context but has a normal name, e.g. using a non-`--` prefixed name where --var syntax is mandatory.
Source
Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:1907
}
}
}
impl<I> Parse<CustomPropertyName> for Parser<I>
where
I: ParserInput,
{
fn parse(&mut self) -> PResult<CustomPropertyName> {
let span = self.input.cur_span();
if !is!(self, Ident) {
return Err(Error::new(span, ErrorKind::Expected("Ident")));
}
match bump!(self) {
Token::Ident { value, raw, .. } => {
if !value.starts_with("--") {
return Err(Error::new(
span,
ErrorKind::Expected("'--' at the start of custom property name"),
));
} else if &*value == "--" {
return Err(Error::new(
span,
ErrorKind::Expected("valid dashed, '--' is not valid custom property name"),
));
}
Ok(CustomPropertyName {
span,
value,
raw: Some(raw),
})
}
_ => {
unreachable!()View on GitHub (pinned to 5176682b65)
Solutions
- Prefix the property name with '--' (e.g. '--brand-color')
- Use a normal declaration if a standard property was intended
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:1907 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/c46c246dd10ada72.
Report an issue: GitHub.