본문 바로가기

👩🏻‍💻 dev

Parsing error: ESLint was configured to run on `<tsconfigRootDir>/xxx` using `parserOptions.project`: /yyy/tsconfig.lint.json However, that TSConfig does not include this file

모노레포 레포지터리 구조는 다음과 같다.

.github
.husky
apps
    ㄴ storybook
    ㄴ web
packages
    ㄴ design-system
         ㄴ .turbo
         ㄴ dist
         ㄴ node_modules
         ㄴ src
         ㄴ turbo
         ㄴ  typings
         ㄴ eslintrc.cjs
         ㄴ package.json
         ㄴ tsconfig.json
         ㄴ tsconfig.lint.json

    ㄴ eslint-config
    ㄴ typescript-config
package.json
pnpm-lock.yaml
.npmrc
// ...생략

 

모노레포로 파일을 구성하고 있었고, husky로 precommit에 lint를 하도록 설정 중에 다음과 같은 에러가 발생했다.

 

문제는 TSConfig가 이 파일을 포함하고 있지 않고 있다는 것이다.

최상단에서 커밋을 하기 전, husky pre-commit에 prettier로 format하고 eslint로 lint를 하도록 설정해주고자 했다.

packages/design-system의 lint는 src와 turbo 경로 아래의 파일들에 한에 lint를 하도록 설정이 되어 있었기 때문에

해당 경로를 추가해줘야 했다. 

 

turborepo를 처음 써봤는데, 좋은 점은 아무래도 에러 로그가 잘 되어 있는 것 같다.

친절하게 해결 방법도 설명해주고 있다.

However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file 
- Create a new TSConfig that includes this file and include it in your parserOptions.project 

 

옵션 1 : EsLint 설정 파일의 include에 해당 파일이 포함되지 않도록 하기

옵션 2 : TSConfig 파일에 include에 파일 추가해 주기

옵션 3 : TSConfig 파일을 새로 만들고, 이 파일을 추가해 주고, parserOptions.project에  포함해 주기

 

다음과 같이 packages/design-system/tsconfig.lint.json에 옵션 2에서 언급한 바와 같이 린트를 해줄 폴더 경로를 추가해 준다.

{
  "extends": "@tripie/typescript-config/react-library.json",
  "compilerOptions": {
    "outDir": "dist"
  },
  "include": ["src", "turbo", "typings"],
  "exclude": ["node_modules", "dist"]
}