yarn add -D eslint babel-eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react
yarn add --save-dev prettier eslint-plugin-prettier eslint-config-prettier
yarn add -D husky lint-staged pretty-quick
二、eslintrc配置
{ "parser": "babel-eslint", "env": { "browser": true }, "extends": ["standard", "prettier", "plugin:react/recommended"], "plugins": ["react", "react-hooks"], "globals": { "_debug": "readonly", "_": "readonly", "__USE_REPORT__": "readonly" }, "rules": { "comma-dangle": [2, "never"], "no-debugger": 0, "quotes": 0, "semi": 0, "indent": 0, "keyword-spacing": 0, "handle-callback-err": 0, "no-undef": 2, "eol-last": 0, "accessor-pairs": 0, "no-empty-character-class": 0, "no-func-assign": 0, "no-throw-literal": 0, "no-useless-computed-key": 0, "no-mixed-operators": 0, "space-before-function-paren": 0, "no-unused-vars": 1, "no-extra-semi": 0, "jsx-a11y/no-distracting-elements": 0, "jsx-a11y/iframe-has-title": 0, "jsx-a11y/aria-activedescendant-has-tabindex": 0, "jsx-a11y/anchor-is-valid": 0, "react/jsx-no-comment-textnodes": 0, "jsx-a11y/alt-text": 0, "jsx-a11y/accessible-emoji": 0, "react/style-prop-object": 0, "react/no-danger-with-children": 0, "react/display-name": 0, "react/no-danger": 0, "react/prop-types": 0, "react/no-did-mount-set-state": 0, "react/jsx-no-duplicate-props": 0, "jsx-a11y/anchor-has-content": 0, "react/forbid-foreign-prop-types": 0, "jsx-a11y/no-redundant-roles": 0, "react-hooks/rules-of-hooks": "error", "react-hooks/exhaustive-deps": 0, "camelcase": 0 }, "parserOptions": { "ecmaFeatures": { "legacyDecorators": true } }}