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

no-array-push-push and prefer-ternary: Improve same reference detection #1123

Merged
merged 9 commits into from
Feb 22, 2021

Conversation

fisker
Copy link
Collaborator

@fisker fisker commented Feb 22, 2021

Copied a util function isSameReference from ESLint core.


no-array-push-push:

foo().push(1);
foo().push(2);

This was invalid, now it's not considered the same array.

foo.bar.push(1);
foo
	.bar.push(1);

Was not considered same array (we used source code to compare), now they can be recognized.


prefer-ternary:

Only check Identifier before, same MemberExpression is recognized.

if (test) {
	foo.bar = 1;
} else {
	foo.bar = 2;
}

->

foo.bar = test ? 1 : 2;

@fisker fisker marked this pull request as ready for review February 22, 2021 09:00
@sindresorhus sindresorhus merged commit c2c28a6 into sindresorhus:main Feb 22, 2021
@fisker fisker deleted the is-same-reference branch February 22, 2021 13:47
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