Guest User

Untitled

a guest
May 25th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. ### Prettier + ESLint + custom or famous Style Guide ###
  2.  
  3. Initial configuration for Prettier as formatter, ESLint with your favorite Style Guide<br />
  4. as a linter and a hook script that will never let you commit un-formatted code.
  5.  
  6. _This guide assumes you're using Standard style guide and Git as versioning system._
  7.  
  8. #### devDependencies ####
  9. ```
  10. npm init -y
  11. npm i -DE prettier
  12. npm i -D eslint eslint-plugin-prettier eslint-config-prettier pretty-quick husky
  13. ```
  14.  
  15. #### ESLint ####
  16. ```
  17. node_modules/eslint/bin/eslint.js --init
  18. ```
  19. then...<br />
  20. ```
  21. -> Use a popular style guide
  22. -> Standard
  23. -> Config file format? choose your favorite (for instance, Javascript)
  24. ```
  25. If you selected Airbnb, then you were asked if you're using React.<br />
  26. When choosing yes, you don't need to add anyhing extra, otherwise,<br />
  27. for using React with Standard you need to install the following as well:
  28. ```
  29. npm i -D eslint-config-standard-react eslint-plugin-react
  30. ```
  31.  
  32. .eslint.* should look like so:
  33. ```
  34. {
  35. "extends": ["standard", "plugin:prettier/recommended"]
  36. }
  37. # for React add "standard-react" just after "standard"
  38.  
  39. OR
  40.  
  41. {
  42. "extends": ["airbnb-base", "plugin:prettier/recommended"]
  43. }
  44. # it will be just "airbnb" when using React
  45. ```
  46. Note: we omitted the eslint-config- prefix since it is automatically assumed by ESLint.
  47.  
  48. #### Git Hook Script ####
  49.  
  50. now add a script for applying prettier before every commit
  51. ```
  52. "precommit": "pretty-quick --staged"
  53. ```
Add Comment
Please, Sign In to add comment