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

Resolve .jsx? to .tsx? and force the .jsx? extensions

Open slavafomin opened this issue 2 years ago • 2 comments

Hello!

Thank you for this great library!

However, I can't really figure out how to configure it in ESM TypeScript React project.

I would like the ESLint to report (and autofix) missing .js and .jsx extensions, however, it forces me to use the .ts(x) extensions instead.

In other words I want:

import { Component } from './component' to be corrected to import { Component } from './component.jsx'

import { util } from './util' to be corrected to import { util } from './util.js'

import { Component } from './component.tsx' and import { util } from './util.ts' should raise error.

Thanks!

slavafomin avatar May 03 '23 12:05 slavafomin

Are the files actually present on disk with those extensions?

If not, this is a duplicate of #2729 and should be closed.

ljharb avatar May 08 '23 16:05 ljharb

@ljharb I believe that the inability of import/extensions to map .js imports to .ts files on disk (and .jsx to .tsx, etc) is the same issue as @phryneas clarified over here in the other repo eslint-import-resolver-typescript:

  • https://github.com/import-js/eslint-import-resolver-typescript/issues/233#issuecomment-1627833938

Seems like there's also a PR open for that here in the eslint-plugin-import repo:

  • https://github.com/import-js/eslint-plugin-import/pull/2813

So maybe it's good to keep this current issue (2776) open until 2813 is landed, since the other issue in the eslint-plugin-import repo (#2729) has been closed.

karlhorky avatar Mar 17 '24 17:03 karlhorky