【问题标题】:Repo working with git submodules causeing eslint to look in the wrong dirRepo 使用 git 子模块导致 eslint 查找错误的目录
【发布时间】:2022-01-21 19:39:54
【问题描述】:

开始了一个新项目,打算使用 git 子模块将服务器、客户端和其他资源分离到自己的 repos 中,同时使用主 repo 来容纳 dev.docker-compose-yamldocker-compose.yaml、静态站点和其他资源.

(这可能是使用子模块错误,如果我错了请纠正我)

项目结构如下:

客户端是 react,服务器是 Nest。每个都包含自己的Dockerfile,由dev.docker.compose.yaml 构建。应用运行正常,但是 eslint 报错:

Parsing error: Cannot read file 'c:\users\<user>\programing\projects\<thing>\tsconfig.json'. eslint [1, 1]

它要查找的文件的正确路径是:

'c:\users\<user>\programing\projects\<thing>\**server**\tsconfig.json'

有没有办法纠正这个问题?我不应该使用这样的子模块吗?

谢谢

【问题讨论】:

    标签: git eslint git-submodules tsconfig typescript-eslint


    【解决方案1】:

    需要在.eslintrc.js 中添加tsconfigRootDir 以及一个测试,使其在子模块中工作并且独立。

    const fs = require('fs');
    
    module.exports = {
      ...
      parserOptions: {
        ...
        tsconfigRootDir: fs.existsSync('../.gitmodules') ? '../server' : './', 
      },
    };
    

    【讨论】:

      猜你喜欢
      • 2020-03-07
      • 2016-11-12
      • 2019-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-30
      • 2018-05-26
      相关资源
      最近更新 更多