Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the ability to configure typescript to javascript file extension conversion #112

Merged
merged 4 commits into from Sep 5, 2023

Conversation

scagood
Copy link

@scagood scagood commented Aug 23, 2023

Reference #108

This adds the ability to configure the ts<>js extension mapping.

This is configured using the following:

  1. Check the rule configuration typescriptExtensionMap
  2. ESLint shared setting node.typescriptExtensionMap
  3. Use .ts <=> .js, .cts <=> .cjs, .mts <=> .mjs, .tsx <=> .js

@scagood
Copy link
Author

scagood commented Aug 23, 2023

This is draft because I am not sure how to add the mapping to n/file-extension-in-import, any suggestions? 🤔

@scagood scagood marked this pull request as ready for review August 23, 2023 16:53
@aladdin-add aladdin-add self-requested a review August 24, 2023 09:57
@scagood
Copy link
Author

scagood commented Aug 27, 2023

@aladdin-add Do you want me to make the tsconfig detection mechanism PR now, or wait for you to review this PR? 👀

@aladdin-add
Copy link

sorry, haven't gotten time to review. will try to do it in the week. :)

Do you want me to make the tsconfig detection mechanism PR now, or wait for you to review this PR? 👀

Yes, please feel free to. You can rebase this change when it's been merged.

@@ -69,13 +69,30 @@ If a path is relative, it will be resolved from CWD.

Default is `[]`

#### typescriptExtensionMap

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid duplication, I'm just wondering whether we could add a section to the readme that describes the shared settings. In the rule docs we can add a link to that. (surely not blocking merging this PR. 😄 )

Copy link

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 👍

Comment on lines +39 to +41
option &&
option.typescriptExtensionMap &&
Array.isArray(option.typescriptExtensionMap)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: can be simply rewritten to Array.isArray(option?.typescriptExtensionMap), as the package has dropped node.js < v16.

Copy link
Author

@scagood scagood Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I am totally going to fix this in another PR!

I just followed what was there 👀

@aladdin-add aladdin-add merged commit 20d2713 into eslint-community:master Sep 5, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants