0

包 devDependencies:

"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.1",
"babel-preset-flow": "^6.23.0",
"eslint": "^5.9.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-flowtype": "^3.2.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"nodemon": "^1.18.7"

.eslitrc 文件:

module.exports = {
  "extends": [
    "standard",
    "plugin:flowtype/recommended",
  ],
  "parser": "babel-eslint",
  "plugins": [
    "flowtype"
  ]
};

.babelrc 文件:

{
  "presets": ["flow"]
}

项目中的示例 js 文件:

/* @flow */

module.exports = function (app, db) {
  test: string // The problem occurs here
  // More code below ...
}

问题是 linter 给出了关于“test:string”的消息:

[eslint] 意外的标记语句。[无标签]

[eslint] 期望一个赋值或函数调用,而是看到一个表达式。[没有未使用的表达式]

[eslint] 'string' 未定义。[无非定义]

我注意到这两个扩展分别工作正常。当我尝试像上面的 .eslintrc 文件一样同时使用它们时,就会出现问题。

4

0 回答 0