设置ESLint

设置ESLint

  1. 安装组件

    npm i eslint prettier eslint-config-prettier eslint-plugin-prettier  eslint-config-airbnb eslint-plugin-node eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react --save-dev
    
  2. 设置规则

    控制off,warn,error
    具体参数设置可以参考官方文档,报错的时候vscode有直接跳转的

    {
      "extends": ["airbnb", "prettier", "plugin:node/recommended"],
      "plugins": ["prettier"],
      "rules": {
        "prettier/prettier": ["error", {}],
        "spaced-comment": "off",
        "no-console": ["warn", { "allow": ["log"], "no-semi": true }],
        "consistent-return": "off",
        "func-names": "off",
        "object-shorthand": "off",
        "no-process-exit": "off",
        "no-param-reassign": "off",
        "no-return-await": "off",
        "no-underscore-dangle": "off",
        "class-methods-use-this": "off",
        "prefer-destructuring": ["error", { "object": true, "array": false }],
        "no-unused-vars": ["error", { "argsIgnorePattern": "req|res|next|val|err" }]
      }
    }
    
    
posted @ 2022-06-22 01:12  kihyun  阅读(61)  评论(0编辑  收藏  举报