Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 977 Bytes

Setting Up Prettier with Github Actions.md

File metadata and controls

42 lines (33 loc) · 977 Bytes

Setting Up Prettier

Do we need to set up Prettier now? No. Do I want an excuse to have you write your own Github Action? Yes. So, here we are.

npm install -D prettier

You can configure it however you want. You don't even have to configure it, frankly. As of right now, this is what my .prettierrc file looks like:

{
  "printWidth": 80,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "all",
  "bracketSpacing": true,
  "bracketSameLine": false
}

Let's also make our lives easier and add some commands to package.json:

{
  //…
  "scripts": {
    //…
    "format:check": "prettier . --check --ignore-path .gitignore",
    "format:fix": "prettier . --check --ignore-path .gitignore"
  }
  //…
}

Exercise

Can you add a job that checks the formatting of PRs against main?

You can see a solution Setting Up Prettier Solution.