denoland/deno · error · Error
Unknown attribute operator
Error message
Unknown attribute operator: '${s}' What it means
Deno lint plugin selectors support a fixed set of attribute operators in [...] parts: =, !=, >, >=, <, <=, ~ and + (getAttrOp in cli/js/40_lint_selector.js). Any other operator string throws `Unknown attribute operator: '<op>'` while the visitor key is parsed, so the rule never registers and linting fails loudly. The classic trigger is copying a CSS attribute substring operator (*=, ^=, $=, |=) that this engine intentionally does not implement.
Solutions
- Replace substring operators with the regex value form: [id.name*="Factory"] → [id.name=/Factory/].
- Or drop the operator ([attr] existence form) and do the precise check in JavaScript inside the visitor callback.
- Check your key against the supported operator list: = != > >= < <= ~ +.
- Keep a unit test that parses every visitor key so unsupported operators fail in CI, not during a lint run.
Example fix
// before
"ClassDeclaration[id.name*=\"Factory\"]:exit"(node) { /* ... */ },
// after
"ClassDeclaration[id.name=/Factory/]:exit"(node) { /* ... */ }, Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_ATTR_OPS = ["=", "!=", ">", ">=", "<", "<=", "~", "+"];
function checkVisitorKeys(keys) {
for (const key of keys) {
if (/(\*|\^|\$|\|)=/.test(key)) {
throw new Error(
`Unsupported attribute operator in "${key}"; supported: ${SUPPORTED_ATTR_OPS.join(" ")}`,
);
}
}
} Prevention
- Memorize the supported operator set (= != > >= < <= ~ +) — CSS substring operators are intentionally absent.
- Use the regex value form [attr=/pattern/] for substring/prefix/suffix matching.
- Run every visitor key through a parse smoke test in CI so bad keys fail before a lint run.
When it happens
Trigger: A visitor key like "ClassDeclaration[id.name*=\"Factory\"]", "Function[id.name^=\"render\"]", "VariableDeclarator[id.name$=\"Count\"]", or a typo such as [attr=!value]. The same getAttrOp path also evaluates top-level combinator tokens (Token.Op), so an unrecognized operator token anywhere in the key can land here.
Common situations: Porting CSS selector habits to lint plugin visitor keys; expecting substring matching that the selector engine never had; typos in hand-written selectors.
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/2cc75f1e2797ce04.
Report an issue: GitHub.
Appendix: source
Thrown at cli/js/40_lint_selector.js:113
switch (s) {
case "=":
return BinOp.Equal;
case "!=":
return BinOp.NotEqual;
case ">":
return BinOp.Greater;
case ">=":
return BinOp.GreaterThan;
case "<":
return BinOp.Less;
case "<=":
return BinOp.LessThan;
case "~":
return BinOp.Tilde;
case "+":
return BinOp.Plus;
default:
throw new Error(`Unknown attribute operator: '${s}'`);
}
}
export class Lexer {
token = Token.Word;
start = 0;
end = 0;
ch = 0;
i = -1;
value = "";
/**
* @param {string} input
*/
constructor(input) {
this.input = input;
this.step();View on GitHub (pinned to 9ad36f7a2c)