{"record":{"id":"6369f32e2fc043c1","repo":"denoland/deno","slug":"invalid-regexp-pattern-raw","errorCode":null,"errorMessage":"Invalid RegExp pattern: ${raw}","messagePattern":"Invalid RegExp pattern: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/js/40_lint_selector.js","lineNumber":406,"sourceCode":"  switch (raw) {\n    case \"true\":\n      return true;\n    case \"false\":\n      return false;\n    case \"null\":\n      return null;\n    case \"undefined\":\n      return undefined;\n    default:\n      if (raw.startsWith(\"'\") && raw.endsWith(\"'\")) {\n        if (raw.length === 2) return \"\";\n        return raw.slice(1, -1);\n      } else if (raw.startsWith('\"') && raw.endsWith('\"')) {\n        if (raw.length === 2) return \"\";\n        return raw.slice(1, -1);\n      } else if (raw.startsWith(\"/\")) {\n        const end = raw.lastIndexOf(\"/\");\n        if (end === -1) throw new Error(`Invalid RegExp pattern: ${raw}`);\n        const pattern = raw.slice(1, end);\n        const flags = end < raw.length - 1 ? raw.slice(end + 1) : undefined;\n        return new RegExp(pattern, flags);\n      } else if (NUMBER_REG.test(raw)) {\n        return Number(raw);\n      } else if (BIGINT_REG.test(raw)) {\n        return BigInt(raw.slice(0, -1));\n      }\n\n      return raw;\n  }\n}\n\nexport const ELEM_NODE = 1;\nexport const RELATION_NODE = 2;\nexport const ATTR_EXISTS_NODE = 3;\nexport const ATTR_BIN_NODE = 4;\nexport const PSEUDO_NTH_CHILD = 5;","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/js/40_lint_selector.js#L388-L424","documentation":"Thrown by the value parser in cli/js/40_lint_selector.js when an attribute value starts with '/' (marking a RegExp literal) but no closing '/' exists (raw.lastIndexOf(\"/\") === -1). Attribute values in selectors can be quoted strings, regexes written /pattern/flags, numbers, or bigints — a lone slash means an unterminated regex.","triggerScenarios":"A selector like \"Literal[value=/foo]\", \"[regex=/]\", or any [...] value beginning with '/' that is not terminated by a second '/'. Common when the regex itself contains a '/' that was not escaped, terminating the literal early or confusing the writer.","commonSituations":"Trying to match string literal values by a pattern, e.g. [value=/^\\d+$/], and forgetting to close or escape slashes; converting a JS regex literal into a selector value and dropping the trailing slash.","solutions":["Close the regex literal: [value=/^\\d+$/]","If the pattern contains '/', escape it as \\/ inside the selector value"],"exampleFix":"// before\n\"Literal[value=/https://]\"(node) {},\n\n// after\n\"Literal[value=/https:\\/\\//]\"(node) {},","handlingStrategy":"validation","validationCode":"function regexValuesClosed(sel) {\n  for (const m of sel.matchAll(/=\\/(?:[^/\\\\]|\\\\.)*/g)) {\n    const rest = sel.slice(m.index + m[0].length);\n    if (!/^\\//.test(rest)) return false; // no closing '/'\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write regex attribute values as /pattern/ with both delimiters","Escape '/' inside the pattern as \\/ before embedding it in a selector"],"tags":["lint","selector","regex","esquery","parser"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}