Description
I love this project. I'm very excited to get it up and running.
The problem I'm running into is that my example.ts file has an import in it like this:
import { environmentConfig } from "../src/environment-config.js";
The file that actually points to is "../src/environment-config.ts".
ts-node-esm example.ts
seems to handle the module resolution for me magically; it just works. Additionally, when I build from project with typescript, it also just works because the .ts files get changed to .js, so the ".js" file extension in the import paths points to the right file when I execute the file with Node: node example.js
.
It seems ideal to me to keep this configuration. However, I cannot get the eslint-plugin-import to resolve ".js" to ".ts" in my imports. I've spent a few hours on it, looking for resolvers on NPM that might do this and trying to write my own resolver. I didn't find anything on NPM and in writing my own resolver, I realized that module resolution is a bit more complex than I anticipated. I also looked at eslint-import-resolver-typescript
, but that seems to be created to support .ts file extensions in your imports, which I do not have. I've also tried searching the issues on this repo and was not able to find anything related.
I am wondering if there is something simple that I am missing to achieve this. I am not particularly knowledgable about module resolution, or the best way to make all of this work. If possible, any thoughts/help would be greatly appreciated. Thank you very much.
Here is my .eslintrc.cjs:
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
plugins: ["@typescript-eslint", "prettier", "import"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict",
"prettier",
"plugin:import/recommended",
],
env: {
node: "true",
},
};