Skip to content

Instantly share code, notes, and snippets.

@xiangaoole
Last active October 10, 2020 01:28
Show Gist options
  • Save xiangaoole/f02d44497702bf6c6231f5737a741087 to your computer and use it in GitHub Desktop.
Save xiangaoole/f02d44497702bf6c6231f5737a741087 to your computer and use it in GitHub Desktop.
Config eslint for better lint hint in VSCode
env:
browser: true
commonjs: true
es6: true
extends:
- airbnb
- prettier
#parser:
parserOptions:
ecmaVersion: 12
plugins:
- prettier
rules:
prettier/prettier:
- 1
- singleQuote: true
no-unused-vars: 1
camelcase: 1
func-names: 0
no-use-before-define: 0
no-shadow: 0
no-restricted-globals: 1
no-nested-ternary: 1
no-underscore-dangle: 1
no-plusplus: ['error', { 'allowForLoopAfterthoughts': true }]
no-param-reassign: ['error', { 'props': false }]

You should install this modules:

  • eslint : for eslint
  • prettier : for prettier
  • eslint-config-prettier : Turns off all rules that are unnecessary or might conflict with Prettier.
  • eslint-plugin-prettier : Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.
yarn add eslint --dev
yarn add prettier --dev
yarn add eslint-config-prettier --dev
yarn add eslint-plugin-prettier --dev

After yarn run eslint --int, there may hints you to install several modules:

The config that you've selected requires the following dependencies:

eslint-plugin-react@^7.20.0 eslint-config-airbnb@latest eslint@^5.16.0 || ^6.8.0 || ^7.2.0 eslint-plugin-import@^2.21.2 eslint-plugin-jsx-a11y@^6.3.0 eslint-plugin-react-hooks@^4 || ^3 || ^2.3.0 || ^1.7.0

You can add them manually:

yarn add --dev eslint-plugin-react eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react-hooks

For react native project:

extends:
  - airbnb
  - prettier
  - prettier/react
parserOptions:
  ecmaFeatures:
    jsx: true
rules:
  react/jsx-filename-extension:
    - 1
    - extensions: ['.js', '.jsx']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment