- I like the formatting capabilities of
prettier
- I don't like that
prettier
won't allowfunc-calling-spacing
andarray-bracket-spacing
- This repo shows how to get the best features of
prettier
without sacrificing customisability witheslint
prettier
- used to format non-javascript fileseslint
- used to lint and format code for errorsprettier-eslint
- format code withprettier
then auto-fix errors witheslint
prettier-eslint-cli
- prettier eslint does not work from the command line out of the boxbabel-eslint
- the parser used to parse Javascript files. This could be replace with a parser of your choice.
- Install the required packages -
npm install
- Open
src/index.js
- Notice the func call spacing
- Edit the file to see that
prettier
is formatting the document andeslint
is maintaining thefunc-call-spacing
- There is a
npm
script inpackage.json
showing how to add this as a CI step
- The extensions I am using to format my code each time I save are:
prettier
- format JSON fileseslint
- lint Javascript filesprettier-eslint
- runs each time I save to format and lint Javascript files
- The
.vscode/settings.json
file triggersprettier-eslint
to run on save of Javascript files andprettier
to run on the save of JSON files. These settings are project specific and will take precedence over your generic User settings
- The
npm
scriptformat
is currently formatted in a strange way
"format": "prettier-eslint --write $PWD/\"src/**/*.js\""
- This is required due to this issue
- The issue should be solved shortly, as a pull request is pending
- If you are on Windows, you will have to reduce your version of
eslint
to6.0.0