{"id":15547,"library":"bo-selector","title":"bo-selector: CSS Selector Parser","description":"The `bo-selector` package provides a CSS selector parser capable of generating an Abstract Syntax Tree (AST) from a CSS selector string. It is built using `jison`, a parser generator, which is a development dependency, meaning the runtime package has no external dependencies. The package is currently at version 0.0.10 and has not seen updates since its last publish in October 2013, indicating it is an abandoned project. Its primary utility is to parse CSS selectors like `'p:has(.foo), b'` into a structured JavaScript object that represents the selector's components and relationships. It exclusively uses the CommonJS module system. Given its age and lack of maintenance, it is highly unlikely to support modern CSS selector features introduced after 2013, nor does it provide an ECMAScript Module (ESM) entry point, making integration into contemporary JavaScript projects challenging.","status":"abandoned","version":"0.0.10","language":"javascript","source_language":"en","source_url":"https://github.com/featurist/bo-selector","tags":["javascript","css","selector","parser","jison","shamone"],"install":[{"cmd":"npm install bo-selector","lang":"bash","label":"npm"},{"cmd":"yarn add bo-selector","lang":"bash","label":"yarn"},{"cmd":"pnpm add bo-selector","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not provide an ESM export. Direct property access is required.","wrong":"import { parser } from 'bo-selector';","symbol":"parser","correct":"const parser = require('bo-selector').parser;"}],"quickstart":{"code":"const parser = require('bo-selector').parser;\nconst util = require('util');\n\n// Example CSS selector string\nconst cssSelector = 'p:has(.foo), b.bar[data-attr=\"value\"]';\n\n// Parse the CSS selector into an Abstract Syntax Tree (AST)\nconst ast = parser.parse(cssSelector);\n\n// Log the generated AST in a human-readable format\nconsole.log('Parsed AST:');\nconsole.log(util.inspect(ast, { depth: null, colors: true }));\n\n// Demonstrate accessing parts of the AST (simplified)\nif (ast.type === 'selector_list' && ast.selectors.length > 0) {\n  const firstSelectorElement = ast.selectors[0].element;\n  console.log('\\nFirst selector element name:', firstSelectorElement.name);\n  if (firstSelectorElement.constraints && firstSelectorElement.constraints.length > 0) {\n    console.log('First selector element constraints:', firstSelectorElement.constraints.map(c => c.type));\n  }\n}","lang":"javascript","description":"Demonstrates parsing a CSS selector string into an Abstract Syntax Tree (AST) and inspecting its structure."},"warnings":[{"fix":"Consider using modern, actively maintained CSS selector parsers or libraries (e.g., PostCSS, css-tree) for new projects. If you must use this package, be aware of its limitations and security implications.","message":"The `bo-selector` package is abandoned, with its last publish in October 2013. It is not maintained and will not receive updates for new CSS features, bug fixes, or security patches.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Ensure your project is configured for CommonJS (`require()`) when using this package. If your project is ESM-first, you may need to use a bundler or dynamic import (`await import()`) if compatibility layers exist, or prefer an alternative ESM-compatible parser.","message":"This package is strictly CommonJS-only. Attempting to use `import` statements will result in errors in an ESM context.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Test your specific selector syntax extensively. For selectors not supported, you will need to manually parse or pre-process them, or switch to a more modern parser.","message":"Due to its age, `bo-selector` does not support modern CSS selector syntax (e.g., `:is()`, `:where()`, `:has()` with complex arguments, new pseudo-classes/elements) introduced after CSS Selectors Level 3 (roughly 2011-2013).","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use the CommonJS `require()` syntax: `const parser = require('bo-selector').parser;`","cause":"Attempting to use `import { parser } from 'bo-selector';` in an ESM module context.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Ensure you are accessing the `parser` property from the required module: `const { parser } = require('bo-selector');` or `const boselector = require('bo-selector'); const parser = boselector.parser;`","cause":"Incorrectly trying to call `bo-selector()` directly or a non-existent method.","error":"parser.parse is not a function"}],"ecosystem":"npm"}