能够为react-native(使用react-native init
)创建一个新项目,并启用对Visual Studio Code的流检查。
我刚刚创建了一个新的react-native项目
react-native init iaptris
然后打开Visual Studio代码
cd iaptris
code .
我看到了这个错误
这些错误描述(意大利语,对不起)
谷歌搜索我得出结论我必须安装Flow Extension for VsCode,我做了。
然后我禁用本机检查当前工作空间,设置文件关联和路径到flow命令
{
"javascript.validate.enable": false,
"files.associations": {
"*.json": "json",
"*.js": "javascriptreact"
},
"flow.pathToFlow": "C:\\Users\\mirko\\.vscode\\extensions\\flowtype.flow-for-vscode-1.0.1\\node_modules\\.bin\\flow.cmd"
}
在同一工作区上关闭并重新启动vscode
此时,错误消失了,而且,删除大括号以抛出新的语法错误,我没有看到任何错误。没有错误。
我现在还要做什么?
实际解决方案,如果这不是更好的方法,请发布您的答案。而且我认为这不是更好的方法。
react-native init <project name>
Javascript -> Validate
(对不起,如果下一张图片是意大利语,但它足以作为参考)yarn add eslint babel-eslint eslint-plugin-flowtype --dev
or
npm install eslint babel-eslint eslint-plugin-flowtype --save-dev
.eslintrc
{
"parser": "babel-eslint",
"plugins": [
"flowtype"
],
"extends": [
"plugin:flowtype/recommended"
]
}