tsconfig baseUrl eslint

tsconfig에 baseUrl을 ./src로 설정했다
그런데 eslint가 못 알아먹는다
알아먹도록 해보자

상황

  • 타입스크립트 프로젝트에서 npx eslint --init을 통해 eslint 환경을 구성했다
  • 그런데 tsconfig에 설정한 baseUrl을 eslint가 알아먹지 못했다

eslint-import-resolver-typescript 설치

terminal
1
yarn add -D eslint-import-resolver-typescript

eslintrc 수정

.eslintrc.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
// ...
"parserOptions": {
// ...
"project": "./tsconfig.json"
},
// ...
// https://github.com/import-js/eslint-plugin-import/issues/1485#issuecomment-535351922
"settings": {
"import/resolver": {
"typescript": {}
}
}
}
  • parserOptions.projectsettings.import/resolver.typescript에 위 내용처럼 추가한다
  • eslint config를 수정하면 항상 ESLint: Restart ESLint Server 또는 Developer: Reload Window을 꼭 해주자

참고

Author

chinsung

Posted on

2021-08-29

Updated on

2021-08-29

Licensed under

댓글