Skip to content

Commit

Permalink
ESLint Plugin: Update eslint jsdoc dependency (#34338)
Browse files Browse the repository at this point in the history
* Update eslint-plugin-jsdoc dependency

* Fix JSDoc comment

* Update eslint rules disabling some of them

It disables some rules that are failing after the eslint plugin
update.

* Update no-multi-asterisks rule options

* Enable and fix jsdoc/valid-types eslint rule

* Update CHANGELOG.md

* Fix jsdoc line alignment

Co-authored-by: Renatho De Carli Rosa <[email protected]>
Co-authored-by: Greg Ziółkowski <[email protected]>
  • Loading branch information
3 people authored Sep 8, 2021
1 parent cb36e1c commit b220881
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 36 deletions.
66 changes: 36 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function* validateBlocksToTemplate( blocks ) {
* text value. See `wp.richText.create`.
*/

/* eslint-disable jsdoc/valid-types */
/**
* Returns an action object used in signalling that selection state should be
* reset to the specified selection.
Expand All @@ -138,6 +139,7 @@ export function resetSelection(
selectionEnd,
initialPosition
) {
/* eslint-enable jsdoc/valid-types */
return {
type: 'RESET_SELECTION',
selectionStart,
Expand Down Expand Up @@ -209,6 +211,7 @@ export function updateBlock( clientId, updates ) {
};
}

/* eslint-disable jsdoc/valid-types */
/**
* Returns an action object used in signalling that the block with the
* specified client ID has been selected, optionally accepting a position
Expand All @@ -222,6 +225,7 @@ export function updateBlock( clientId, updates ) {
* @return {Object} Action object.
*/
export function selectBlock( clientId, initialPosition = 0 ) {
/* eslint-enable jsdoc/valid-types */
return {
type: 'SELECT_BLOCK',
initialPosition,
Expand Down Expand Up @@ -389,6 +393,7 @@ function getBlocksWithDefaultStylesApplied( blocks, blockEditorSettings ) {
} );
}

/* eslint-disable jsdoc/valid-types */
/**
* Returns an action object signalling that a blocks should be replaced with
* one or more replacement blocks.
Expand All @@ -408,6 +413,7 @@ export function* replaceBlocks(
initialPosition = 0,
meta
) {
/* eslint-enable jsdoc/valid-types */
clientIds = castArray( clientIds );
blocks = getBlocksWithDefaultStylesApplied(
castArray( blocks ),
Expand Down Expand Up @@ -594,6 +600,7 @@ export function insertBlock(
);
}

/* eslint-disable jsdoc/valid-types */
/**
* Returns an action object used in signalling that an array of blocks should
* be inserted, optionally at a specific index respective a root block list.
Expand All @@ -614,6 +621,7 @@ export function* insertBlocks(
initialPosition = 0,
meta
) {
/* eslint-enable jsdoc/valid-types */
if ( isObject( initialPosition ) ) {
meta = initialPosition;
initialPosition = 0;
Expand Down Expand Up @@ -954,6 +962,7 @@ export function removeBlock( clientId, selectPrevious ) {
return removeBlocks( [ clientId ], selectPrevious );
}

/* eslint-disable jsdoc/valid-types */
/**
* Returns an action object used in signalling that the inner blocks with the
* specified client ID should be replaced.
Expand All @@ -970,6 +979,7 @@ export function replaceInnerBlocks(
updateSelection = false,
initialPosition = 0
) {
/* eslint-enable jsdoc/valid-types */
return {
type: 'REPLACE_INNER_BLOCKS',
rootClientId,
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ export function getNextBlockClientId( state, startClientId ) {
return getAdjacentBlockClientId( state, startClientId, 1 );
}

/* eslint-disable jsdoc/valid-types */
/**
* Returns the initial caret position for the selected block.
* This position is to used to position the caret properly when the selected block changes.
Expand All @@ -646,6 +647,7 @@ export function getNextBlockClientId( state, startClientId ) {
* @return {0|-1|null} Initial position.
*/
export function getSelectedBlocksInitialCaretPosition( state ) {
/* eslint-enable jsdoc/valid-types */
return state.initialPosition;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/gallery/v1/tiles.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function Tiles( props ) {
const lastRow = Math.floor( lastTile / columns );

const wrappedChildren = Children.map( children, ( child, index ) => {
/** Since we don't have `calc()`, we must calculate our spacings here in
/**
* Since we don't have `calc()`, we must calculate our spacings here in
* order to preserve even spacing between tiles and equal width for tiles
* in a given row.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/animate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import classnames from 'classnames';
* @typedef {'left' | 'right'} SlideInOrigin
* @typedef {{ type: 'appear'; origin?: AppearOrigin }} AppearOptions
* @typedef {{ type: 'slide-in'; origin?: SlideInOrigin }} SlideInOptions
* @typedef {{ type: 'loading'; }} LoadingOptions
* @typedef {{ type: 'loading' }} LoadingOptions
* @typedef {AppearOptions | SlideInOptions | LoadingOptions} GetAnimateOptions
*/

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/ui/context/use-context-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useCx } from '../../utils/hooks/use-cx';

/**
* @template TProps
* @typedef {TProps & { className: string; }} ConnectedProps
* @typedef {TProps & { className: string }} ConnectedProps
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/dom/src/dom/caret-range-from-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
*
* @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.
* @param {number} x Horizontal position within the current viewport.
* @param {number} y Vertical position within the current viewport.
* @param {number} x Horizontal position within the current viewport.
* @param {number} y Vertical position within the current viewport.
*
* @return {Range | null} The best range for the given point.
*/
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancement

- The bundled `eslint-plugin-jsdoc` dependency has been updated from requiring `^34.1.0` to requiring `^36.0.8` ([#34338](https://github.com/WordPress/gutenberg/pull/34338)).

### Bug Fix

- The recommended configuration will now respect `type` imports in TypeScript files ([#34055](https://github.com/WordPress/gutenberg/pull/34055)).
Expand Down
5 changes: 5 additions & 0 deletions packages/eslint-plugin/configs/jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ module.exports = {
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/require-yields': 'off',
'jsdoc/tag-lines': 'off',
'jsdoc/no-multi-asterisks': [
'error',
{ preventAtMiddleLines: false },
],
'jsdoc/check-access': 'error',
'jsdoc/check-alignment': 'error',
'jsdoc/check-line-alignment': [
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jsdoc": "^34.1.0",
"eslint-plugin-jsdoc": "^36.0.8",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-react": "^7.22.0",
Expand Down

0 comments on commit b220881

Please sign in to comment.