From d517b75158ba454d084028ccc825ee00ff39c55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 09:36:59 +0200 Subject: [PATCH 01/20] fix refactor Repeater away from prop types --- components/repeater/index.js | 88 ++++++------------------------------ 1 file changed, 14 insertions(+), 74 deletions(-) diff --git a/components/repeater/index.js b/components/repeater/index.js index 7830750f..2dd25037 100644 --- a/components/repeater/index.js +++ b/components/repeater/index.js @@ -4,7 +4,6 @@ import { useSelect, dispatch } from '@wordpress/data'; import { cloneElement } from '@wordpress/element'; import { Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import PropTypes from 'prop-types'; import { v4 as uuid } from 'uuid'; import { @@ -37,7 +36,7 @@ import { DragHandle } from '../drag-handle'; * @param {string} props.id A string identifier for a repeater item. * @returns {*} React JSX */ -const SortableItem = ({ children, item, setItem, removeItem, id }) => { +const SortableItem = ({ children, item = {}, setItem = null, removeItem = null, id = '' }) => { const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id, }); @@ -83,11 +82,11 @@ const SortableItem = ({ children, item, setItem, removeItem, id }) => { */ export const AbstractRepeater = ({ children, - addButton, - allowReordering, + addButton = null, + allowReordering = false, onChange, value, - defaultValue, + defaultValue = [], }) => { const sensors = useSensors( useSensor(PointerSensor), @@ -219,7 +218,12 @@ export const AbstractRepeater = ({ ); }; -export const AttributeRepeater = ({ children, attribute, addButton, allowReordering }) => { +export const AttributeRepeater = ({ + children, + attribute = null, + addButton = null, + allowReordering = false, +}) => { const { clientId, name } = useBlockEditContext(); const { updateBlockAttributes } = dispatch(blockEditorStore); @@ -258,12 +262,12 @@ export const AttributeRepeater = ({ children, attribute, addButton, allowReorder export const Repeater = ({ children, - addButton, - allowReordering, + addButton = null, + allowReordering = false, onChange, value, - defaultValue, - attribute, + defaultValue = [], + attribute = null, }) => { if (attribute) { return ( @@ -289,67 +293,3 @@ export const Repeater = ({ ); }; - -Repeater.propTypes = { - children: PropTypes.func.isRequired, - addButton: PropTypes.func, - attribute: PropTypes.string, - allowReordering: PropTypes.bool, - onChange: PropTypes.func.isRequired, - value: PropTypes.array.isRequired, - defaultValue: PropTypes.array, -}; - -Repeater.defaultProps = { - attribute: null, - addButton: null, - allowReordering: false, - defaultValue: [], -}; - -AttributeRepeater.propTypes = { - children: PropTypes.func.isRequired, - attribute: PropTypes.string, - addButton: PropTypes.func, - allowReordering: PropTypes.bool, -}; - -AttributeRepeater.defaultProps = { - attribute: null, - addButton: null, - allowReordering: false, -}; - -AbstractRepeater.propTypes = { - children: PropTypes.func.isRequired, - addButton: PropTypes.func, - allowReordering: PropTypes.bool, - onChange: PropTypes.func.isRequired, - value: PropTypes.array.isRequired, - defaultValue: PropTypes.array, -}; - -AbstractRepeater.defaultProps = { - addButton: null, - allowReordering: false, - defaultValue: [], -}; - -SortableItem.defaultProps = { - attribute: 'items', - addItem: null, - setItem: null, - removeItem: null, - item: {}, - id: '', -}; - -SortableItem.propTypes = { - children: PropTypes.func.isRequired, - attribute: PropTypes.string, - addItem: PropTypes.func, - setItem: PropTypes.func, - removeItem: PropTypes.func, - item: PropTypes.object, - id: PropTypes.string, -}; From 2bf3f6eb932c43859d1315a891dd3ad6d5bdeffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 11:56:06 +0200 Subject: [PATCH 02/20] fix move defaultProps to inline default values in ClipboardButton component --- components/clipboard-button/index.tsx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/components/clipboard-button/index.tsx b/components/clipboard-button/index.tsx index a7407e7b..826fe860 100644 --- a/components/clipboard-button/index.tsx +++ b/components/clipboard-button/index.tsx @@ -38,10 +38,10 @@ interface ButtonLabels { } export const ClipboardButton: React.FC = ({ - text, - disabled, - onSuccess, - labels, + text = '', + disabled = false, + onSuccess = () => {}, + labels = {}, }) => { const [hasCopied, setHasCopied] = useState(false); const copy = labels.copy ? labels.copy : __('Copy'); @@ -84,10 +84,3 @@ export const ClipboardButton: React.FC = ({ ); }; - -ClipboardButton.defaultProps = { - text: '', - disabled: false, - onSuccess: () => {}, - labels: {}, -}; From 4e268c70761a54a15573143256141d6145914b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 11:57:07 +0200 Subject: [PATCH 03/20] fix remove propTypes & defaultProps from RichTextCharacterLimit component --- components/rich-text-character-limit/index.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/components/rich-text-character-limit/index.js b/components/rich-text-character-limit/index.js index 27c5fef1..387621bb 100644 --- a/components/rich-text-character-limit/index.js +++ b/components/rich-text-character-limit/index.js @@ -2,7 +2,6 @@ import { useState, useEffect } from '@wordpress/element'; import { RichText, useBlockEditContext } from '@wordpress/block-editor'; import { create, remove, getTextContent, toHTMLString } from '@wordpress/rich-text'; import { useFloating, autoUpdate } from '@floating-ui/react-dom'; -import PropTypes from 'prop-types'; import { Counter } from '../counter'; /** @@ -118,15 +117,3 @@ const RichTextCharacterLimit = (props) => { }; export { RichTextCharacterLimit, getCharacterCount }; - -RichTextCharacterLimit.defaultProps = { - limit: 100, - enforce: true, -}; - -RichTextCharacterLimit.propTypes = { - limit: PropTypes.number, - enforce: PropTypes.bool, - value: PropTypes.string.isRequired, - onChange: PropTypes.func.isRequired, -}; From 49bcc31b20a32818942daa619a8323ca9138c0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 11:57:37 +0200 Subject: [PATCH 04/20] fix remove propTypes & defaultProps from ListItem component --- components/post-term-list/item.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/components/post-term-list/item.js b/components/post-term-list/item.js index df44640f..30e8353d 100644 --- a/components/post-term-list/item.js +++ b/components/post-term-list/item.js @@ -1,5 +1,4 @@ import { useContext } from '@wordpress/element'; -import PropTypes from 'prop-types'; import { PostTermContext } from './context'; export const ListItem = (props) => { @@ -8,15 +7,6 @@ export const ListItem = (props) => { return {children}; }; -ListItem.propTypes = { - tagName: PropTypes.string, - children: PropTypes.node.isRequired, -}; - -ListItem.defaultProps = { - tagName: 'li', -}; - export const TermLink = (props) => { const { link, name } = useContext(PostTermContext); From 7d268dbb569ecc848405ca636e91ff55a8e54cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 11:59:28 +0200 Subject: [PATCH 05/20] fix remove propTypes & defaultProps from CustomBlockAppender component --- components/custom-block-appender/index.js | 28 ++--------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/components/custom-block-appender/index.js b/components/custom-block-appender/index.js index d34c768e..4b1645bb 100644 --- a/components/custom-block-appender/index.js +++ b/components/custom-block-appender/index.js @@ -1,12 +1,3 @@ -/* eslint-disable react/jsx-props-no-spreading */ -/** - * External dependencies - */ -import PropTypes from 'prop-types'; - -/** - * WordPress dependencies - */ import { Inserter } from '@wordpress/block-editor'; import { Button } from '@wordpress/components'; @@ -25,8 +16,8 @@ import { Button } from '@wordpress/components'; */ const CustomBlockAppender = ({ rootClientId, - buttonText, - icon, + buttonText = '', + icon = 'plus', className = 'custom-block-appender', ...buttonProps }) => { @@ -49,19 +40,4 @@ const CustomBlockAppender = ({ ); }; -CustomBlockAppender.propTypes = { - rootClientId: PropTypes.string.isRequired, - buttonText: PropTypes.string, - label: PropTypes.string, - icon: PropTypes.string, - className: PropTypes.string, -}; - -CustomBlockAppender.defaultProps = { - buttonText: '', - label: '', - icon: 'plus', - className: 'custom-block-appender', -}; - export { CustomBlockAppender }; From 0eb87291fd1f1f2f0e9a9ac8a998fa5dd1cde9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:00:45 +0200 Subject: [PATCH 06/20] fix remove defaultProps & propTypes from Image component --- components/image/index.js | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/components/image/index.js b/components/image/index.js index a76c3bfe..48b730b7 100644 --- a/components/image/index.js +++ b/components/image/index.js @@ -1,17 +1,16 @@ import { MediaPlaceholder, InspectorControls } from '@wordpress/block-editor'; import { Spinner, FocalPointPicker, PanelBody, Placeholder } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import PropTypes from 'prop-types'; import { useMedia } from '../../hooks/use-media'; -const Image = (props) => { +export const Image = (props) => { const { id, size = 'full', onSelect, focalPoint = { x: 0.5, y: 0.5 }, - onChangeFocalPoint, + onChangeFocalPoint = undefined, labels = {}, canEditImage = true, allowedTypes = ['image'], @@ -75,31 +74,3 @@ const Image = (props) => { ); }; - -export { Image }; - -Image.defaultProps = { - size: 'large', - focalPoint: { x: 0.5, y: 0.5 }, - onChangeFocalPoint: undefined, - labels: {}, - canEditImage: true, - allowedTypes: ['image'], -}; - -Image.propTypes = { - id: PropTypes.number.isRequired, - size: PropTypes.string, - onSelect: PropTypes.func.isRequired, - onChangeFocalPoint: PropTypes.func, - allowedTypes: PropTypes.array, - focalPoint: PropTypes.shape({ - x: PropTypes.string, - y: PropTypes.string, - }), - labels: PropTypes.shape({ - title: PropTypes.string, - instructions: PropTypes.string, - }), - canEditImage: PropTypes.bool, -}; From 26967ac74ac3955946d0f03f5eddf78dade7e7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:02:21 +0200 Subject: [PATCH 07/20] remove defaultProps & propTypes from InnerBlockSlider component --- components/inner-block-slider/index.js | 27 ++++---------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/components/inner-block-slider/index.js b/components/inner-block-slider/index.js index 755b4c6e..9b24d5f6 100644 --- a/components/inner-block-slider/index.js +++ b/components/inner-block-slider/index.js @@ -1,23 +1,20 @@ /* eslint-disable */ // @ts-nocheck -// eslint-disable-file import { useSelect, useDispatch } from '@wordpress/data'; import { useEffect, useState, useRef } from '@wordpress/element'; import { createBlock } from '@wordpress/blocks'; import { useInnerBlocksProps } from '@wordpress/block-editor'; import deprecated from '@wordpress/deprecated'; -import PropTypes from 'prop-types'; /** @jsx jsx */ -// eslint-disable-next-line no-unused-vars import { jsx, css } from '@emotion/react'; import { ChevronLeft, ChevronRight } from './icons'; -const InnerBlockSlider = ({ +export const InnerBlockSlider = ({ parentBlockId, - slidesPerPage, + slidesPerPage = 1, allowedBlock, - template, - slideHeight, + template = null, + slideHeight = null, }) => { const [currentPage, setCurrentPage] = useState(1); @@ -173,19 +170,3 @@ const InnerBlockSlider = ({ ); }; - -InnerBlockSlider.defaultProps = { - slidesPerPage: 1, - template: null, - slideHeight: null, -}; - -InnerBlockSlider.propTypes = { - slidesPerPage: PropTypes.number, - parentBlockId: PropTypes.string.isRequired, - allowedBlock: PropTypes.string.isRequired, - template: PropTypes.array, - slideHeight: PropTypes.string, -}; - -export { InnerBlockSlider }; From b315bcf79fd586b48ed9dc533ee65d0ac1e55874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:04:54 +0200 Subject: [PATCH 08/20] remove prop types eslint rule --- .eslintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 453ad550..6286f494 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,6 +8,7 @@ "import/no-extraneous-dependencies": 0, "react/jsx-props-no-spreading": 0, "jsdoc/check-tag-names": 0, - "import/extensions": 0 + "import/extensions": 0, + "react/prop-types": 0 } } \ No newline at end of file From 0d0fca19a0da49a28d4f63f51aa212449aee59c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:05:20 +0200 Subject: [PATCH 09/20] remove defaultProps & propTypes from PostCategoryList --- components/post-category-list/index.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/components/post-category-list/index.js b/components/post-category-list/index.js index 87c500e9..b87fd664 100644 --- a/components/post-category-list/index.js +++ b/components/post-category-list/index.js @@ -1,14 +1,8 @@ -import PropTypes from 'prop-types'; import { __ } from '@wordpress/i18n'; import { PostTermList } from '../post-term-list'; -export const PostCategoryList = PostTermList; - -PostCategoryList.propTypes = { - taxonomyName: PropTypes.string, -}; - -PostCategoryList.defaultProps = { - taxonomyName: 'category', - noResultsMessage: __('Please select a category', 'tenup'), -}; +export const PostCategoryList = ({ + taxonomyName = 'category', + noResultsMessage = __('Please select a category', 'tenup'), + ...rest +}) => ; From 83c8b9e8a2f59151d364bfd6ac592ebc41ef5b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:07:03 +0200 Subject: [PATCH 10/20] remove defaultProps & propTypes from Link Component --- components/link/index.js | 42 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/components/link/index.js b/components/link/index.js index d183f6ac..c24fd679 100644 --- a/components/link/index.js +++ b/components/link/index.js @@ -3,7 +3,6 @@ */ import classnames from 'classnames'; import styled from '@emotion/styled'; -import PropTypes from 'prop-types'; /** * WordPress dependencies @@ -105,17 +104,17 @@ const StylesRichTextLink = styled(RichText)` * * @returns {*} The rendered component. */ -const Link = ({ - value, - type, +export const Link = ({ + value = undefined, + type = '', opensInNewTab, - url, + url = undefined, onLinkChange, onTextChange, - onLinkRemove, - kind, - placeholder, - className, + onLinkRemove = null, + kind = '', + placeholder = __('Link text ...', '10up-block-components'), + className = undefined, ...rest }) => { const [isPopoverVisible, setIsPopoverVisible] = useState(false); @@ -201,28 +200,3 @@ const Link = ({ ); }; - -Link.defaultProps = { - value: undefined, - url: undefined, - className: undefined, - onLinkRemove: null, - type: '', - kind: '', - placeholder: __('Link text ...', '10up-block-components'), -}; - -Link.propTypes = { - value: PropTypes.string, - url: PropTypes.string, - onLinkChange: PropTypes.func.isRequired, - onLinkRemove: PropTypes.func, - onTextChange: PropTypes.func.isRequired, - opensInNewTab: PropTypes.bool.isRequired, - type: PropTypes.string, - kind: PropTypes.string, - className: PropTypes.string, - placeholder: PropTypes.string, -}; - -export { Link }; From eeb1f480fdde6ee66073dd44290fa9cfa2c51bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:07:41 +0200 Subject: [PATCH 11/20] remove defaultProps & propTypes from PostExcerpt component --- components/post-excerpt/index.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/components/post-excerpt/index.js b/components/post-excerpt/index.js index 1404a71e..f2487655 100644 --- a/components/post-excerpt/index.js +++ b/components/post-excerpt/index.js @@ -1,7 +1,6 @@ import { useEntityProp } from '@wordpress/core-data'; import { __ } from '@wordpress/i18n'; import { RichText } from '@wordpress/block-editor'; -import PropTypes from 'prop-types'; import { usePost } from '../../hooks'; export const PostExcerpt = (props) => { @@ -31,11 +30,3 @@ export const PostExcerpt = (props) => { /> ); }; - -PostExcerpt.propTypes = { - placeholder: PropTypes.string, -}; - -PostExcerpt.defaultProps = { - placeholder: __('Enter excerpt...', 'tenup'), -}; From 5fd28fecb9c3d3c92712539408dbb14e97a69fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:08:44 +0200 Subject: [PATCH 12/20] remove defaultProps & propTypes from PostContext component --- components/post-context/index.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/components/post-context/index.js b/components/post-context/index.js index e0257493..01d407b4 100644 --- a/components/post-context/index.js +++ b/components/post-context/index.js @@ -1,9 +1,8 @@ -import PropTypes from 'prop-types'; import { useMemo } from '@wordpress/element'; -import { DEFAULT_POST_CONTEXT, PostContext as PostContextContext } from './context'; +import { PostContext as PostContextContext } from './context'; export const PostContext = (props) => { - const { children, postId, postType, isEditable } = props; + const { children, postId = null, postType = null, isEditable = null } = props; const value = useMemo( () => ({ @@ -16,12 +15,3 @@ export const PostContext = (props) => { return {children}; }; - -PostContext.propTypes = { - children: PropTypes.node.isRequired, - postId: PropTypes.number, - postType: PropTypes.string, - isEditable: PropTypes.bool, -}; - -PostContext.defaultProps = DEFAULT_POST_CONTEXT; From 397572b80ad5cc070df26b2de88fe4db0df88b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:10:25 +0200 Subject: [PATCH 13/20] remove defaultProps & propTypes from PostPrimaryCategory --- components/post-primary-category/index.js | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/components/post-primary-category/index.js b/components/post-primary-category/index.js index 32a24c81..2cfed246 100644 --- a/components/post-primary-category/index.js +++ b/components/post-primary-category/index.js @@ -1,17 +1,16 @@ import { __ } from '@wordpress/i18n'; -import PropTypes from 'prop-types'; import { PostPrimaryTerm } from '../post-primary-term'; -export const PostPrimaryCategory = PostPrimaryTerm; - -PostPrimaryCategory.propTypes = { - placeholder: PropTypes.string, - taxonomyName: PropTypes.string, - isLink: PropTypes.bool, -}; - -PostPrimaryCategory.defaultProps = { - placeholder: __('Select a category', 'tenup'), - taxonomyName: 'category', - isLink: true, -}; +export const PostPrimaryCategory = ({ + placeholder = __('Select a category', 'tenup'), + taxonomyName = 'category', + isLink = true, + ...rest +}) => ( + +); From 35020236d103c203e5c5cf2701ed1e4f7ca1d045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:11:16 +0200 Subject: [PATCH 14/20] remove defaultProps & propTypes from PostPrimaryTerm component --- components/post-primary-term/index.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/components/post-primary-term/index.js b/components/post-primary-term/index.js index 72ec15cf..1f383a40 100644 --- a/components/post-primary-term/index.js +++ b/components/post-primary-term/index.js @@ -1,5 +1,4 @@ import { __ } from '@wordpress/i18n'; -import PropTypes from 'prop-types'; import { usePrimaryTerm } from '../../hooks'; export const PostPrimaryTerm = (props) => { @@ -33,15 +32,3 @@ export const PostPrimaryTerm = (props) => { return {termString}; }; - -PostPrimaryTerm.propTypes = { - placeholder: PropTypes.string, - taxonomyName: PropTypes.string, - isLink: PropTypes.bool, -}; - -PostPrimaryTerm.defaultProps = { - placeholder: __('Select a Term', 'tenup'), - isLink: true, - taxonomyName: 'category', -}; From e2db8e1d246569dfdbeed5a9593e5edc25e4f78d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:15:22 +0200 Subject: [PATCH 15/20] remove defaultProps & propTypes from ContentPicker component --- components/content-picker/index.js | 91 ++++++++---------------------- 1 file changed, 23 insertions(+), 68 deletions(-) diff --git a/components/content-picker/index.js b/components/content-picker/index.js index 1e6c771e..ac7cdaea 100644 --- a/components/content-picker/index.js +++ b/components/content-picker/index.js @@ -1,4 +1,3 @@ -import PropTypes from 'prop-types'; import styled from '@emotion/styled'; import { select } from '@wordpress/data'; import { useMemo } from '@wordpress/element'; @@ -43,7 +42,7 @@ const ContentPickerWrapper = styled.div` * @param {Array} props.contentTypes array of content types to filter by * @param {string} props.placeholder placeholder text for the search input * @param {Function} props.onPickChange callback for when the picker changes - * @param {Function} props.queryFilter callback that allows to modify the query + * @param {?Function} props.queryFilter callback that allows to modify the query * @param {number} props.maxContentItems max number of items to show in the picker * @param {boolean} props.isOrderable whether or not the picker is sortable * @param {string} props.singlePickedLabel label for the single picked item @@ -54,28 +53,30 @@ const ContentPickerWrapper = styled.div` * @param {number} props.perPage number of items to show per page * @param {boolean} props.fetchInitialResults whether or not to fetch initial results on mount * @param {Function} props.renderItemType callback to render the item type - * @param {Function} props.renderItem react component to render the search result item + * @param {?Function} props.renderItem react component to render the search result item * @returns {*} React JSX */ -const ContentPicker = ({ - label, - hideLabelFromVision, - mode, - contentTypes, - placeholder, - onPickChange, - queryFilter, - maxContentItems, - isOrderable, - singlePickedLabel, - multiPickedLabel, - content, - uniqueContentItems, - excludeCurrentPost, - perPage, - fetchInitialResults, - renderItemType, - renderItem, +export const ContentPicker = ({ + label = '', + hideLabelFromVision = true, + mode = 'post', + contentTypes = ['post', 'page'], + placeholder = '', + onPickChange = (ids) => { + console.log('Content picker list change', ids); // eslint-disable-line no-console + }, + queryFilter = null, + maxContentItems = 1, + isOrderable = false, + singlePickedLabel = __('You have selected the following item:', '10up-block-components'), + multiPickedLabel = __('You have selected the following items:', '10up-block-components'), + content = [], + uniqueContentItems = true, + excludeCurrentPost = true, + perPage = 20, + fetchInitialResults = false, + renderItemType = defaultRenderItemType, + renderItem = null, }) => { const currentPostId = select('core/editor')?.getCurrentPostId(); @@ -187,49 +188,3 @@ const ContentPicker = ({ ); }; - -ContentPicker.defaultProps = { - label: '', - hideLabelFromVision: true, - mode: 'post', - onPickChange: (ids) => { - console.log('Content picker list change', ids); // eslint-disable-line no-console - }, - queryFilter: undefined, - contentTypes: ['post', 'page'], - placeholder: '', - content: [], - perPage: 20, - maxContentItems: 1, - uniqueContentItems: true, - isOrderable: false, - excludeCurrentPost: true, - multiPickedLabel: __('You have selected the following items:', '10up-block-components'), - singlePickedLabel: __('You have selected the following item:', '10up-block-components'), - fetchInitialResults: false, - renderItemType: defaultRenderItemType, - renderItem: undefined, -}; - -ContentPicker.propTypes = { - contentTypes: PropTypes.array, - content: PropTypes.array, - placeholder: PropTypes.string, - mode: PropTypes.oneOf(['post', 'user', 'term']), - label: PropTypes.string, - hideLabelFromVision: PropTypes.bool, - multiPickedLabel: PropTypes.string, - singlePickedLabel: PropTypes.string, - isOrderable: PropTypes.bool, - onPickChange: PropTypes.func, - queryFilter: PropTypes.func, - uniqueContentItems: PropTypes.bool, - excludeCurrentPost: PropTypes.bool, - maxContentItems: PropTypes.number, - perPage: PropTypes.number, - fetchInitialResults: PropTypes.bool, - renderItemType: PropTypes.func, - renderItem: PropTypes.func, -}; - -export { ContentPicker }; From 06f02c379b8aa6df32835ccd4e0a81853cf102eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:15:59 +0200 Subject: [PATCH 16/20] remove defaultProps & propTypes from PickedItem Component --- components/content-picker/PickedItem.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/components/content-picker/PickedItem.js b/components/content-picker/PickedItem.js index c45dfc83..f18e9158 100644 --- a/components/content-picker/PickedItem.js +++ b/components/content-picker/PickedItem.js @@ -1,4 +1,3 @@ -import PropTypes from 'prop-types'; import styled from '@emotion/styled'; import { useSortable } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; @@ -51,7 +50,7 @@ function getType(mode) { * @param {number|string} props.id id of the item * @returns {*} React JSX */ -const PickedItem = ({ item, isOrderable, handleItemDelete, mode, id }) => { +const PickedItem = ({ item, isOrderable = false, handleItemDelete, mode, id }) => { const type = getType(mode); const { attributes, isDragging, listeners, setNodeRef, transform, transition } = useSortable({ @@ -140,16 +139,4 @@ const PickedItem = ({ item, isOrderable, handleItemDelete, mode, id }) => { ); }; -PickedItem.defaultProps = { - isOrderable: false, -}; - -PickedItem.propTypes = { - item: PropTypes.object.isRequired, - isOrderable: PropTypes.bool, - handleItemDelete: PropTypes.func.isRequired, - mode: PropTypes.string.isRequired, - id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, -}; - export default PickedItem; From 9cbdfd350e6afeea54e038e89e09b7d29ec48023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:16:41 +0200 Subject: [PATCH 17/20] remove defaultProps & propTypes from SortableList component --- components/content-picker/SortableList.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/components/content-picker/SortableList.js b/components/content-picker/SortableList.js index 6ec8d797..baaa2a59 100644 --- a/components/content-picker/SortableList.js +++ b/components/content-picker/SortableList.js @@ -7,10 +7,15 @@ import { useSensors, } from '@dnd-kit/core'; import { arrayMove, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'; -import PropTypes from 'prop-types'; import PickedItem from './PickedItem'; -const SortableList = ({ posts, isOrderable, handleItemDelete, mode, setPosts }) => { +const SortableList = ({ + posts, + isOrderable = false, + handleItemDelete, + mode = 'post', + setPosts, +}) => { const hasMultiplePosts = posts.length > 1; const items = posts.map((item) => item.uuid); @@ -45,17 +50,4 @@ const SortableList = ({ posts, isOrderable, handleItemDelete, mode, setPosts }) ); }; -SortableList.defaultProps = { - isOrderable: false, - mode: 'post', -}; - -SortableList.propTypes = { - posts: PropTypes.array.isRequired, - isOrderable: PropTypes.bool, - handleItemDelete: PropTypes.func.isRequired, - mode: PropTypes.string, - setPosts: PropTypes.func.isRequired, -}; - export default SortableList; From fdfec620f3139e9da2476636cc1755052ffe9cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:17:38 +0200 Subject: [PATCH 18/20] remove defaultProps & propTypes from PostTermList component --- components/post-term-list/index.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/components/post-term-list/index.js b/components/post-term-list/index.js index b06b3cfd..e9bee1c4 100644 --- a/components/post-term-list/index.js +++ b/components/post-term-list/index.js @@ -1,7 +1,6 @@ import { Spinner } from '@wordpress/components'; import { Children } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import PropTypes from 'prop-types'; import { PostTaxonomiesHierarchicalTermSelector, PostTaxonomiesFlatTermSelector, @@ -15,8 +14,8 @@ import { ListItem, TermLink } from './item'; export const PostTermList = (props) => { const { tagName: TagName = 'ul', - taxonomyName, - children, + taxonomyName = 'category', + children = null, noResultsMessage = __('Please select a term', 'tenup'), ...rest } = props; @@ -109,19 +108,5 @@ export const PostTermList = (props) => { ); }; -PostTermList.propTypes = { - children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), - taxonomyName: PropTypes.string, - tagName: PropTypes.string, - noResultsMessage: PropTypes.string, -}; - -PostTermList.defaultProps = { - children: null, - tagName: 'ul', - taxonomyName: 'category', - noResultsMessage: __('Please select a term', 'tenup'), -}; - PostTermList.ListItem = ListItem; PostTermList.TermLink = TermLink; From d6fdad17228db28dbaa3270e5fb2ceead8327799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:18:29 +0200 Subject: [PATCH 19/20] remove no longer needed eslint ignore statements --- api/register-block-extension/index.js | 1 - hooks/use-popover/index.js | 1 - 2 files changed, 2 deletions(-) diff --git a/api/register-block-extension/index.js b/api/register-block-extension/index.js index 1fb235c3..94af36dd 100644 --- a/api/register-block-extension/index.js +++ b/api/register-block-extension/index.js @@ -1,4 +1,3 @@ -/* eslint-disable react/prop-types */ /* eslint-disable react/jsx-props-no-spreading */ import { addFilter } from '@wordpress/hooks'; diff --git a/hooks/use-popover/index.js b/hooks/use-popover/index.js index 8b2a656a..e5323999 100644 --- a/hooks/use-popover/index.js +++ b/hooks/use-popover/index.js @@ -20,7 +20,6 @@ export const usePopover = () => { const ref = useOnClickOutside(() => setIsVisible(false)); const PopoverComponent = useMemo( () => - // eslint-disable-next-line react/prop-types ({ children }) => { if (!isVisible) { return null; From 5ba1128599eaf30dab0078132e2efd240f9a7491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 11 Jun 2024 12:18:36 +0200 Subject: [PATCH 20/20] uninstall prop-types --- package-lock.json | 4 +++- package.json | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2198abba..3c2fdf39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,6 @@ "@typescript-eslint/parser": "^6.21.0", "@wordpress/icons": "^10.0.0", "array-move": "^4.0.0", - "prop-types": "^15.8.1", "react-window": "^1.8.10", "uuid": "^9.0.1", "wp-types": "^3.65.0" @@ -20748,6 +20747,7 @@ }, "node_modules/object-assign": { "version": "4.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -22973,6 +22973,7 @@ }, "node_modules/prop-types": { "version": "15.8.1", + "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.4.0", @@ -22982,6 +22983,7 @@ }, "node_modules/prop-types/node_modules/react-is": { "version": "16.13.1", + "dev": true, "license": "MIT" }, "node_modules/proxy-addr": { diff --git a/package.json b/package.json index 25695d6c..b4115aaf 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "@typescript-eslint/parser": "^6.21.0", "@wordpress/icons": "^10.0.0", "array-move": "^4.0.0", - "prop-types": "^15.8.1", "react-window": "^1.8.10", "uuid": "^9.0.1", "wp-types": "^3.65.0"