Skip to content

[file-extension-in-import] Dir imports resolve to package/dir.js instead of package/dir/index.js #136

@Sarabadu

Description

@Sarabadu

Environment

Node version: 20
npm version: 10.1.0
ESLint version: 8.51.0
eslint-plugin-n version: 16.2.0
Operating System: macos

What rule do you want to report?

file-extension-in-import

Link to Minimal Reproducible Example

https://eslint-online-playground.netlify.app/#eNqtkktP4zAUhf/KlTcpUus8ZjTDdMRokFggsWCDYEFAcpNLMfglP0pL6X/HeYBIRSQWrJL4npzz+ehuibNVimsmjUD64MiccGm09bCF8+BN8LCDO6slJP9NEEHytH/odpr8hTQFf88duHsdRA0LhDu+ZguBwNzIXzEoKdVbkODOX+Hi2JhT7fwZblyXvB/MnoPFmWKerzB9wkW6KrKiyP5k+Zcpxi1Srmpcd2ClGkOaJHWQcpMcNKJKK+eBwREofOrbmsRJc65jm0IvJ+yATAlFJ7jytor2WsWKt6UCKAmuParalWQO1/GrFc0tVlrKeI51SaZRZURYcjVX6WByM+08DLMO7bnxPKY2Tq13615JdonWxUFzXhLBPDofTd8UTgdb4cXGYCeQug4ivjfzXal2Ed2w6pEtm80YgKtIhMM4peve5jb/SfPfNIOXF/h3lP+iGc160x66xtUJmuYmquJ7Pl0NI8TdcNZVMhu713Dneqgf9PCQ5p+oPu5Ery1oXgyYY8+Ido/5Hfk789red6/+GzDA

What did you expect to happen?

I was expecting to auto fix this issues with file-extension-in-import plugin instead of being flagged as error from n/no-missing-import

import { Output } from '@pulumi/pulumi/output'; // this should be fixable as '@pulumi/pulumi/output.js'
import {listWebAppHostKeysOutput} from '@pulumi/azure-native/web/v20220901'; // this should be fixable as '@pulumi/azure-native/web/v20220901/index.js'

migrating to node 20 those imports are failling with:

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/.../node_modules/@pulumi/azure-native/web/v20220901' is not supported resolving ES modules imported from /.../someFile.js
    Did you mean to import @pulumi/azure-native/web/v20220901/index.js?

Would be nice to use file-extension-in-import (maybe with some additional configs) to auto fix those

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions