Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Merge requests
  • !862

Implement prettier

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/mxstbr/prettier into master Feb 16, 2018
  • Overview 4
  • Commits 4
  • Pipelines 0
  • Changes 42

Created by: mxstbr

Prettier is an automatic code formatting tool (similar to gofmt in go) which takes care of handling code style for us. Adding it to the repository should mean new contributors can come on board more easily because they don't have to care about writing in a consistent code style, they can just focus on their code and prettier will make sure it's formatted consistently with the rest of the code. (see the prettier website for more information)

This PR has four parts:

  1. Set up prettier as a pre-commit hook (36ec5b70): With lint-staged and husky prettier now runs before contributors commit. This means everybody can write their code in whatever code style they want, but as soon as they commit it's reformatted to conform the the shared style of the codebase.
  2. Enforce prettier style in CI (95eef4cf): Altough it runs as a precommit hook and thusly all code is formatted, folks could on purpose disable the precommit hook, then commit without reformatting, and then submit a PR. By running prettier in CI with --list-different CI will fail if folks do this, in effect enforcing prettier's code style.
  3. Disable the stylistic eslint rules (eb7e37e5): Since prettier now enforces a consistent code style, there's no reason to enforce that again from eslint. I've disabled all stylist eslint rules (e.g. semi), but left all the error catching ones in place. (e.g. no-unused-variables)
  4. Run prettier over the entire codebase to get a consistent style (e3bcce65)

FWIW, we've added prettier to styled-components and react-boilerplate and have had 0 complaints overall. It's been a huge success and has made our life much easier, on top of never having to say "Hey, CI failed because you forgot a semicolon. Please add that and push again.". It's amazing and I'd love to have that in bull so folks can contribute to this amazing project more easily.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/mxstbr/prettier