eslint-plugin-node
eslint-plugin-node copied to clipboard
no-missing-import conflicts with typescript compiling to ES modules
Hello,
I'm using TypeScript project which compiles to ES modules. Because of this imports should containt '.js' extension like:
import {config} from './config.js';
The problem is that actually there is config.ts file and looks like no-missing-imports can't compare them.
Thanks in advance for your help. Here are my configs:
.eslintrc:
{
"parser": "@typescript-eslint/parser",
"env": {
"jest": true,
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:jest/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"prettier"
],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"node/no-unpublished-import": 0,
"node/no-missing-import": 0
}
}
tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*"]
}
Additional context: [email protected]
// ./bar.ts import { helper } from "./foo.js"; // works in ESM & CJS helper();This might feel a bit cumbersome at first, but TypeScript tooling like auto-imports and path completion will typically just do this for you.
Workaround for this issue: disable node/no-missing-import rule and use eslint-plugin-import with eslint-import-resolver-typescript.