Skip to content

How to properly combine it with import/extensions rule in an ESM project? #14

Closed
@mbonaci

Description

@mbonaci

If I use your conf from README and also do (FYI I'm using airbnb eslint conf):

"import/extensions": [
  "error",
  "ignorePackages",
  {
    "js": "always",
    "cjs": "always",
    "jsx": "always",
    "ts": "never",
    "tsx": "never",
    "json": "always"
  }
]

then eslint doesn't complain if I import a ts/tsx file without an extension, e.g.:

import Root from 'components/Root'; // no errors for this tsx file

If I change import/extensions conf and say "tsx": "always" instead, then I get:

Missing file extension "tsx" for "components/Root" eslint[import/extensions]

When I import it as a js file there are no errors and that's great:

import Root from 'components/Root.js'; // great, but I need the error when the .js extension is missing

So how come your extension isn't jumping out of joy to step in and save the day :)

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions