VS Code React Native项目中更漂亮问题的自动修复或快捷方式

时间:2020-01-12 10:08:11

标签: react-native visual-studio-code prettier

我正在将Visual Studio Code与React Native项目一起使用。 ESLint用于检查dt["diff"]=dt["year"].mul(12).add(dt["month"]) dt['diff']=dt.groupby('patient_ID')['diff'].diff().fillna(0) 中指定的内容。 当某些问题不正确时,我会得到如下提示:

enter image description here

我希望自动或使用快捷方式组合来解决问题,而不是获取这些通知并右键单击它们,选择>> dt[['patient_ID', 'year', 'month', 'diff']] patient_ID year month diff 0 4388 2004 8 0.0 1 4388 2007 9 37.0 2 9086 2007 9 0.0 3 9086 2008 6 9.0 4 9086 2011 2 32.0 。我该如何配置?我目前正在使用纯JavaScript,没有Typescript。

2 个答案:

答案 0 :(得分:2)

编辑/创建.vscode/settings.json,使其包含

{
"editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
},
}

修复了保存时的问题。

答案 1 :(得分:0)

感谢@jonrsharpe!只想加我几毛钱。

  1. 转到 settings.json 文件:

    • Windows %APPDATA%\Code\User\settings.json
    • macOS $HOME/Library/Application Support/Code/User/settings.json
    • Linux $HOME/.config/Code/User/settings.json
  2. 添加到此处:

 {
   "editor.codeActionsOnSave": {
     "source.fixAll.eslint": true
   },
 }
  1. 重新启动VSCode

享受编码!))

更新

在Mac上,上述解决方案适用于我,但在Windows上,要使其正常运行,我必须在 settings.json 中添加以下内容:

    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true,
        "source.fixAll": true
      },
    "eslint.autoFixOnSave": true