Skip to content

Instantly share code, notes, and snippets.

@kevinah95
Last active November 1, 2023 05:25
Show Gist options
  • Save kevinah95/328a181730e9f48a91b204346d480305 to your computer and use it in GitHub Desktop.
Save kevinah95/328a181730e9f48a91b204346d480305 to your computer and use it in GitHub Desktop.

Add eslint and prettier

https://eslint.org/blog/2023/10/deprecating-formatting-rules/

$ npm init @eslint/config
✔ How would you like to use ESLint? · problems
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · react
✔ Does your project use TypeScript? · No / Yes
✔ Where does your code run? · browser
✔ What format do you want your config file to be in? · JavaScript
The config that you've selected requires the following dependencies:

@typescript-eslint/eslint-plugin@latest eslint-plugin-react@latest @typescript-eslint/parser@latest
✔ Would you like to install them now? · No / Yes
✔ Which package manager do you want to use? · yarn

$ yarn add -D prettier
node --eval "fs.writeFileSync('.prettierrc','{}\n')"

{

    "tabWidth": 2,
    "semi": true,
    "singleQuote": true,
    "arrowParens": "avoid"
}

$ yarn add -D eslint-config-prettier

$ yarn prettier . --write

Install prettier oficial extension

Add config to User Settings

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment