VSCode自动导入方面

时间:2019-11-07 20:28:10

标签: visual-studio-code eslint auto-import

我很好奇VSCode是否可行。基本上,我有一个.eslint文件,除其他事项外,它指定了不希望出现的分号,然后会在保存时将漂亮的分号删除

{
  "parser": "babel-eslint",
  "extends": ["react", "prettier"],
  "plugins": ["react", "import", "prettier"],
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  },
  "rules": {
    "semi": ["error", "never"],
    "indent": [
      "error",
      2,
      {
        "SwitchCase": 1
      }
    ],
    "react/prop-types": [0],
    "space-before-function-paren": 0,
    "prefer-reflect": 0,
    "quotes": ["error", "double"],
    "jsx-quotes": ["error", "prefer-double"],
    "no-lonely-if": 0,
    "max-depth": 0,
    "no-unused-vars": 1,
    "multiline-ternary": 0,
    "prettier/prettier": ["error"]
  }
}

当我尝试执行自动导入并知道如何在顶部构建该导入语句以遵循我在此处的内容时,我希望VSCode遵守此设置。大括号之间的间距,双引号和无分号。

我还拥有一个jsconfig.json文件,它指定了一些路径以及自动导入功能似乎毫无困难的别名

{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "moduleResolution": "node",
    "jsx": "react",
    "baseUrl": "src/",
    "paths": {
      "components/*": ["src/components/*"],
      "dialogs/*": ["src/dialogs/*"],
      "actions/*": ["src/actions/*"],
      "reducers/*": ["src/reducers/*"],
      "routes/*": ["src/routes/*"],
      "store/*": ["src/store/*"],
      "types/*": ["src/types/*"],
      "pages/*": ["src/pages/*"]
    }
  },
  "exclude": ["node_modules"]
}

是否可以通过这两个文件之一使VSCode能够处理这种事情?

0 个答案:

没有答案