# Contributing to @destination/prettier-plugin-twig Requirements: - Node v16+ - pnpm ``` git clone git@github.com:wearedestination/prettier-plugin-twig.git pnpm install pnpm test ``` ## Context There's a lot of abstract concepts that goes into making this plugin. - Take a look at our plugin's [principles](./docs/principles/index.md). - Read [HOW_IT_WORKS.md](HOW_IT_WORKS.md) for a technical overview. - Read [Whitespace Handling](./docs/whitespace-handling.md) for an overview of how we deal with that internally. The source code for this plugin is in TypeScript. ## Standards - PR should explain what the feature does, and why the change exists. - PR should include any carrier specific documentation explaining how it works. - Code should be generic and reusable. ## Formatting This plugin uses prettier to format its TypeScript codebase. To format your code before a commit, run the following command: ``` pnpm format ``` ## Testing This prettier plugin has two kinds of tests: unit tests (in `src/`) and integration tests (in `test/`, where we make sure an input file gets transformed into another after running prettier). To run all tests: ```bash pnpm test ``` To run only one of the two kinds: ```bash # unit tests pnpm mocha 'src/**/*.spec.ts' # integration tests pnpm mocha 'test/**/*.spec.ts' ``` To run the idempotence tests (where we make sure running prettier twice on an input file returns the same result): ```bash pnpm test:idempotence ``` ### Adding new integration tests - Copy any of the folders in the `test/` directory and rename it to something appropriate. - In the `index.html.twig` file, type code that should be made prettier - In the `fixed.html.twig` file, type what you'd expect the plugin to output ## Running from source on another code base ```bash # build the code so you can run it (re-run after every source change) pnpm build # run prettier on a file or folder pnpm prettier --write path/to/files.html.twig ``` ## How to contribute 1. Fork it ( https://github.com/wearedestination/prettier-plugin-twig/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request