Skip to content

[file-extension-in-import] Does not work properly in TypeScript projects with allowImportingTsExtensions #134

@Zamiell

Description

@Zamiell

Environment

Hello,

With the following config:

"n/file-extension-in-import": ["error", "always"],

Will autofix this:

import { foo } from "./foo";

To this:

import { foo } from "./foo.js";

However, this is a bug in TypeScript projects that use allowImportingTsExtensions. In such projects, having a ".js" import is a bug, because the assumption is that our entire application is written in TypeScript, and no JavaScript files will probably ever exist.

Proposal:

Instead of fixing to .js, the rule should auto-fix to .ts when the "tsconfig.json" has the allowImportingTsExtensions option set to true.

What rule do you want to report?

file-extension-in-import

Participation

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions