eslint-plugin-node
eslint-plugin-node copied to clipboard
feat: `file-extension-in-import` to consider exports map
When importing an extension-less path, I'd like for file-extension-in-import to check if the path exists in the target package's exports map. If it exists, it should not error.
eg.
import * as assert from 'uvu/assert';
Given the following export map.
Related https://github.com/mysticatea/eslint-plugin-node/issues/255
Happy to open a PR if feature request is approved
This issue should be labeled a bug, not an enhancement. The node/file-extension-in-import rule is straight-up broken, reporting false errors that are impossible to fix without using // eslint-disable-next-line node/file-extension-in-import. The package exports field is not some optional, exotic feature. It's core functionality for all the current stable Node.js versions (claimed to be supported by eslint-plugin-node) and in use by all sorts of popular packages.
Here is a situation I run into a lot:
// eslint-disable-next-line node/file-extension-in-import
import { red } from "kleur/colors";