如何在vscode上启用flow-native的流检查?

问题描述 投票:3回答:1

目标

能够为react-native(使用react-native init)创建一个新项目,并启用对Visual Studio Code的流检查。

我做了什么

我刚刚创建了一个新的react-native项目

react-native init iaptris

然后打开Visual Studio代码

cd iaptris
code .

我看到了这个错误

enter image description here

这些错误描述(意大利语,对不起)

enter image description here

谷歌搜索我得出结论我必须安装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

问题

此时,错误消失了,而且,删除大括号以抛出新的语法错误,我没有看到任何错误。没有错误。

enter image description here

我现在还要做什么?

react-native visual-studio-code flowtype
1个回答
2
投票

实际解决方案,如果这不是更好的方法,请发布您的答案。而且我认为这不是更好的方法。

  1. react-native init <project name>
  2. 打开VsCode
  3. 仅为当前工作空间禁用Javascript -> Validate(对不起,如果下一张图片是意大利语,但它足以作为参考)

enter image description here

  1. 安装一个插件 yarn add eslint babel-eslint eslint-plugin-flowtype --dev or npm install eslint babel-eslint eslint-plugin-flowtype --save-dev
  2. 创建一个包含以下内容的.eslintrc { "parser": "babel-eslint", "plugins": [ "flowtype" ], "extends": [ "plugin:flowtype/recommended" ] }
  3. 关闭并重新打开vscode和工作区
© www.soinside.com 2019 - 2024. All rights reserved.