.js 应用程序。我需要为此应用程序使用 eslint。我正在使用https://www.npmjs.com/package/eslint-config-airbnb并在 VS Code 编辑器中使用更漂亮的插件。
.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"
}
index.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 文件中都有相同类型的错误。有谁知道如何解决这些问题?