Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ESLint, Prettier & Airbnb Setup

VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
npx install-peerdeps --dev eslint-config-airbnb

3. Create .prettierrc for any prettier rules (semicolons, quotes, etc)

4. Create .eslintrc.json file (You can generate with eslint --init if you install eslint globally)

{
  "extends": ["airbnb", "prettier", "plugin:node/recommended"],
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": "error",
    "no-unused-vars": "warn",
    "no-console": "off",
    "func-names": "off",
    "no-process-exit": "off",
    "object-shorthand": "off",
    "class-methods-use-this": "off"
  }
}

Reference

@SwiftWinds
Copy link

SwiftWinds commented Dec 27, 2019

Feel free to use https://github.com/paulolramos/eslint-prettier-airbnb-react, which does this whole process automatically via shell script! :)

@peidrao
Copy link

peidrao commented Mar 7, 2020

good man!

@richwag
Copy link

richwag commented May 24, 2020

This is excellent. and thanks to SwiftWinds for making this super easy.

@SwiftWinds
Copy link

SwiftWinds commented May 25, 2020

This is excellent. and thanks to SwiftWinds for making this super easy.

No problem! :D

@LucasAsafe
Copy link

LucasAsafe commented Jul 9, 2020

Tnx, mate!

@blyatmobilebr-zz
Copy link

blyatmobilebr-zz commented Aug 9, 2020

thank you!

@bryeduria
Copy link

bryeduria commented Aug 21, 2020

For those of you who do not want the React plugins in the peerdeps, you can also use:

npx install-peerdeps --dev eslint-config-airbnb-base

@adongu
Copy link

adongu commented Aug 29, 2020

Feel free to use https://github.com/paulolramos/eslint-prettier-airbnb-react, which does this whole process automatically via shell script! :)

Good man

@roei133
Copy link

roei133 commented Oct 15, 2020

Hi, why the code not fix auto when i press save in the vscode ? its should fix me the code and its not .

@fatihemree
Copy link

fatihemree commented Nov 3, 2020

Thanks

@DNI9
Copy link

DNI9 commented Nov 3, 2020

thank you magic man

@ionicArabic
Copy link

ionicArabic commented Nov 28, 2020

Good work. Finally I have Prettier working with VS code

@ahhzaky
Copy link

ahhzaky commented Mar 27, 2021

Thank you😊

@Suyash-Purwar
Copy link

Suyash-Purwar commented Apr 27, 2021

Thanks Brad

@MageshSundarG
Copy link

MageshSundarG commented May 5, 2021

Thanks a lot

@grah48583
Copy link

grah48583 commented May 18, 2021

thank you very much
but i had a question.

Do i have to do this every time or i can set all this settings globally?

@christopherafbjur
Copy link

christopherafbjur commented Jun 3, 2021

Created a npm package which bootstraps this setup to your VSCode project. Can either be installed globally or run through npx:
npx setup-airbnb-config ./yourProjectFolder. Supports both vanilla JS and React. Feel free to use it. Contributions are welcome!

https://www.npmjs.com/package/setup-airbnb-config

@Costas-Zeimpekis
Copy link

Costas-Zeimpekis commented Jun 16, 2021

Thank you Brad, very useful

@goacgras
Copy link

goacgras commented Jun 17, 2021

my prettier says No local configuration (i.e. .prettierrc or .editorconfig) detected, falling back to VS Code configuration. How do i override my vscode prettier config to this?

@AdamShamsadov
Copy link

AdamShamsadov commented Sep 29, 2021

hey,
the terminal does not trow an arrow for me when i use double quotes ...
tried googling it and found somthing like "turn 'jsxSingleQuote':true" but it didnt do anything aither...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment