{"id":31364458,"url":"https://github.com/rich-27/prettier-plugin-js-hack-pipes-wrapper","last_synced_at":"2026-04-20T03:33:06.783Z","repository":{"id":316424212,"uuid":"1062772300","full_name":"rich-27/prettier-plugin-js-hack-pipes-wrapper","owner":"rich-27","description":"A Prettier plugin that enables formatting using JavaScript's proposed Hack pipe operator with the topic token specified in your Babel configuration.","archived":false,"fork":false,"pushed_at":"2025-09-24T15:03:06.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-24T15:17:50.681Z","etag":null,"topics":["babel","formatting","javascript","pipeline-operator","prettier","prettier-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rich-27.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T17:51:20.000Z","updated_at":"2025-09-24T15:03:09.000Z","dependencies_parsed_at":"2025-09-24T15:28:07.074Z","dependency_job_id":null,"html_url":"https://github.com/rich-27/prettier-plugin-js-hack-pipes-wrapper","commit_stats":null,"previous_names":["rich-27/prettier-plugin-js-hack-pipes-wrapper"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rich-27/prettier-plugin-js-hack-pipes-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-27%2Fprettier-plugin-js-hack-pipes-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-27%2Fprettier-plugin-js-hack-pipes-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-27%2Fprettier-plugin-js-hack-pipes-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-27%2Fprettier-plugin-js-hack-pipes-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rich-27","download_url":"https://codeload.github.com/rich-27/prettier-plugin-js-hack-pipes-wrapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-27%2Fprettier-plugin-js-hack-pipes-wrapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32031583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","formatting","javascript","pipeline-operator","prettier","prettier-plugin"],"created_at":"2025-09-27T07:50:14.449Z","updated_at":"2026-04-20T03:33:06.737Z","avatar_url":"https://github.com/rich-27.png","language":"JavaScript","readme":"# Patching JS Hack Pipes in Prettier \u0026nbsp;[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n`prettier-plugin-js-hack-pipes-wrapper` is a [Prettier](https://prettier.io/) plugin that enables formatting using JavaScript's proposed Hack pipe operator with the topic token specified in your Babel configuration.\n\n## The Problem\n\nPrettier's built-in JavaScript parser hardcodes the pipeline operator topic token to `%`. The token is still to be determined, as of September 2025. `@babel/plugin-proposal-pipeline-operator` allows for the configuration of the topic token. When using a non-default topic token, Prettier fails to parse and format the code correctly, raising the following syntax error:\n\n```\nSyntaxError: Invalid topic token {token}. In order to use {token} as a topic reference, the pipelineOperator plugin must be configured with { \"proposal\": \"hack\", \"topicToken\": \"{token}\" }\n```\n\nPrettier does not expose a pipelineOperator plugin nor provide the ability to configure it.\n\n## How it works\n\nThis plugin:\n\n1. Attempts to read your Babel configuration to detect the configured topic token\n2. Wraps Prettier's `babel` JS parser, replacing the topic token for AST generation\n3. Wraps Prettier's `estree` printer to print the AST with with the correct topic token\n\nAs of mid 2025, `#` seems to be the most promising candidate for the operator's topic token (see [Bikeshedding on the wiki](https://github.com/tc39/proposal-pipeline-operator/wiki/Bikeshedding-the-Hack-topic-token) and [Bikeshedding discussion](https://github.com/tc39/proposal-pipeline-operator/issues/91#issuecomment-2784940602)), hence its use subsequent use in this readme.\n\n## Installation\n\nThe following is a placeholder, currently the plugin only supports [being run locally via relative resolution](https://prettier.io/docs/plugins#testing-plugins).\n\n```bash\nnpm install --save-dev prettier-plugin-js-hack-pipes-wrapper\n```\n\n## Usage\n\nThe following is a placeholder, currently the plugin only supports [being run locally via relative resolution](https://prettier.io/docs/plugins#testing-plugins).\n\n### Via Configuration File\n\n```json\n{\n  \"plugins\": [\"prettier-plugin-js-hack-pipes-wrapper\"]\n}\n```\n\n### Via CLI\n\n```bash\nprettier --write --plugin=prettier-plugin-js-hack-pipes-wrapper \"**/*.js\"\n```\n\n### Via API\n\n```javascript\nimport prettier from 'prettier';\n\nconst formatted = await prettier.format(code, {\n  parser: '|\u003e-babel-wrapper',\n  printer: '|\u003e-wrapped-ast',\n  plugins: ['prettier-plugin-js-hack-pipes-wrapper'],\n});\n```\n\n## Configuration\n\n### Babel Configuration\n\nConfigure the pipeline operator plugin in your Babel config with your preferred topic token:\n\n```json\n{\n  \"plugins\": [\n    [\n      \"@babel/plugin-proposal-pipeline-operator\",\n      { \"proposal\": \"hack\", \"topicToken\": \"#\" }\n    ]\n  ]\n}\n```\n\n### Supported Topic Tokens\n\nThe plugin supports any topic token that Babel's pipeline operator plugin accepts:\n\n- `%` (default)\n- `^^`\n- `@@`\n- `^`\n- `#`\n\n## Examples\n\n**Input:**\n\n```javascript\n'Pipeline operator test' |\u003e #.length |\u003e console.log(#);\n```\n\n**Formatted output:**\n\n```javascript\n'Pipeline operator test' |\u003e #.length |\u003e console.log(#);\n```\n\n## Babel Configuration Loading\n\nThe plugin has three potential methods for attempting to load the relevant Babel configuration file. See `/src/babel-options-loader` for an explanation.\n\nIf no Babel configuration is found or no pipeline operator plugin is configured, the plugin falls back to Prettier's default `%` topic token.\n\n## Compatibility\n\n- **Prettier**: tested with 3.6.2\n- **Babel**: tested with 7.28.4\n\n## Architecture\n\nThis plugin vendors specific portions of Prettier's source code via git submodules to modifiy Prettier's 'babel' JavaScript parser and 'estree' printer with minimal changes. This approach:\n\n- Makes the required changes explicit and demonstrable\n- Provides a working solution for reference in discussion about/proposal for Prettier contribution\n\n## Known Issues\n\n- Currently only supports `.js` files\n- Currently reads the babel configuration during each parse:\n  - What is the best way to cache this information?\n  - Is it possible to gain access to the codebase's working directory at initialisation?\n  - Could a user have multiple babel configurations in different parts of their project that would need separate handling?\n    - Would this indicate it is better to depend on babel for config parsing?\n- No bundling/packaging at this stage, must be run locally\n- Minimal tests and verification at this stage\n\n## Related\n\n- [TC39 Pipeline Operator Proposal](https://github.com/tc39/proposal-pipeline-operator)\n- [@babel/plugin-proposal-pipeline-operator](https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator)\n- [Prettier Plugin API](https://prettier.io/docs/plugins.html)\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frich-27%2Fprettier-plugin-js-hack-pipes-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frich-27%2Fprettier-plugin-js-hack-pipes-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frich-27%2Fprettier-plugin-js-hack-pipes-wrapper/lists"}