Skip to content

Instantly share code, notes, and snippets.

@kembek
Last active January 24, 2021 13:11
Show Gist options
  • Select an option

  • Save kembek/9554d036d84c29263031647e2d871520 to your computer and use it in GitHub Desktop.

Select an option

Save kembek/9554d036d84c29263031647e2d871520 to your computer and use it in GitHub Desktop.
ESLint
node_modules/
.eslintrc.js
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
env: {
browser: true,
node: true,
},
plugins: ['simple-import-sort'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'error',
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'jsx-a11y/anchor-is-valid': [
'error',
{
components: ['Link'],
specialLink: ['hrefLeft', 'hrefRight'],
aspects: ['invalidHref', 'preferButton'],
},
],
},
};

List of packages to install:

  • typescript
  • @types/node
  • @types/react
  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/parser
  • eslint
  • eslint-config-prettier
  • eslint-plugin-jsx-a11y
  • eslint-plugin-prettier
  • eslint-plugin-react
  • eslint-plugin-react-hooks
  • eslint-plugin-simple-import-sort
  • prettier

Commands:

Install - npm install --save-dev typescript @types/node @types/react @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-simple-import-sort prettier

Fix lint errors - eslint --fix . --ignore-path ./.gitignore

Format - prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc

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