{"id":25641,"library":"gonzales-pe-sl","title":"gonzales-pe-sl (CSS Parser Fork for sass-lint)","description":"A temporary fork of gonzales-pe, version 4.2.3, created specifically for sass-lint. It is a CSS parser that supports SCSS, Sass, and LESS syntaxes, producing a parse tree that can be traversed, modified, and serialized back to CSS. The package is unmaintained and intended only as a transitional dependency for sass-lint; newer projects should use postcss-scss or postcss-less instead. The release cadence is effectively frozen.","status":"maintenance","version":"4.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/DanPurdy/gonzales-pe","tags":["javascript"],"install":[{"cmd":"npm install gonzales-pe-sl","lang":"bash","label":"npm"},{"cmd":"yarn add gonzales-pe-sl","lang":"bash","label":"yarn"},{"cmd":"pnpm add gonzales-pe-sl","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not support ESM; use CommonJS require. The symbol is the default export, typically named gonzales.","wrong":"import gonzales from 'gonzales-pe-sl';","symbol":"gonzales","correct":"const gonzales = require('gonzales-pe-sl');"},{"note":"gonzales is the default require, and parse is a method on it. The syntax option is required for non-CSS syntaxes.","symbol":"parse","correct":"const parseTree = gonzales.parse(css, {syntax: 'scss'});"},{"note":"createNode is a method on the default export, not a named export.","wrong":"import { createNode } from 'gonzales-pe-sl';","symbol":"createNode","correct":"const node = gonzales.createNode({ type: 'selector', content: 'div' });"},{"note":"No TypeScript types or enums are provided; node types are plain strings.","wrong":"import { NodeType } from 'gonzales-pe-sl';","symbol":"Types (Node types)","correct":"// Node types are strings like 'selector', 'declaration', 'value', etc. Refer to docs."}],"quickstart":{"code":"const gonzales = require('gonzales-pe-sl');\n\n// Parse SCSS\nconst css = `\n.container {\n  $color: red;\n  .item {\n    color: $color;\n  }\n}`;\n\nconst options = {\n  syntax: 'scss',\n  tabSize: 2\n};\n\nconst parseTree = gonzales.parse(css, options);\nconsole.log(parseTree.type); // 'stylesheet'\n\n// Traverse and find selectors\nconst findSelectors = (node) => {\n  if (node.type === 'selector') {\n    console.log('Found selector:', node.content.map(t => t.content).join(''));\n  }\n  if (node.content && Array.isArray(node.content)) {\n    node.content.forEach(findSelectors);\n  }\n};\nfindSelectors(parseTree);\n\n// Convert back to string\nconst stringified = parseTree.toString();\nconsole.log(stringified);","lang":"javascript","description":"Shows how to require the package, parse SCSS with options, traverse the tree recursively finding selectors, and convert back to string."},"warnings":[{"fix":"Replace with postcss-scss (npm install postcss-scss) or postcss-less, and use postcss's AST API.","message":"gonzales-pe-sl is a temporary fork for sass-lint only; not intended for direct use. Use postcss-scss or postcss-less instead.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use require() as shown in the quickstart, or consider switching to a modern parser.","message":"No ES module (ESM) support; only CommonJS require() works. Attempting to import will fail.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Refer to the original gonzales-pe docs for node types; for TypeScript projects, consider using @types/gonzales-pe (if available) or switch to postcss.","message":"The parse tree node types are plain strings; no TypeScript types or documentation beyond node-types.md. Nodes may have unexpected structures.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Migrate to a maintained alternative like postcss-scss or gonzales-pe-dev (not recommended).","message":"The package is no longer maintained and will not receive security updates or bug fixes.","severity":"breaking","affected_versions":">=4.2.3"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install gonzales-pe-sl","cause":"Package not installed","error":"Cannot find module 'gonzales-pe-sl'"},{"fix":"Change import gonzales from 'gonzales-pe-sl' to const gonzales = require('gonzales-pe-sl');","cause":"Using ES import instead of require","error":"gonzales.parse is not a function"},{"fix":"Ensure you pass the correct syntax option (e.g., {syntax: 'scss'}) and valid CSS string.","cause":"Parsing failed, likely due to missing syntax option or invalid CSS","error":"TypeError: Cannot read property 'type' of undefined"},{"fix":"Simplify the input or switch to a more modern parser like postcss-scss.","cause":"Parser cannot handle the input syntax because it is not supported (e.g., some newer CSS features).","error":"Unrecognised input"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}