Basically, when using Prettier, all ESLint styling rules should be disabled.
This can be done with eslint-config-prettier.
See .eslintrc.js
example below.
In prettier.config.js
you can use anything you want (see example below).
Now the tricky part is how to run them...
Usually ESLint should run first, then Prettier.
That way any code changes by ESLint will be pass through Prettier as well.
Only use the opposite if you want ESLint to re-format something the conflicts with Prettier formatting.
In the package.json
example below:
husky
- Sets up git hooks when younpm install
, in this case apre-commit
hook.lint-staged
- Allows to run commands only on staged files/chunks in Git (i.e. only what yougit add
).
Also, if you currently have styling rules in .eslintrc.js
, you'll need to remove them.
How to find them?
Use the eslint-config-prettier - cli-helper-tool.
See lint:eslint-config-prettier
in package.json
below.
For more ESLint setup inspiration, see my own ESLint configs:
eslint-config-ai