denoland/deno · error · Error
Unknown pseudo selector
Error message
Unknown pseudo selector: '${lex.value}' What it means
The lint selector engine implements only a fixed pseudo-class set: :first-child, :last-child, :nth-child(), :where(), :matches(), :is(), :has() and :not(). The default branch of the pseudo switch (cli/js/40_lint_selector.js) throws `Unknown pseudo selector: '<name>'` for anything else. This is a deliberate limitation — the engine matches an AST, not the DOM, so CSS pseudo-classes like :hover have no meaning here.
Solutions
- Remove the unsupported pseudo-class from the key.
- Re-express the intent with the supported set — e.g. :nth-of-type(2) usually becomes :nth-child(2); grouping becomes :is(a, b).
- If no selector expresses it, match the node type in the key and do the extra check in JavaScript inside the visitor callback.
Example fix
// before
"CallExpression:nth-of-type(2)"(node) { /* ... */ },
// after
"CallExpression:nth-child(2)"(node) { /* ... */ }, Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_PSEUDOS = new Set([
"first-child", "last-child", "nth-child", "where", "matches", "is", "has", "not",
]);
function checkPseudos(key) {
for (const m of key.matchAll(/:([a-z-]+)/g)) {
if (!SUPPORTED_PSEUDOS.has(m[1])) {
throw new Error(`Unsupported pseudo :${m[1]} in "${key}"`);
}
}
} Prevention
- Remember the engine is AST-based: only first-child, last-child, nth-child, where, matches, is, has, not exist.
- Do extra structural checks in JavaScript inside the visitor instead of reaching for CSS pseudo-classes.
When it happens
Trigger: A visitor key containing :root, :hover, :empty, :nth-of-type(), :first-of-type, or any other pseudo not in the supported set — thrown while parsing the key when the rule registers.
Common situations: Copy-pasting a CSS selector into a plugin rule; assuming full CSS selector support; using structural pseudo-classes that exist in CSS but map to nothing in an AST.
Related errors
- Empty node
- Empty selector
- Expected 'of' keyword in ':nth-child' but got
- Expected token ' ', but got ' '.\n\n \n ^
- Invalid RegExp pattern
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/84b3d3ae46d3f1df.
Report an issue: GitHub.
Appendix: source
Thrown at cli/js/40_lint_selector.js:725
stack.push([]);
continue;
}
case "not": {
lex.next();
lex.expect(Token.BraceOpen);
lex.next();
current.push({
type: PSEUDO_NOT,
selectors: [],
});
stack.push([]);
continue;
}
default:
throw new Error(`Unknown pseudo selector: '${lex.value}'`);
}
} else if (lex.token === Token.Comma) {
if (throwOnComma) {
throw new Error(`Multiple selector arguments not supported here`);
}
lex.next();
if (lex.token === Token.Space) {
lex.next();
}
popSelector(result, stack);
stack.push([]);
continue;
} else if (lex.token === Token.BraceClose) {
throwOnComma = false;
popSelector(result, stack);
} else if (lex.token === Token.Op) {View on GitHub (pinned to 9ad36f7a2c)