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(eslint-plugin): misc bugfixes related to recent jsdoc changes #16975

Merged
merged 3 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/designers-developers/developers/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ _Parameters_

_Returns_

- `booleans`: Is the preview for the URL an oEmbed link fallback.
- `boolean`: Is the preview for the URL an oEmbed link fallback.

<a name="isRequestingEmbedPreview" href="#isRequestingEmbedPreview">#</a> **isRequestingEmbedPreview**

Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/components/inserter/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Inserter extends Component {
/**
* Render callback to display Dropdown toggle element.
*
* @param {Object} options
* @param {Function} options.onToggle Callback to invoke when toggle is
* pressed.
* @param {boolean} options.isOpen Whether dropdown is currently open.
Expand All @@ -63,6 +64,7 @@ class Inserter extends Component {
/**
* Render callback to display Dropdown content element.
*
* @param {Object} options
* @param {Function} options.onClose Callback to invoke when dropdown is
* closed.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Tooltip extends Component {
* Creates an event callback to handle assignment of the `isInMouseDown`
* instance property in response to a `mousedown` or `mouseup` event.
*
* @param {booelan} isMouseDown Whether handler is to be created for the
* @param {boolean} isMouseDown Whether handler is to be created for the
* `mousedown` event, as opposed to `mouseup`.
*
* @return {Function} Event callback handler.
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ _Parameters_

_Returns_

- `booleans`: Is the preview for the URL an oEmbed link fallback.
- `boolean`: Is the preview for the URL an oEmbed link fallback.

<a name="isRequestingEmbedPreview" href="#isRequestingEmbedPreview">#</a> **isRequestingEmbedPreview**

Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export function getEmbedPreview( state, url ) {
* @param {Object} state Data state.
* @param {string} url Embedded URL.
*
* @return {booleans} Is the preview for the URL an oEmbed link fallback.
* @return {boolean} Is the preview for the URL an oEmbed link fallback.
*/
export function isPreviewEmbedFallback( state, url ) {
const preview = state.embedPreviews[ url ];
Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-plugin/configs/es5.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
extends: [
Copy link
Member

Choose a reason for hiding this comment

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

Cool, thanks for making closer to what we had before 💯

require.resolve( './jsdoc.js' ),
],
rules: {
'array-bracket-spacing': [ 'error', 'always' ],
'array-callback-return': 'error',
Expand Down
39 changes: 35 additions & 4 deletions packages/eslint-plugin/configs/jsdoc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
const globals = require( 'globals' );

/**
* Helpful utilities that are globally defined and known to the TypeScript compiler.
*
* @see http://www.typescriptlang.org/docs/handbook/utility-types.html
*/
const typescriptUtilityTypes = [
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, this comes from the official TypeScript npm package but I guess it wouldn't be as easy to extract. I did a quick google search and I didn't find anything that would fit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, unfortunately they aren't able to be extracted in this way because they're defined as types and/or interfaces. It would be much cleaner though if that was possible, I agree.

'ArrayLike',
'Exclude',
'Extract',
'InstanceType',
'Iterable',
'IterableIterator',
'NonNullable',
'Omit',
'Partial',
'Pick',
'PromiseLike',
'Readonly',
'ReadonlyArray',
'ReadonlyMap',
'ReadonlySet',
'Record',
'Required',
'ReturnType',
'ThisType',
];

module.exports = {
extends: [
'plugin:jsdoc/recommended',
Expand All @@ -17,10 +44,14 @@ module.exports = {
},
rules: {
'jsdoc/no-undefined-types': [ 'warn', {
// Required to reference browser types because we don't have the `browser` environment enabled for the project.
// Here we filter out all browser globals that don't begin with an uppercase letter because those
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`).
definedTypes: Object.keys( globals.browser ).filter( ( k ) => /^[A-Z]/.test( k ) ),
definedTypes: [
// Required to reference browser types because we don't have the `browser` environment enabled for the project.
// Here we filter out all browser globals that don't begin with an uppercase letter because those
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`).
...Object.keys( globals.browser ).filter( ( k ) => /^[A-Z]/.test( k ) ),
...typescriptUtilityTypes,
'void',
],
} ],
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param-description': 'off',
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = {
require.resolve( './custom.js' ),
require.resolve( './react.js' ),
require.resolve( './esnext.js' ),
require.resolve( './jsdoc.js' ),
],
env: {
node: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/token-list/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class TokenList {
*
* @see https://dom.spec.whatwg.org/#domtokenlist
*
* @return {Generator} TokenList iterator.
* @return {IterableIterator<string>} TokenList iterator.
*/
* [ Symbol.iterator ]() {
return yield* this._valueAsArray;
Expand Down