Skip to content

Instantly share code, notes, and snippets.

@itkrt2y
Last active February 22, 2021 01:03
Show Gist options
  • Save itkrt2y/9e2db9a6f27dbc0fa3749b9bc4e49001 to your computer and use it in GitHub Desktop.
Save itkrt2y/9e2db9a6f27dbc0fa3749b9bc4e49001 to your computer and use it in GitHub Desktop.
VSCode + TypeScript + ESLint + Prettier + React
/** @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" } }
};
// .vscode/settings.json
{
"editor.codeActionsOnSave": ["source.fixAll"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
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