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

[New] extensions: add auto fixer! #2593

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kumavis
Copy link

@kumavis kumavis commented Nov 11, 2022

doesn't seem to work in all cases - fails silently in some cases as you can see in the tests where there are expected errors but ouput === code.

first time writing a fixer so I hope I'm doing it right.

adding the missing file extension does not support query params. would be easier with node's path, I found it hard to work with the URL since it would not differentiate between x and ./x, but maybe i was holding it wrong

@kumavis
Copy link
Author

kumavis commented Nov 11, 2022

hi @ljharb /
am i doing this right?

@@ -151,6 +159,7 @@ ruleTester.run('extensions', rule, {
invalid: [
test({
code: 'import a from "a/index.js"',
output: 'import a from "a/index"',
Copy link
Member

Choose a reason for hiding this comment

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

this isn't a safe autofix unless we can validate that a/index and a/index.js resolve to the same thing.

if we can't add that validation using custom resolvers, then this would need to be a suggestion instead of an autofix.

@ljharb ljharb marked this pull request as draft January 11, 2023 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants