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

Add JSDoc comment to Popover's focus() method #8312

Merged
merged 1 commit into from
Jul 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/components/src/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ class Popover extends Component {
this.rafHandle = window.requestAnimationFrame( () => this.computePopoverPosition() );
}

/**
* Calling `refresh()` will force the Popover to recalculate its size and
* position. This is useful when a DOM change causes the anchor node to change
* position.
*
* @return {void}
Copy link
Member

Choose a reason for hiding this comment

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

There's a bit of a convention to not explicitly document the undefined return value. I seem to recall some discussion on it, but it should be formalized if we want to follow one way or the other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we add a lint rule one way or the other?

Copy link
Member

Choose a reason for hiding this comment

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

Looking at this page, it might be possible by "requireReturn": false:

https://eslint.org/docs/rules/valid-jsdoc#options

false if and only if the function or method has a return statement or returns a value e.g. async function (this option value does apply to constructors)

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like that's what we're doing:

requireReturn: false,

I guess there's no way to require no @return {void} which is a shame.

Which is the lesser of two evils? Having to type @return {void} all the time, or allowing inconsistency? 😛

Copy link
Member

Choose a reason for hiding this comment

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

Or creating our own JSDoc rule!

*/
refresh() {
const popoverSize = this.updatePopoverSize();
this.computePopoverPosition( popoverSize );
Expand Down