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

prefer-string-slice: Keep optional chaining in autofix #1085

Merged
merged 2 commits into from Feb 9, 2021
Merged

prefer-string-slice: Keep optional chaining in autofix #1085

merged 2 commits into from Feb 9, 2021

Conversation

noftaly
Copy link
Contributor

@noftaly noftaly commented Jan 29, 2021

Keep optional chaining in auto fix

Fixes #999

@fisker
Copy link
Collaborator

fisker commented Jan 30, 2021

What about foo?.slice?.(1, 2)

@fisker
Copy link
Collaborator

fisker commented Jan 30, 2021

And foo?.bar.slice(1, 2), I believe it's different callee type.

@noftaly
Copy link
Contributor Author

noftaly commented Jan 30, 2021

And foo?.bar.slice(1, 2), I believe it's different callee type.

This is already tested

What about foo?.slice?.(1, 2)

I'll add this one in an hour or so

},
{
code: 'foo.bar.substr?.()',
output: 'foo.bar.slice?.()',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this, the old one is testing object has .substr, but new one testing .slice exists, if someone mean to test it is a string and foo.bar is an array, it's broken.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hope no one use this...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you want

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.

Broken autofix in prefer-string-slice with optional chaining
3 participants