-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Upgrade: eslint-plugin-node to 7.0.1 #10612
Conversation
seems we have been inconsistent in the usage of |
lib/testers/rule-tester.js
Outdated
@@ -398,6 +398,7 @@ class RuleTester { | |||
function assertASTDidntChange(beforeAST, afterAST) { | |||
|
|||
// Feature detect the Node.js implementation and use that if available. | |||
// eslint-disable-next-line node/no-unsupported-features/node-builtins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused about this line. Is the name of the rule "no-unsupported-features/node-builtins"
(and therefore the plugin-qualified name is "node/no-unsupported-features/node-builtins"
? I don't think I've ever seen a rule defined with a forward slash in its name, just wanted to make sure I understood correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We can use /
in the rule name in plugins. #3458 (comment) mentioned this fact.
lib/testers/rule-tester.js
Outdated
@@ -398,6 +398,7 @@ class RuleTester { | |||
function assertASTDidntChange(beforeAST, afterAST) { | |||
|
|||
// Feature detect the Node.js implementation and use that if available. | |||
// eslint-disable-next-line node/no-unsupported-features/node-builtins | |||
if ((util.isDeepStrictEqual && !util.isDeepStrictEqual(beforeAST, afterAST)) || !lodash.isEqual(beforeAST, afterAST)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be right about this running two deep equal checks. Maybe it would be worthwhile to extract the logic, or change to a ternary (if (!(util.isDeepStrictEqual ? util.isDeepStrictEqual(beforeAST, afterAST) : lodash.isEqual(beforeAST, afterAST))) {
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's exactly a code I thought.
But I'm wondering we can rewrite it to simple if (!lodash.isEqual(beforeAST, afterAST)) {
.
This feature detection might cause to change test results by the existence of util.isDeepStrictEqual
.
I think the thought was that `util.isDeepStrictEqual` might be faster, but
I have no objection to just using lodash.
…On Tue, Jul 17, 2018, 20:50 Toru Nagashima ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/testers/rule-tester.js
<#10612 (comment)>:
> @@ -398,6 +398,7 @@ class RuleTester {
function assertASTDidntChange(beforeAST, afterAST) {
// Feature detect the Node.js implementation and use that if available.
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
if ((util.isDeepStrictEqual && !util.isDeepStrictEqual(beforeAST, afterAST)) || !lodash.isEqual(beforeAST, afterAST)) {
Yes, it's exactly a code I thought.
But I'm wondering we can rewrite it to simple if
(lodash.isEqual(beforeAST, afterAST)) {.
This feature detection might cause to change test results by the existence
of util.isDeepStrictEqual.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#10612 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AARWepbp3AnIXd5XCM06hAXRMeYV0-ciks5uHpRwgaJpZM4VSzSK>
.
|
|
@aladdin-add It's the reason Problem is: !util.isDeepStrictEqual(beforeAST, afterAST) || !lodash.isEqual(beforeAST, afterAST) That
I prefer the latter because we don't need the forking by feature detection. |
Anyway, I'll separate that matter to another PR. |
agreed! |
I sent a PR: #10617 |
might need to rebase, since #10617 get merged. cc @mysticatea |
Done! |
What is the purpose of this pull request? (put an "X" next to item)
[X] Other, please explain: upgrade
eslint-plugin-node
to7.0.1
for linting our codebase.What changes did you make? (Give an overview)
It has new features:
^6.14.0 || ^8.10.0 || >=9.10.0
).Is there anything you'd like reviewers to focus on?
I'm not sure if this
util.isDeepStrictEqual()
part is needed.That looks to do double checking for the AST if
util.isDeepStrictEqual
exists. But why?