blog.unresolved.xyzblog.unresolved.xyz

tsconfigのbaseUrlとeslintを共存させる方法

Sun Aug 09 2020
  • TypeScript
  • TIL

tsconfigにbaseUrlを設定しているとeslintがコケることがあります。

1回設定したら終わりだしメモしなくていいだろうと思っていましたが、5回くらいググっているのでこちらにメモしておきます。

1error Unable to resolve path to module '#/foo' import/no-unresolved

eslint-import-resolver-typescriptの導入とresolverの設定をする

要はimport記法でtsファイルを解決できていないようです。

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

して、

1{ 2 // other configuration are omitted for brevity 3 settings: { 4 "import/resolver": { 5 typescript: {} // this loads <rootdir>/tsconfig.json to eslint 6 }, 7 }, 8}

としたら消えます。

refs