{"_id":"@dvorakdominik/prettier-plugin-less-detached-rules","name":"@dvorakdominik/prettier-plugin-less-detached-rules","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dvorakdominik/prettier-plugin-less-detached-rules","version":"0.1.0","description":"Prettier plugin that formats LESS detached ruleset arguments passed to mixin calls.","keywords":["prettier","prettier-plugin","less","detached-ruleset","mixin","postcss-less"],"license":"MIT","author":{"name":"Dominik Dvořák"},"repository":{"type":"git","url":"git+https://github.com/dvorakdominik/prettier-less-detached-rules.git"},"bugs":{"url":"https://github.com/dvorakdominik/prettier-less-detached-rules/issues"},"homepage":"https://github.com/dvorakdominik/prettier-less-detached-rules#readme","type":"commonjs","main":"./src/plugin.cjs","exports":{".":{"require":"./src/plugin.cjs","default":"./src/plugin.cjs"}},"publishConfig":{"access":"public"},"engines":{"node":">=20"},"scripts":{"test":"vitest run","test:watch":"vitest","lint:format":"prettier --check 'src/**/*.cjs' 'tests/**/*.{mjs,less}'","prepublishOnly":"npm test","release:patch":"npm version patch && npm publish","release:minor":"npm version minor && npm publish","release:major":"npm version major && npm publish"},"peerDependencies":{"prettier":"^3.0.0"},"dependencies":{"postcss":"^8.3.5","postcss-less":"^6.0.0"},"devDependencies":{"prettier":"^3.8.3","vitest":"^4.1.7"},"_id":"@dvorakdominik/prettier-plugin-less-detached-rules@0.1.0","gitHead":"419c79ac5f2bdfa247383eac78347a1ad0ee3ce6","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-LcZsPFyIIeGb22QSMRS9x27R/guhHT6k41YgSUVqSTamxBf2utnWxM9oEDAdSX+mkJCmz8cK8rBK7PqelbeOpw==","shasum":"08bffc85a63edc90a8d749a1d8a24630987e0d4b","tarball":"https://registry.npmjs.org/@dvorakdominik/prettier-plugin-less-detached-rules/-/prettier-plugin-less-detached-rules-0.1.0.tgz","fileCount":4,"unpackedSize":12146,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDSN6+I1zpFU/QMR3eDqPWP205lOt1JckCbx+tXmUsEagIgWuSwdnuhyudJJYl8fZEN5E/bhVWuyfUIoNTrcp6N+70="}]},"_npmUser":{"name":"dvorak-dominik","email":"me@dominikdvorak.cz"},"directories":{},"maintainers":[{"name":"dvorak-dominik","email":"me@dominikdvorak.cz"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prettier-plugin-less-detached-rules_0.1.0_1779695203178_0.20374964050932642"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-25T07:46:42.945Z","0.1.0":"2026-05-25T07:46:43.301Z","modified":"2026-05-25T07:46:43.646Z"},"maintainers":[{"name":"dvorak-dominik","email":"me@dominikdvorak.cz"}],"description":"Prettier plugin that formats LESS detached ruleset arguments passed to mixin calls.","homepage":"https://github.com/dvorakdominik/prettier-less-detached-rules#readme","keywords":["prettier","prettier-plugin","less","detached-ruleset","mixin","postcss-less"],"repository":{"type":"git","url":"git+https://github.com/dvorakdominik/prettier-less-detached-rules.git"},"author":{"name":"Dominik Dvořák"},"bugs":{"url":"https://github.com/dvorakdominik/prettier-less-detached-rules/issues"},"license":"MIT","readme":"# prettier-plugin-less-detached-rules\n\nA [Prettier](https://prettier.io/) plugin that formats **LESS detached ruleset arguments** inside mixin calls.\n\n## The problem\n\nPrettier's built-in LESS formatter leaves the content of detached rulesets inside mixin arguments unformatted:\n\n```less\n// Before (what Prettier produces without this plugin)\n.container {\n  .mediaMin(tablet, {color: red;\nmargin: 0; padding:10px;});\n}\n```\n\n```less\n// After (with this plugin)\n.container {\n  .mediaMin(tablet, {\n    color: red;\n    margin: 0;\n    padding: 10px;\n  });\n}\n```\n\n## Installation\n\n```sh\nnpm install --save-dev @dvorakdominik/prettier-plugin-less-detached-rules\n```\n\nRequires **Prettier ≥ 3.0** as a peer dependency.\n\n## Configuration\n\nAdd the plugin to your `.prettierrc` (or equivalent):\n\n```json\n{\n  \"plugins\": [\"@dvorakdominik/prettier-plugin-less-detached-rules\"]\n}\n```\n\nThat's it — formatting of LESS files with detached ruleset arguments now works correctly.\n\n## Compatibility\n\n| Dependency | Version |\n|---|---|\n| Node.js | ≥ 20 |\n| Prettier | ≥ 3.0 |\n\n### Other LESS plugins\n\nThis plugin is designed to coexist with other Prettier LESS plugins (e.g. `prettier-plugin-css-grid`). It correctly delegates text transformations from upstream plugins before applying its own processing.\n\nPlugin order in your configuration follows the standard Prettier plugin ordering rules — place this plugin **last** if using it alongside other LESS plugins:\n\n```json\n{\n  \"plugins\": [\"prettier-plugin-css-grid\", \"@dvorakdominik/prettier-plugin-less-detached-rules\"]\n}\n```\n\n## Known limitations\n\n- **One detached ruleset per mixin call**: if a single mixin call contains multiple detached ruleset arguments (e.g. `.mixin({a: 1}, {b: 2})`), only the first will be formatted. This is an uncommon LESS pattern.\n- **Module-level re-entrancy guard**: the plugin uses a module-level counter to prevent infinite recursion. Concurrent `prettier.format()` calls within the same Node.js process that share this module instance are not safe. In practice, Prettier's worker pool uses separate child processes, so this is not an issue in normal usage.\n- **Silent formatting failures**: if the inner content of a detached ruleset is syntactically invalid, the plugin skips it rather than aborting the entire file. Set `PRETTIER_PLUGIN_DEBUG=1` to log skipped nodes to stderr.\n\n## How it works\n\n1. Runs Prettier on the file to establish correct outer indentation.\n2. Parses the result with `postcss-less` to locate mixin calls whose params include a `{…}` block.\n3. For each such block, formats the inner content with Prettier using a dummy wrapper rule (`.x { … }`), then adjusts the indentation to match the call site.\n4. Returns the final AST to Prettier for printing.\n\nRe-entrant calls (triggered by step 3) are detected via a depth counter and delegated directly to the built-in LESS parser, preventing infinite recursion while still allowing other plugins to run.\n\n## License\n\nMIT © Dominik Dvořák\n","readmeFilename":"README.md","_rev":"1-5d188e4d5b78f6053898448400b6efce"}