Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Prettier + ESLint + custom or famous Style Guide ###
- Initial configuration for Prettier as formatter, ESLint with your favorite Style Guide<br />
- as a linter and a hook script that will never let you commit un-formatted code.
- _This guide assumes you're using Standard style guide and Git as versioning system._
- #### devDependencies ####
- ```
- npm init -y
- npm i -DE prettier
- npm i -D eslint eslint-plugin-prettier eslint-config-prettier pretty-quick husky
- ```
- #### ESLint ####
- ```
- node_modules/eslint/bin/eslint.js --init
- ```
- then...<br />
- ```
- -> Use a popular style guide
- -> Standard
- -> Config file format? choose your favorite (for instance, Javascript)
- ```
- If you selected Airbnb, then you were asked if you're using React.<br />
- When choosing yes, you don't need to add anyhing extra, otherwise,<br />
- for using React with Standard you need to install the following as well:
- ```
- npm i -D eslint-config-standard-react eslint-plugin-react
- ```
- .eslint.* should look like so:
- ```
- {
- "extends": ["standard", "plugin:prettier/recommended"]
- }
- # for React add "standard-react" just after "standard"
- OR
- {
- "extends": ["airbnb-base", "plugin:prettier/recommended"]
- }
- # it will be just "airbnb" when using React
- ```
- Note: we omitted the eslint-config- prefix since it is automatically assumed by ESLint.
- #### Git Hook Script ####
- now add a script for applying prettier before every commit
- ```
- "precommit": "pretty-quick --staged"
- ```
Add Comment
Please, Sign In to add comment