应用程序。我需要为此应用程序使用 eslint。我正在使用 https://www.npmjs.com/package/eslint-config-airbnb 并在 VS 代码编辑器中使用更漂亮的插件。
.eslintrc
{
"extends": "airbnb"
}
我看到在添加 eslint 插件 https://marketplace.visualstudio.comitems?itemName=dbaeumer.vscode-eslint 和 npm 包后,VS Code 现在在整个项目中给我很多错误。
很少有错误
[eslint] Definition for rule 'jsx-a11y/href-no-hash' was not found (jsx-a11y/href-no-hash)
[eslint] Expected linebreaks to be 'LF' but found 'CRLF'. (linebreak-style)
[eslint] Unexpected unnamed function. (func-names)
[eslint] Missing space before function parentheses. (space-before-function-paren)
[eslint] Strings must use singlequote. (quotes)
[eslint] Unexpected function expression. (prefer-arrow-callback)
[eslint] Unexpected unnamed function 'bind'. (func-names)
[eslint] Missing space before function parentheses. (space-before-function-paren)
包.json
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.5.1",
"babel-core": "^6.9.0",
"babel-eslint": "^7.2.3",
"babel-preset-es2015": "^6.5.0",
"babel-preset-stage-0": "6.5.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
"nodemon": "^1.12.1"
}
索引.js
import request from "superagent";
module.exports = function(req, res, next) {
const id = "abc";
request
.post(url)
.send(`p1=v1`)
.send(`p2=v2`)
.end(function(error, response) {}.bind(this));
next();
};
每个 JS 文件中的错误类型相同。有谁知道如何解决这些问题?
原文由 N Sharma 发布,翻译遵循 CC BY-SA 4.0 许可协议
devDependencies
使用:eslintConfig
部分添加到您的package.json
:访问 eslint.org/docs/rules ,搜索您想要调整的警告并将它们添加到上面的
eslintConfig
中。删除项目根目录中的
.eslintrc
文件。5)重新启动你的IDE