{"record":{"id":"ff24a58edd4bece7","repo":"denoland/deno","slug":"empty-selector","errorCode":null,"errorMessage":"Empty selector","messagePattern":"Empty selector","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/js/40_lint_selector.js","lineNumber":773,"sourceCode":"  }\n\n  return result;\n}\n\n/**\n * @param {Selector[]} result\n * @param {Selector[]} stack\n */\nfunction popSelector(result, stack) {\n  const sel = /** @type {Selector} */ (stack.pop());\n\n  if (stack.length === 0) {\n    result.push(sel);\n    stack.push([]);\n  } else {\n    const prev = /** @type {Selector} */ (stack.at(-1));\n    if (prev.length === 0) {\n      throw new Error(`Empty selector`);\n    }\n\n    const node = prev.at(-1);\n    if (node === undefined) {\n      throw new Error(`Empty node`);\n    }\n\n    if (node.type === PSEUDO_NTH_CHILD) {\n      node.of = sel;\n    } else if (\n      node.type === PSEUDO_HAS || node.type === PSEUDO_IS ||\n      node.type === PSEUDO_NOT\n    ) {\n      node.selectors.push(sel);\n    } else {\n      throw new Error(`Multiple selectors not allowed here`);\n    }\n  }","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/js/40_lint_selector.js#L755-L791","documentation":"popSelector (cli/js/40_lint_selector.js) attaches each finished selector group to its parent node; when the group below the popped frame is empty it throws `Empty selector` as an invariant guard. Under the current grammar most user inputs route elsewhere (empty groups inside :is()/:has() are tolerated), so encountering this error usually means a degenerate selector key or a parser edge case — notably :nth-child forms without an `of` clause interact oddly with the parser's group stack.","triggerScenarios":"Degenerate or malformed selector keys that leave an empty selector group on the stack when one is popped — e.g. empty groups created by stray separators, or unusual :nth-child(...) placements inside :has()/:is()/:not(). Well-formed keys effectively never reach this branch.","commonSituations":"Hand-crafted selector keys assembled by string concatenation that produce empty segments; experimental selector syntax; a key that looks valid but trips a parser bug.","solutions":["Simplify the selector key: reduce it to node types and one pseudo-class at a time until the throw disappears.","Avoid mixing :nth-child(...) (without `of`) inside :has()/:is()/:not() compound selectors; compute the check in JavaScript instead.","If the key looks valid, minimize it and report the case to the Deno repository (denoland/deno) — this branch is an invariant guard and may indicate a parser bug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep visitor keys simple: plain compound selectors with at most one pseudo-class each.","Avoid mixing :nth-child(...) without an 'of' clause inside :has()/:is()/:not() compounds.","If a key that looks valid triggers this, minimize it and report it to denoland/deno — the branch is an invariant guard."],"tags":["deno","deno-lint","lint-plugin","selector","parse-error","invariant"],"backgroundTag":"invalid-selector-syntax","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}