7

我有以下项目结构:

/root
  /serviceA 
  /serviceB
  /serviceC 
  /serviceD 

并非所有服务都是基于打字稿/节点的,所以我想避免将 tsconfig 添加到根目录中。每个服务都设置为一个完整的单元,具有自己的 eslint、ts 和自己的配置安装。

我打开 VScode 的任何ts服务都显示以下错误:

Parsing error: Cannot read file '/users/{me}/dev/{root}/tsconfig.json'.

这是正确的,因为没有这样的文件,那么我如何强制 vscode & eslint 使用单个服务配置文件?

4

2 回答 2

11

编辑您的.eslintrc文件:


module.exports = {
  parserOptions: {
    project: './tsconfig.json',
    tsconfigRootDir: __dirname,
  },
};

来源:https ://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-488538828

于 2020-11-08T09:46:24.297 回答
1

.eslintrc您可以将路径设置为tsconfig.json.

parserOptions : {
  project: './tsconfig.json',
},

这是一个仅为 ts 文件设置的示例

https://github.com/davidjbradshaw/eslint-config-auto/blob/master/rules/%40typescript-eslint/parser.js

于 2020-08-11T10:56:56.593 回答