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

Fix: correct docs for Reflect, Reflect cannot take null or undefined,… #7150

Merged
merged 1 commit into from Sep 28, 2016

Conversation

sstern6
Copy link
Contributor

@sstern6 sstern6 commented Sep 13, 2016

What is the purpose of this pull request? (put an "X" next to item)

[ x] Documentation update

Please check each item to ensure your pull request is ready:

  • [ x] I've read the pull request guide
  • I've included tests for my change
  • I've updated documentation for my change (if appropriate)

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

@mention-bot
Copy link

@sstern6, thanks for your PR! By analyzing the annotation information on this pull request, we identified @keithamus, @aubergine10 and @IanVS to be potential reviewers

@eslintbot
Copy link

Thanks for the pull request, @sstern6! I took a look to make sure it's ready for merging and found some changes are needed:

  • The commit summary must be 72 characters or shorter. Please check out our guide for how to properly format your commit summary and update it on this pull request.

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@eslintbot
Copy link

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);
Copy link
Member

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]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Youre right, updating

@eslintbot
Copy link

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);
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@nzakas nzakas added the documentation Relates to ESLint's documentation label Sep 14, 2016
@nzakas
Copy link
Member

nzakas commented Sep 14, 2016

Just a heads up, the commit message should begin with "Docs:" rather than "Fix:" because this is a documentation fix.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Sep 15, 2016

I believe this also fixes 7075?

@sstern6
Copy link
Contributor Author

sstern6 commented Sep 15, 2016

Great, will have this updated by morning.

@eslintbot
Copy link

LGTM

Copy link
Member

@kaicataldo kaicataldo left a 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 and foo.bar -> obj.myMethod, but I think we should change all the instances of it for that section then (including the examples for the exceptions 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.

@sstern6
Copy link
Contributor Author

sstern6 commented Sep 19, 2016

@kaicataldo Thanks will update!

@sstern6
Copy link
Contributor Author

sstern6 commented Sep 22, 2016

@kaicataldo sorry for the delay, should have this back up this afternoon!

@kaicataldo
Copy link
Member

No worries - thanks for working on this!

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@sstern6
Copy link
Contributor Author

sstern6 commented Sep 27, 2016

@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 myFunction and obj.myMethod. Please let me know if I missed anything or if anything needs to be changed based on a misunderstanding. Updated the commit message as well.

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 Object.getPrototypeOf({}, 'myProp') per the eslint updated docs. It looks like MDN docs state that `Object.getPrototypeOf' only takes the "object whose prototype is to be returned". I am sure it works both ways but wasn't sure if it should be in there for clarity sake. Wanted to confirm with you before making any decisions/additional changes.

Thanks

```

### Reflect.setPrototypeOf
### <Reflect class="setPrototypeOf"></Reflect>
Copy link
Contributor

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.

Copy link
Member

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

Copy link
Member

@kaicataldo kaicataldo left a 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>
Copy link
Member

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

@sstern6
Copy link
Contributor Author

sstern6 commented Sep 28, 2016

Apologize @kaicataldo for the confusion. Only the apply section, including the exceptions will be updated with myFunction and obj.myMethod.

Updated file coming your way. Again apologize for my misunderstanding and the confusion.

@eslintbot
Copy link

LGTM

@kaicataldo
Copy link
Member

No need to apologize - thanks again for working on this

@kaicataldo kaicataldo merged commit 66adac1 into eslint:master Sep 28, 2016
@kaicataldo
Copy link
Member

LGTM. Thanks for contributing to ESLint!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation bug: missing Reflect.apply() argument in examples
9 participants