plus is noe defined

以下方法已经弃用,请跳转至标 https://www.cnblogs.com/biuo/p/15311918.html

一、在根目录下创建文件.eslintrc

plus is noe defined

二、复制默认代码进去

{
  "extends": [
    "eslint:recommended",
    "plugin:import/errors",
    "plugin:import/warnings"
  ],
  "plugins": [
    "react"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "jquery": true,
    "mocha": true
  },
  "settings": {
    "import/ignore": [
      "node_modules"
    ]
  },
  "rules": {
    "no-unused-vars": "off",
    "no-console": "off",
    "no-debugger": "off",
    "no-mixed-spaces-and-tabs": "off"
  }
}

三、把万恶的‘plus’加到文档中去

不一定是‘plus' 你觉得不关你事的not defined报错都可以放进去

"globals":{
  "plus": true,
}

也就是说 .eslintrc的代码如下

{
  "extends": [
    "eslint:recommended",
    "plugin:import/errors",
    "plugin:import/warnings"
  ],
  "plugins": [
    "react"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "jquery": true,
    "mocha": true
  },
  "settings": {
    "import/ignore": [
      "node_modules"
    ]
  },
  "rules": {
    "no-unused-vars": "off",
    "no-console": "off",
    "no-debugger": "off",
    "no-mixed-spaces-and-tabs": "off"
  },
  "globals":{
    "plus":true
  }
}

四、在package.json文件里面配置scripts的lint属性

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "link":"eslint src"
  },

五、运行检测

npm lint 或者 npm run lint

六、重启项目 完工!!!

上一篇:7.17学习内容


下一篇:mysql数据库 入门基础