我正在运行win10并且我已经使用chocolatey(node,yarn ++)安装了所有软件。
在进行纱线测试(eslint src&& flow)时,我得到以下信息:
yarn test v0.27.5
$ eslint src && flow
can't resolve reference #/definitions/basicConfig from id #
can't resolve reference #/definitions/basicConfigOrBoolean from id #
can't resolve reference #/definitions/basicConfigOrBoolean from id #
Error: node_modules/eslint-plugin-jsx-a11y/src/rules/media-has-caption.js:53
v--------------------------------------
53: const trackChildren: Array<JSXElement> = node.children.filter((child: Node) => {
54: if (child.type !== 'JSXElement') {
55: return false;
...:
60: });
-^ call of method `filter`. Function cannot be called on any member of intersection type
53: const trackChildren: Array<JSXElement> = node.children.filter((child: Node) => {
^^^^^^^^^^^^^^^^^^^^ intersection
Member 1:
245: filter(callbackfn: typeof Boolean): Array<$NonMaybeType<T>>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: C:\Users\Eivind\AppData\Local\Temp\flow\flowlib_d70c9ae\core.js:245
Error:
v-----------------
53: const trackChildren: Array<JSXElement> = node.children.filter((child: Node) => {
54: if (child.type !== 'JSXElement') {
55: return false;
...:
60: });
^ statics of function. This type is incompatible with
v-----------------------
106: declare class Boolean {
107: constructor(value?: mixed): void;
108: static (value:any):boolean;
...:
111: }
^ statics of Boolean. See lib: C:\Users\Eivind\AppData\Local\Temp\flow\flowlib_d70c9ae\core.js:106
Member 2:
246: filter(callbackfn: (value: T, index: number, array: Array<T>) => any, thisArg?: any): Array<T>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: C:\Users\Eivind\AppData\Local\Temp\flow\flowlib_d70c9ae\core.js:246
Error:
4924: children: Array<Node>;
^^^^ object type. This type is incompatible with the expected param type of. See: node_modules/ast-types-flow/lib/types.js:4924
53: const trackChildren: Array<JSXElement> = node.children.filter((child: Node) => {
^^^^ Node
Error: node_modules/eslint-plugin-jsx-a11y/src/rules/media-has-caption.js:59
59: return isTrackType(context, elementType(child.openingElement));
^^^^^^^^^^^^^^ property `openingElement`. Property not found in
59: return isTrackType(context, elementType(child.openingElement));
^^^^^ Node
Found 2 errors
error Command failed with exit code 2.
不知道这是什么......
在使用yarn add package
之后,我还遇到了一些无法识别脚本的问题,但我想我通过修复eslint-airbnb-config的错误对等依赖来解决这个问题。
以下是我的配置文件:
的package.json
{
"name": "js-fullstack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "eslint src && flow",
"start": "babel-node src"
},
"keywords": [],
"author": "",
"license": "ISC",
"browserslist": [
"> 1%"
],
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-preset-env": "^1.6.0",
"babel-preset-flow": "^6.23.0",
"eslint": "^4.3.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-compat": "^1.0.4",
"eslint-plugin-flowtype": "^2.35.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "^7.1.0",
"flow-bin": "^0.51.1"
},
"dependencies": {}
}
.eslintrc.json
{
"extends": [
"airbnb",
"plugin:flowtype/recommended"
],
"plugins": [
"compat",
"flowtype"
],
"rules": {
"linebreak-style": [2, "windows"],
"jsx-a11y/href-no-hash": 0,
"semi": [2, "never"],
"no-unexpected-multiline": 2,
"compat/compat": 2
}
}
.flowconfig
{
"presets": [
"env",
"flow"
]
}