Skip to content

Instantly share code, notes, and snippets.

@ivanbtrujillo
Last active January 23, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanbtrujillo/cfc02d32d198ddf6953b1b2e43d6d290 to your computer and use it in GitHub Desktop.
Save ivanbtrujillo/cfc02d32d198ddf6953b1b2e43d6d290 to your computer and use it in GitHub Desktop.
Prettier + ESLint en VSCode

En este Gist explico como configurar prettier y eslint en VSCode para que prettier use las reglas de nuestro .eslintrc.json y formatee nuestro codigo en base a esas reglas.

Dependencias

Instalar como dev-dependencies estas dependencias o versiones superiores:

"prettier": "^1.10.2", "prettier-eslint": "^8.8.1"

Configuracion en VSCode

Instalar la extension de VSCode Prettier - Code Formatter (Esben Petersen)

Abrir la configuracion de VSCode (Preferences > Open User Settings o Ctrl + ,) y:

  • Habilitas que formatee el codigo cuando lo guardes: "editor.formatOnSave": true
  • Le dices a prettier que formatee el codigo usando la config de esLint: "prettier.eslintIntegration": true

Formatear el codigo solo cuando se presione un shorcut

  1. Configurar el user settings de VScode asi:

"editor.formatOnPaste": true, "editor.formatOnSave": true, "editor.formatOnType": true,

  1. Para formatear el codigo cuando quieras: CTRL+SHIFT+I
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment