When working on my TypeScript project, I have noticed that to import ./foo/index.ts
, there are four different ways to do it:
import Foo from './foo' // ❌
import Foo from './foo/index' // ❌
import Foo from './foo/index.js' // ❌
import Foo from './foo/index.ts' // ✅
I want to set up my project so that only full file names with their actual extensions are allowed for relative imports.
Is there a way to achieve this using either tsconfig.json
or ESLint?