首页 > 解决方案 > 使用 VSCode 配置 ESLint

问题描述

我有以下目录结构:

/
├──.node-modules
├──server             # server code
│   ├──...
├──shared             # modules used by client and server
├──webapp             # client code
│   ├──...
│   ├──eslintrc.js    # client eslint config
├──eslintrc.js        # project eslint config
└──webpack.config.js

我将 Vue 用于客户端代码和dbaeumer.vscode-eslintVSCode 扩展。在.vue文件上,我不断收到import报表错误。

无法解析模块的路径module

我一直在搞乱eslint.workingDirectories设置来设置它,但没有成功。在我的客户端本地 eslint 配置中,我定义了导入/解析器:

module.exports = {
  ...
  settings: {
    'import/resolver': 'webpack',
  },
}

标签: visual-studio-codeeslint

解决方案


不久前,我在我的 VS Code 上安装 ESlint 时使用了这个视频。

也许这可能是版本的问题,您可以从这里检查最佳版本。


推荐阅读