From 9115160c2ff451e0b6475f8648983d0253777dc4 Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Sun, 20 Sep 2020 19:54:08 -0400 Subject: [PATCH] Enable and fix all jsdoc rule violations (https://github.com/woocommerce/woocommerce-blocks/pull/3168) * add param jsdocs to satisfy jsdoc require-param rule * Fix jsdoc-checktypes rule violations * fix jsdoc/require-param-type rule violations * fix jsdoc/check-param-names violations * fix jsdoc/require-property-description rule violations * fix rule violations for jsdoc/valid-types rule * fix rule violations for jsdoc/require-property rule * fix jsdoc/no-undefined-types rule violations * fix jsdoc/check-types rule violations * fix jsdoc/require-returns-description rule violation * enable jsdoc/require-returns-type rule * fix jsdoc/newline-after-description rule violations --- plugins/woocommerce-blocks/.eslintrc.js | 15 +++------------ .../variable/variation-attributes/index.js | 4 ++++ .../add-to-cart/shared/add-to-cart-button.js | 15 ++++++++++++++- .../add-to-cart/shared/quantity-input.js | 7 +++++++ .../atomic/blocks/product-elements/price/block.js | 1 - .../atomic/blocks/product-elements/title/block.js | 1 - .../assets/js/base/components/button/index.js | 11 ++++++++++- .../cart-checkout/address-form/index.js | 9 +++++++++ .../cart-checkout/payment-method-icons/index.js | 5 +++-- .../payment-method-icons/payment-method-icon.js | 5 +++++ .../cart-checkout/product-image/index.js | 3 +++ .../product-low-stock-badge/index.js | 3 +++ .../cart-checkout/product-summary/index.js | 5 +++++ .../cart-checkout/product-variation-data/index.js | 4 ++++ .../cart-checkout/shipping-location/index.js | 3 +++ .../totals/totals-shipping-item/index.js | 7 +++++++ .../js/base/components/checkbox-control/index.js | 8 ++++++++ .../js/base/components/checkbox-list/index.js | 9 +++++++++ .../assets/js/base/components/chip/chip.js | 11 +++++++++++ .../js/base/components/chip/removable-chip.js | 10 ++++++++++ .../js/base/components/dropdown-selector/index.js | 11 +++++++++++ .../components/formatted-monetary-amount/index.js | 5 +++++ .../assets/js/base/components/label/index.js | 6 ++++++ .../js/base/components/price-slider/index.js | 11 +++++++++++ .../js/base/components/sort-select/index.js | 11 +++++++++++ .../assets/js/base/components/summary/utils.js | 2 +- .../assets/js/base/components/title/index.js | 8 ++++++++ .../add-to-cart-form/form-state/reducer.js | 3 +++ .../cart-checkout/checkout-state/reducer.js | 5 +++++ .../cart-checkout/payment-methods/reducer.js | 5 +++++ .../base/context/cart-checkout/shipping/index.js | 3 +++ .../js/base/context/container-width-context.js | 5 +++++ .../js/base/context/shared/event-emit/reducer.js | 5 +++++ .../js/base/context/shared/validation/index.js | 4 ++++ .../js/base/context/store-notices-context.js | 7 +++++++ .../hooks/use-position-relative-to-viewport.js | 2 ++ .../assets/js/base/utils/address.js | 4 ++++ .../js/base/utils/get-intersection-observer.js | 6 ++++-- .../assets/js/base/utils/legacy-events.js | 4 +++- .../get-registered-block-components.js | 2 -- .../block-components/register-block-component.js | 2 -- .../active-filters/active-attribute-filters.js | 6 ++++++ .../assets/js/blocks/active-filters/block.js | 4 ++++ .../assets/js/blocks/active-filters/index.js | 4 +--- .../assets/js/blocks/attribute-filter/block.js | 4 ++++ .../assets/js/blocks/attribute-filter/index.js | 4 +--- .../assets/js/blocks/attribute-filter/label.js | 4 ++++ .../cart-checkout/cart/checkout-button/index.js | 3 +++ .../assets/js/blocks/cart-checkout/cart/edit.js | 5 +++++ .../cart-checkout/cart/empty-cart-edit/index.js | 3 +++ .../blocks/cart-checkout/cart/full-cart/index.js | 3 +++ .../assets/js/blocks/cart-checkout/cart/index.js | 4 +--- .../js/blocks/cart-checkout/checkout/block.js | 3 ++- .../checkout/checkout-order-error/index.js | 9 ++++++--- .../js/blocks/cart-checkout/checkout/index.js | 5 ++--- .../assets/js/blocks/featured-category/block.js | 12 ++++++++++++ .../assets/js/blocks/featured-product/block.js | 13 +++++++++++++ .../assets/js/blocks/price-filter/block.js | 2 ++ .../assets/js/blocks/price-filter/index.js | 4 +--- .../assets/js/blocks/product-categories/block.js | 5 +++++ .../assets/js/blocks/product-search/block.js | 9 +++++++++ .../assets/js/blocks/product-search/edit.js | 11 +++++++++++ .../js/blocks/products/all-products/index.js | 6 +----- .../assets/js/blocks/reviews/all-reviews/edit.js | 4 ++++ .../assets/js/blocks/reviews/frontend-block.js | 7 +++++++ .../js/blocks/reviews/reviews-by-category/edit.js | 5 +++++ .../js/blocks/reviews/reviews-by-product/edit.js | 5 +++++ .../assets/js/blocks/single-product/block.js | 7 +++++++ .../js/blocks/single-product/edit/api-error.js | 5 +++++ .../single-product/edit/editor-block-controls.js | 4 ++++ .../assets/js/blocks/single-product/edit/index.js | 10 ++++++++++ .../blocks/single-product/edit/layout-editor.js | 5 +++++ .../single-product/edit/shared-product-control.js | 4 ++++ .../js/editor-components/feedback-prompt/index.js | 4 ++++ .../grid-content-control/index.js | 4 ++++ .../grid-layout-control/index.js | 6 ++++++ .../product-orderby-control/index.js | 4 ++++ .../editor-components/products-control/index.js | 1 + .../assets/js/editor-components/utils/index.js | 10 ++++++---- .../payment-methods/cod/index.js | 7 +++++-- .../stripe/credit-card/elements.js | 10 ++++++++++ .../stripe/stripe-utils/type-defs.js | 4 ++++ .../payment-methods/stripe/stripe-utils/utils.js | 6 +++++- .../assets/js/settings/shared/get-setting.js | 1 - .../assets/js/settings/shared/set-setting.js | 1 - .../assets/js/type-defs/contexts.js | 13 +++++++------ .../assets/js/type-defs/hooks.js | 5 ++++- .../type-defs/registered-payment-method-props.js | 12 ++++++------ .../rules/feature-flag.js | 2 +- .../tests/e2e/fixtures/fixture-data.js | 2 ++ .../tests/utils/find-label-with-text.js | 4 +++- 91 files changed, 448 insertions(+), 74 deletions(-) diff --git a/plugins/woocommerce-blocks/.eslintrc.js b/plugins/woocommerce-blocks/.eslintrc.js index c21dc02830a..d6378bb682c 100644 --- a/plugins/woocommerce-blocks/.eslintrc.js +++ b/plugins/woocommerce-blocks/.eslintrc.js @@ -14,6 +14,9 @@ module.exports = { context: 'readonly', jestPuppeteer: 'readonly', }, + settings: { + jsdoc: { mode: 'typescript' }, + }, rules: { 'woocommerce/feature-flag': 'off', // @todo Remove temporary disabling of various eslint rules. @@ -38,18 +41,6 @@ module.exports = { // - @worpdress/no-unused-vars-before-return // - testing-library/no-await-sync-query // - @woocommerce/dependency-group - 'jsdoc/require-param': 'off', - 'jsdoc/check-tag-names': 'off', - 'jsdoc/check-param-names': 'off', - 'jsdoc/require-property-description': 'off', - 'jsdoc/valid-types': 'off', - 'jsdoc/require-property': 'off', - 'jsdoc/no-undefined-types': 'off', - 'jsdoc/check-types': 'off', - 'jsdoc/require-returns-description': 'off', - 'jsdoc/require-param-type': 'off', - 'jsdoc/require-returns-type': 'off', - 'jsdoc/newline-after-description': 'off', '@wordpress/i18n-translator-comments': 'off', '@wordpress/valid-sprintf': 'off', '@wordpress/no-unused-vars-before-return': 'off', diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/variation-attributes/index.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/variation-attributes/index.js index 8509e7e518e..36949f19f5c 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/variation-attributes/index.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/variation-attributes/index.js @@ -7,6 +7,10 @@ import { getAttributes, getVariationAttributes } from './utils'; /** * VariationAttributes component. + * + * @param {Object} props Incoming props + * @param {Object} props.product Product + * @param {Object} props.dispatchers An object where values are dispatching functions. */ const VariationAttributes = ( { product, dispatchers } ) => { const attributes = getAttributes( product.attributes ); diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js index 6de8094f06e..8d5c3dcf260 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/add-to-cart-button.js @@ -84,7 +84,12 @@ const AddToCartButton = () => { }; /** - * Button for non-purchasable products. + * Button component for non-purchasable products. + * + * @param {Object} props Incoming props. + * @param {string} props.className Css classnames. + * @param {string} props.href Link for button. + * @param {string} props.text Text content for button. */ const LinkComponent = ( { className, href, text } ) => { return ( @@ -96,6 +101,14 @@ const LinkComponent = ( { className, href, text } ) => { /** * Button for purchasable products. + * + * @param {Object} props Incoming props for component + * @param {string} props.className Incoming css class name. + * @param {number} props.quantityInCart Quantity of item in cart. + * @param {boolean} props.isProcessing Whether processing action is occurring. + * @param {boolean} props.isDisabled Whether the button is disabled or not. + * @param {boolean} props.isDone Whether processing is done. + * @param {function():any} props.onClick Callback to execute when button is clicked. */ const ButtonComponent = ( { className, diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/quantity-input.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/quantity-input.js index dfcbf2ebca6..5f275ab98ac 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/quantity-input.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/add-to-cart/shared/quantity-input.js @@ -1,5 +1,12 @@ /** * Quantity Input Component. + * + * @param {Object} props Incoming props for component + * @param {boolean} props.disabled Whether input is disabled or not. + * @param {number} props.min Minimum value for input. + * @param {number} props.max Maximum value for input. + * @param {number} props.value Value for input. + * @param {function():any} props.onChange Function to call on input change event. */ const QuantityInput = ( { disabled, min, max, value, onChange } ) => { return ( diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/block.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/block.js index 93286f37e80..dadc6cc2ca2 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/block.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/block.js @@ -27,7 +27,6 @@ import { withProductDataContext } from '@woocommerce/shared-hocs'; * @param {string} [props.customColor] Normal Price custom text color. * @param {string} [props.saleColor] Original Price text color. * @param {string} [props.customSaleColor] Original Price custom text color. - * @param {Object} [props.product] Optional product object. Product from * context will be used if this is not provided. * @return {*} The component. */ diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js index a85b4151457..7de86109bb7 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/title/block.js @@ -30,7 +30,6 @@ import './style.scss'; * @param {string} [props.customColor] Custom title color value. * @param {string} [props.fontSize] Title font size name. * @param {number } [props.customFontSize] Custom font size value. - * @param {Object} [props.product] Optional product object. Product from context * will be used if this is not provided. * @return {*} The component. */ diff --git a/plugins/woocommerce-blocks/assets/js/base/components/button/index.js b/plugins/woocommerce-blocks/assets/js/base/components/button/index.js index 484ed304a93..efffbb8db5e 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/button/index.js +++ b/plugins/woocommerce-blocks/assets/js/base/components/button/index.js @@ -10,8 +10,17 @@ import classNames from 'classnames'; */ import './style.scss'; +/** @typedef {import('react')} React */ + /** - * Component that visually renders a button but semantically might be `