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
Fix: correct docs for Reflect, Reflect cannot take null or undefined,… #7150
Conversation
@sstern6, thanks for your PR! By analyzing the annotation information on this pull request, we identified @keithamus, @aubergine10 and @IanVS to be potential reviewers |
Thanks for the pull request, @sstern6! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
LGTM |
@@ -54,12 +54,12 @@ Examples of **correct** code for this rule when used without exceptions: | |||
```js | |||
/*eslint prefer-reflect: "error"*/ | |||
|
|||
Reflect.apply(undefined, args); | |||
Reflect.apply(null, args); | |||
Reflect.apply(obj.fooBar, args); |
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.
This and the following line seem to be examples of the exact same use case. Also, doesn't Reflect.apply
take three arguments?
It looks to me like maybe the intended examples here were:
Reflect.apply(obj.foo, undefined, args);
Reflect.apply(obj.foo, null, args);
and
Reflect.apply(obj.foo, undefined, [arg]);
Reflect.apply(obj.foo, null, [arg]);
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.
Youre right, updating
LGTM |
@@ -54,12 +54,12 @@ Examples of **correct** code for this rule when used without exceptions: | |||
```js | |||
/*eslint prefer-reflect: "error"*/ | |||
|
|||
Reflect.apply(undefined, args); | |||
Reflect.apply(null, args); | |||
Reflect.apply(obj.foo, undefined, args); |
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.
Oops, sorry, I think these should all be calling foo
instead of obj.foo
( i.e. Reflect.apply(foo, undefined, args);
) to match the incorrect examples. Can someone else confirm?
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.
IMHO, seems like mdn references Reflect.apply(Math.floor, undefined, [1.5])
so I personally think obj.foo
could be used. But i think confirming would be a good idea.
Thanks
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 think the above examples of incorrect patterns are badly written (sorry). Above there is foo
(a function var) and obj.foo
(a function property on an object). So @kaicataldo is right, this below example should demonstrate both - this should be foo
.
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.
It might be worthwhile rewriting the above incorrect patterns to use a mixture of names, rather than foo
for everything.
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.
what if we use a more suggestive name, like myFunction
, or fn
?
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 happy with that. I think potentially foo
and obj.foo
need different names, e.g. foo
can become myFunction
and obj.foo
obj.myMethod
perhaps?
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.
Thanks @keithamus @vitorbal will update per your recommendations.
Just a heads up, the commit message should begin with "Docs:" rather than "Fix:" because this is a documentation fix. |
|
Great, will have this updated by morning. |
LGTM |
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.
Thanks for updating! Two quick things:
- I'm fine with changing
foo
->myFunction
andfoo.bar
->obj.myMethod
, but I think we should change all the instances of it for that section then (including the examples for theexceptions
configuration option). I think it's confusing to not have the corresponding examples share the same names. - Mind adding
(fixes #7069)
to the end of the commit message? (i.e.Docs: correction in prefer-reflect docs (fixes #7069)
) This helps us out a lot because we can track the issue where the change was discussed and also because GitHub will then automatically close the issue for us.
@kaicataldo Thanks will update! |
@kaicataldo sorry for the delay, should have this back up this afternoon! |
No worries - thanks for working on this! |
LGTM |
LGTM |
@kaicataldo back up with what I understood to be the changes you requested. Went through the WHOLE file to make sure everything was as clear as possible regarding Request: Please carefully review the delete section of the file to make sure I understood what was trying to be communicated and I didn't inappropriately change anything. Question: With regards to Thanks |
``` | ||
|
||
### Reflect.setPrototypeOf | ||
### <Reflect class="setPrototypeOf"></Reflect> |
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.
This doesn't look right.
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.
Yeah, this shouldn't have changed
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.
Thanks for working on this! I actually meant that I think this change should be applied to the whole Reflect.apply
section (not to the whole file). The initial PR only made changes to the correct examples code block, and I think we should then make the incorrect and exceptions
examples match. Sorry if this wasn't clear - does that make sense?
``` | ||
|
||
### Reflect.setPrototypeOf | ||
### <Reflect class="setPrototypeOf"></Reflect> |
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.
Yeah, this shouldn't have changed
Apologize @kaicataldo for the confusion. Only the Updated file coming your way. Again apologize for my misunderstanding and the confusion. |
LGTM |
No need to apologize - thanks again for working on this |
LGTM. Thanks for contributing to ESLint! |
What is the purpose of this pull request? (put an "X" next to item)
Please check each item to ensure your pull request is ready:
What changes did you make? (Give an overview)
Updated the docs that reference Reflect.apply. Reflect.apply's first argument is a
target
, which according to the mdn specifications is a function.This PR fixes #7069