Format code in GitHub comments with Prettier
This is the recommended and easiest installation method. Install the Prettier GitHub app to some or all of your repos.
- or 
- Setup
- Register a GitHub app
- Use whatever makes sense for you for App name, Description, Homepage URL and User authorization callback URL; leave Setup URL empty
- Set Webhook URL to your deployment URL, for example https://prettier-github.herokuapp.com/
- Set a Webhook secret and note it down
- Select Read & write access for Issues, Pull requests and Repository contents
- For Issues and Pull requests, check all Webhook checkboxes; for Repository contents, check only Commit comment
- Click on Create GitHub app
- Click on Generate private key and save the downloaded file
- Note down the app ID (displayed under your username in the right column)
 
- Configure environment variables of your deployment
- Set GITHUB_KEYto the downloaded private key
- Set GITHUB_IDto the app ID
- Set GITHUB_WEBHOOK_SECRETto the Webhook secret you configured
 
- Set 
Whenever someone includes a JavaScript code block in a comment, it will be formatted using Prettier.
You can disable formatting per-comment by writing <!-- prettier-github disable --> anywhere in the comment (except code blocks)
Due to lacking GitHub APIs, Prettier GitHub currently doesn't format reviews, review comments and commit comments. See #11
Prettier GitHub will use the prettier field in the package.json of the respective repository for configuration. See Prettier's readme for available options. Additionally, you can set langs to an array specifying which languages should be formatted.
package.json:
{
	...
	"prettier": {
		"singleQuote": true,
		"useTabs": true,
		"langs": [
			"js",
			"javascript"
		]
	}
	...
}This will enforce single quotes and tabs, and will only format code blocks marked as js or javascript.
- Generate personal access token with the repo scope for your GitHub account
- Install ngrok for localhost tunnelling
- Run ngrok http 3000and note down the URL, for examplehttp://2ab92a92.ngrok.io
- Set up a webhook for your testing repo
- Set Payload URL to the ngrok URL
- Set Content type to application/json
- Set a Secret and note it down
- Select Let me select individual events; then check Commit comment, Issue comment, Issues, Pull request, Pull request review and Pull request review comment and uncheck Push
 
- Copy .env.example- Set GITHUB_TOKENto the personal access token generated earlier
- Set GITHUB_WEBHOOK_SECRETto the Webhook secret you configured
 
- Set 
- Run npm installand thennpm start
MIT

