Last active
February 22, 2021 01:03
-
-
Save itkrt2y/9e2db9a6f27dbc0fa3749b9bc4e49001 to your computer and use it in GitHub Desktop.
VSCode + TypeScript + ESLint + Prettier + React
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
/** @type import("eslint").Linter.Config */ | |
module.exports = { | |
env: { browser: true, node: true }, | |
parser: '@typescript-eslint/parser', | |
extends: [ | |
"eslint:recommended", | |
"plugin:@typescript-eslint/recommended", | |
"plugin:import/errors", | |
"plugin:import/warnings", | |
"plugin:react/recommended", | |
"plugin:react-hooks/recommended", | |
"prettier", | |
], | |
rules: { | |
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], | |
"react/prefer-stateless-function": "error", | |
"import/order": ["error", { alphabetize: { order: "asc" } }], | |
// https://github.com/basarat/typescript-book/blob/master/docs/tips/defaultIsBad.md | |
// https://twitter.com/dan_abramov/status/1255229440860262400 | |
"import/no-default-export": "error", | |
}, | |
settings: { react: { version: "detect" } } | |
}; |
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
// .vscode/settings.json | |
{ | |
"editor.codeActionsOnSave": ["source.fixAll"], | |
"editor.defaultFormatter": "esbenp.prettier-vscode", | |
"editor.formatOnSave": true | |
} |
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
yarn add -D \ | |
@typescript-eslint/eslint-plugin \ | |
@typescript-eslint/parser \ | |
prettier \ | |
eslint \ | |
eslint-config-prettier \ | |
eslint-plugin-react \ | |
eslint-plugin-react-hooks \ | |
eslint-plugin-import |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Next.js example https://github.com/vercel/next.js/blob/canary/examples/with-typescript-eslint-jest/.eslintrc.json