Last active
December 12, 2019 17:13
-
-
Save claudiobusatto/84b400c434ff6a524ea53a7cb01e96cd to your computer and use it in GitHub Desktop.
Include Prettier, ESLint and Airbnb code style to a NodeJS project on Visual Studio Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This gist is based on https://blog.echobind.com/integrating-prettier-eslint-airbnb-style-guide-in-vscode-47f07b5d7d6a | |
# Download the ESLint and Prettier extensions for VSCode. | |
code --install-extension esbenp.prettier-vscode | |
code --install-extension dbaeumer.vscode-eslint | |
# Install the ESLint and Prettier libraries into our project. In your project’s root directory, you will want to run: | |
npm install -D eslint prettier | |
# Install the Airbnb config. If you’re using npm 5+, you can run this shortcut to install the | |
# config and all of its dependencies: | |
npx install-peerdeps --dev eslint-config-airbnb-base | |
# Install eslint-config-prettier (disables formatting for ESLint) and eslint-plugin-prettier | |
# (allows ESLint to show formatting errors as we type) | |
npm install -D eslint-config-prettier eslint-plugin-prettier eslint-plugin-import | |
# Create .eslintrc.json file in your project’s root directory: | |
echo '{"extends": ["airbnb-base", "prettier"],"plugins": ["prettier"],"rules": {"prettier/prettier": ["error"]}}' > .eslintrc.json | |
# Create a prettier rc file | |
echo '{"trailingComma": "es5","tabWidth": 2,"semi": true,"printWidth": 100,"singleQuote": true}' > .prettierrc | |
# The last step is to make sure Prettier formats on save. | |
# Include the line on your VSCode configuration: "editor.formatOnSave": true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment