{"id":16374447,"url":"https://github.com/azz/prettier-transform","last_synced_at":"2025-03-23T03:32:38.777Z","repository":{"id":57330070,"uuid":"105243744","full_name":"azz/prettier-transform","owner":"azz","description":"Perform AST transforms before running prettier","archived":false,"fork":false,"pushed_at":"2017-09-29T12:05:31.000Z","size":48,"stargazers_count":23,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T12:16:48.030Z","etag":null,"topics":["ast","prettier","transform"],"latest_commit_sha":null,"homepage":null,"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/azz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-29T07:35:53.000Z","updated_at":"2024-07-04T13:09:10.000Z","dependencies_parsed_at":"2022-08-29T04:31:11.177Z","dependency_job_id":null,"html_url":"https://github.com/azz/prettier-transform","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fprettier-transform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fprettier-transform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fprettier-transform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fprettier-transform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azz","download_url":"https://codeload.github.com/azz/prettier-transform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245052619,"owners_count":20553161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ast","prettier","transform"],"created_at":"2024-10-11T03:17:16.349Z","updated_at":"2025-03-23T03:32:38.475Z","avatar_url":"https://github.com/azz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prettier-transform\n[![Travis](https://img.shields.io/travis/azz/prettier-transform.svg?style=flat-square)](https://travis-ci.org/azz/prettier-transform)\n[![Prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![npm](https://img.shields.io/npm/v/prettier-transform.svg?style=flat-square)](https://npmjs.org/prettier-transform)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\n\n## Install\n\n```bash\nyarn add --dev prettier-transform\n```\n\n## Usage with prettier\n\nAdd to your prettier configuration file (`.prettierrc`):\n\n```json\n{\n  \"transform\": {\n    \"parser\": \"babylon\",\n    \"transforms\": [\n      \"./my-transform\"\n    ]\n  }\n}\n```\n\nThen invoke prettier using the parser API:\n\n```bash\nprettier --parser ./node_modules/prettier-transform --write \"**/*.js\"\n```\n\nIf you want to do different transforms for different files, you can make use of\nprettier's `overrides` configuration:\n\n```json\n{\n  \"overrides\": [\n    {\n      \"files\": \"*.jsx\",\n      \"options\": {\n        \"transform\": {\n          \"parser\": \"babylon\",\n          \"transforms\": [\"./transform-a\", \"./transform-b\"]\n        }\n      }\n    }\n  ]\n}\n```\n\n## Writing Transforms\n\nTransforms must be standard JavaScript modules that export a function that takes\nan AST and returns an AST.\n\nIf you're working with a babylon-produced AST, you can do the following:\n\n```js\nconst traverse = require(\"babel-traverse\").default;\n\nmodule.exports = ast =\u003e {\n  traverse(ast, {\n    Identifier(path) {\n      if (path.node.name === \"foo\") {\n        path.node.name = \"bar\";\n      }\n    }\n  });\n  return ast;\n};\n```\n\n## API Usage\n\nBasic usage:\n\n```js\nconst prettierTransform = require(\"prettier-transform\");\nconst myTransform = require(\"./my-transform\");\n\nprettierTransform.format(\"foo()\", [myTransform], { parser: \"babylon\" });\n```\n\nPass options to prettier:\n\n```js\nprettierTransform.format(\"foo()\", [myTransform], {\n  parser: \"babylon\",\n  semi: false\n});\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Fprettier-transform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazz%2Fprettier-transform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Fprettier-transform/lists"}