Skip to content

Instantly share code, notes, and snippets.

@mikemfleming
Last active January 24, 2022 03:18
Show Gist options
  • Save mikemfleming/30d5da22bb5c2e8fc47d785ebda877d8 to your computer and use it in GitHub Desktop.
Save mikemfleming/30d5da22bb5c2e8fc47d785ebda877d8 to your computer and use it in GitHub Desktop.

Prettier and Eslint for code quality

Heavily inspired by Dan Abramov.

Problem

How to write less error-prone code in a way that supports collaboration with a large team.

Proposal

Following these steps won't catch everything but it will catch a lot of things and before they're even committed to VC.

  • Use Prettier to enforce code style. Prettier will fix issues automatically and silently.
  • Use ESlint to catch possible mistakes in the code before they get commited.
    • Configure some rules to autofix and others to require dev intervention
  • Apply these rules on a precommit hook.

Use Prettier to fix things related to code style

  • whitespace
  • semicolons
  • line length

Use ESlint to catch things that might be mistakes

Here are some example rules that I've found to be helpful on previous collaborations.

Critical rules

Non-critical rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment