eslint-plugin-node icon indicating copy to clipboard operation
eslint-plugin-node copied to clipboard

feat: `file-extension-in-import` to consider exports map

Open privatenumber opened this issue 4 years ago • 2 comments

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

privatenumber avatar Mar 03 '21 08:03 privatenumber

Happy to open a PR if feature request is approved

privatenumber avatar Mar 03 '21 20:03 privatenumber

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";

jaydenseric avatar Jan 27 '22 23:01 jaydenseric