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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance no-array-for-each to handle optional chaining #1753

Merged
merged 27 commits into from Apr 1, 2022

Conversation

zaicevas
Copy link
Contributor

Closes #1632

That's my first contribution, so let me know if I missed anything 馃槄

rules/no-array-for-each.js Outdated Show resolved Hide resolved
rules/no-array-for-each.js Outdated Show resolved Hide resolved
@fisker
Copy link
Collaborator

fisker commented Mar 23, 2022

Tests are not enough, please duplicate all these cases

, change to ?. and test them all.

@zaicevas

This comment was marked as outdated.

@fisker
Copy link
Collaborator

fisker commented Mar 24, 2022

Forget about the indention, let other rule handle it, even

if (foo) for (const returnStatement of returnStatements) {
 // ...
}

is fine to me.

rules/no-array-for-each.js Outdated Show resolved Hide resolved
@fisker

This comment was marked as outdated.

@zaicevas

This comment was marked as outdated.

@fisker

This comment was marked as outdated.

@zaicevas

This comment was marked as outdated.

rules/no-array-for-each.js Outdated Show resolved Hide resolved
rules/no-array-for-each.js Outdated Show resolved Hide resolved
rules/no-array-for-each.js Outdated Show resolved Hide resolved
# Conflicts:
#	rules/no-array-for-each.js
#	test/snapshots/no-array-for-each.mjs.md
#	test/snapshots/no-array-for-each.mjs.snap
@fisker
Copy link
Collaborator

fisker commented Mar 31, 2022

@zaicevas Please take a look, please let me know if you find something wrong.

@fisker
Copy link
Collaborator

fisker commented Mar 31, 2022

I'll fix some edge cases after we merge this. Turns out it's not hard to fix 2e783bb

@zaicevas
Copy link
Contributor Author

@zaicevas Please take a look, please let me know if you find something wrong.

I'll take a look later today

Copy link
Contributor Author

@zaicevas zaicevas left a comment

Choose a reason for hiding this comment

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

Looks much cleaner! I cracked my head trying to understand why you removed most tests. Then I finally found flatMap(code => [code, code.replace('.forEach', '?.forEach')]), 馃槄

rules/no-array-for-each.js Show resolved Hide resolved
@sindresorhus sindresorhus merged commit 1d32db4 into sindresorhus:main Apr 1, 2022
@sindresorhus
Copy link
Owner

Thanks for contributing :)

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.

no-array-for-each: is not handling optional chaining when auto-fixing
3 participants