{"record":{"id":"3a7eafa1aafcdd69","repo":"denoland/deno","slug":"expected-of-keyword-in-nth-child-but-got-l","errorCode":null,"errorMessage":"Expected 'of' keyword in ':nth-child' but got: ${lex.value}","messagePattern":"Expected 'of' keyword in ':nth-child' but got: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/js/40_lint_selector.js","lineNumber":657,"sourceCode":"            } else if (lex.token === Token.Minus) {\n              node.op = \"-\";\n              lex.next();\n\n              if (lex.token === Token.Space) {\n                lex.next();\n              }\n            }\n\n            lex.expect(Token.Word);\n            node.stepOffset = +lex.value;\n            lex.next();\n\n            if (lex.token !== Token.BraceClose) {\n              lex.next(); // Space\n\n              if (lex.token === Token.Word) {\n                if (/** @type {string} */ (lex.value) !== \"of\") {\n                  throw new Error(\n                    `Expected 'of' keyword in ':nth-child' but got: ${lex.value}`,\n                  );\n                }\n\n                lex.next();\n                lex.expect(Token.Space);\n                lex.next();\n                throwOnComma = true;\n                stack.push([]);\n              }\n\n              continue;\n            }\n\n            lex.expect(Token.BraceClose);\n          } else if (!node.repeat) {\n            // :nth-child(2) -> step is actually stepOffset\n            node.stepOffset = node.step - 1;","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/js/40_lint_selector.js#L639-L675","documentation":"Thrown in the :nth-child parsing branch (cli/js/40_lint_selector.js) when the parser accepts an 'An+B of S' form and, after the step offset, encounters a word that is not the literal keyword 'of'. The 'of' keyword introduces the selector whose nth match counts, e.g. :nth-child(2 of VariableDeclarator).","triggerScenarios":"Selectors like \":nth-child(2 odd)\", \":nth-child(2 n of X)\", or any word other than 'of' after the offset inside :nth-child(...). Also a typo'd keyword such as 'Of' (case matters).","commonSituations":"Copying CSS :nth-child(an+b [of S]) syntax that this parser only partially supports; writing :nth-child(2n) expecting the CSS '2n' step form; putting a bare type name directly after the number without the 'of' keyword.","solutions":["Use the exact form :nth-child(N of Selector), e.g. :nth-child(2 of VariableDeclarator)","If you meant a pure positional match with no selector, keep just the number: :nth-child(2)"],"exampleFix":"// before\n\":nth-child(2 VariableDeclarator)\"(node) {},\n\n// after\n\":nth-child(2 of VariableDeclarator)\"(node) {},","handlingStrategy":"validation","validationCode":"function validNthChild(sel) {\n  return sel.replace(/:nth-child\\(([^)]*)\\)/g, (_, arg) => {\n    if (!/^(?:\\d+|\\d+ of .+)$/.test(arg.trim())) throw new Error(`bad :nth-child arg: '${arg}'`);\n    return _;\n  });\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the two supported forms: :nth-child(N) and :nth-child(N of Selector) — nothing else","The keyword is lowercase 'of'; CSS 'an+b' forms like 2n are not accepted"],"tags":["lint","selector","nth-child","esquery","parser"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}