{"library":"rework-visit","title":"Rework CSS AST Declaration Visitor","description":"rework-visit is a utility package providing a declaration visitor for the Rework CSS preprocessor's Abstract Syntax Tree (AST). Released as version 1.0.0 in June 2013, it has not seen active development or new releases since. The package enables Rework plugins to traverse and manipulate CSS declarations programmatically within the AST. It is specifically designed for the `rework` ecosystem, which has largely been superseded by more modern and actively maintained CSS tooling like PostCSS. Therefore, rework-visit is considered abandoned, with no ongoing release cadence or new feature development. Its core differentiator is its tight integration with the now-legacy Rework AST, making it unsuitable for contemporary CSS processing pipelines.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install rework-visit"],"cli":null},"imports":["const visit = require('rework-visit');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const rework = require('rework');\nconst visit = require('rework-visit');\n\nconst cssInput = `\n  .container {\n    color: blue;\n    font-size: 16px;\n    display: flex;\n  }\n  .item {\n    margin: 10px;\n    padding: 5px;\n  }\n`;\n\nfunction myReworkPlugin(stylesheet) {\n  visit.declarations(stylesheet, function (declarations, node) {\n    declarations.forEach(function (declaration) {\n      // Example: Convert all font-size values to '1.2em' (for demonstration)\n      if (declaration.property === 'font-size') {\n        declaration.value = '1.2em';\n      }\n      // Example: Add a new declaration\n      if (declaration.property === 'display' && declaration.value === 'flex') {\n        declarations.push({\n          type: 'declaration',\n          property: 'align-items',\n          value: 'center'\n        });\n      }\n    });\n  });\n}\n\n// Apply the plugin\nconst outputCss = rework(cssInput)\n  .use(myReworkPlugin)\n  .toString();\n\nconsole.log(outputCss);\n/*\n  Expected Output:\n  .container {\n    color: blue;\n    font-size: 1.2em;\n    display: flex;\n    align-items: center;\n  }\n  .item {\n    margin: 10px;\n    padding: 5px;\n  }\n*/","lang":"javascript","description":"This example demonstrates how to use `rework-visit` within a `rework` plugin to iterate over and modify CSS declarations in an AST. It changes 'font-size' and adds 'align-items' to flex containers.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}