From d983ec8897ff4b1dd52886f09dcae3417bed331d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2020 20:37:06 -0400 Subject: [PATCH] chore(deps): update dependency prettier to v2 (#5058) * chore(deps): update dependency prettier to v2 * format Co-authored-by: Renovate Bot Co-authored-by: Jimmy Jia --- karma.conf.js | 2 +- package.json | 2 +- src/AbstractNav.js | 4 +- src/AbstractNavItem.js | 2 +- src/AccordionToggle.js | 2 +- src/Alert.js | 2 +- src/BootstrapModalManager.js | 12 ++--- src/Carousel.js | 22 ++++---- src/Col.js | 2 +- src/Collapse.js | 10 ++-- src/DropdownItem.js | 2 +- src/ElementChildren.js | 4 +- src/Fade.js | 2 +- src/InputGroup.js | 4 +- src/ListGroupItem.js | 2 +- src/Modal.js | 8 +-- src/NavbarCollapse.js | 2 +- src/NavbarToggle.js | 2 +- src/Overlay.js | 4 +- src/OverlayTrigger.js | 12 ++--- src/ProgressBar.js | 4 +- src/Row.js | 2 +- src/SafeAnchor.js | 4 +- src/TabContainer.js | 6 +-- src/Tabs.js | 4 +- src/ToggleButton.js | 4 +- src/ToggleButtonGroup.js | 6 +-- src/createChainedFunction.js | 2 +- src/createWithBsPrefix.js | 2 +- src/divWithClassName.js | 2 +- src/useWrappedRefWithWarning.js | 2 +- test/AccordionSpec.js | 26 ++------- test/AlertSpec.js | 2 +- test/BreadcrumbItemSpec.js | 23 ++------ test/ButtonGroupSpec.js | 2 +- test/ButtonSpec.js | 2 +- test/CarouselSpec.js | 29 ++++------ test/CloseButton.js | 2 +- test/CollapseSpec.js | 12 ++--- test/DropdownButtonSpec.js | 25 +++------ test/DropdownItemSpec.js | 12 ++--- test/DropdownSpec.js | 16 ++---- test/DropdownToggleSpec.js | 4 +- test/FadeSpec.js | 6 +-- test/FormCheckSpec.js | 2 +- test/FormControlSpec.js | 2 +- test/FormFileSpec.js | 2 +- test/FormLabelSpec.js | 2 +- test/ModalSpec.js | 6 +-- test/NavDropdownSpec.js | 5 +- test/NavLinkSpec.js | 2 +- test/NavSpec.js | 18 +++---- test/OverlayTriggerSpec.js | 54 +++++-------------- test/ProgressBarSpec.js | 2 +- test/SafeAnchorSpec.js | 5 +- test/SplitButtonSpec.js | 12 ++--- test/TabContainerSpec.js | 42 ++++----------- test/TabsSpec.js | 2 +- test/ThemeProviderSpec.js | 2 +- test/ToggleButtonGroupSpec.js | 10 +--- test/index.js | 2 +- tools/build.js | 8 +-- www/config.js | 10 +--- www/resolveHocComponents.js | 8 +-- www/src/components/CodeBlock.js | 2 +- www/src/components/Heading.js | 2 +- www/src/components/LinkToSource.js | 2 +- www/src/components/NavMain.js | 6 +-- www/src/components/PropTable.js | 15 +++--- www/src/components/ReactPlayground.js | 4 +- www/src/components/SideNav.js | 4 +- www/src/components/Sonnet.js | 2 +- www/src/components/Toc.js | 2 +- www/src/examples/Button/Loading.js | 2 +- .../Button/ToggleButtonGroupControlled.js | 2 +- www/src/examples/Dropdown/ButtonCustomMenu.js | 6 +-- www/src/examples/Dropdown/DropDirections.js | 4 +- www/src/examples/Dropdown/SplitVariants.js | 2 +- www/src/examples/Dropdown/Variants.js | 2 +- www/src/examples/Form/Check.js | 2 +- www/src/examples/Form/CheckApi.js | 2 +- www/src/examples/Form/CheckCustom.js | 2 +- www/src/examples/Form/CheckCustomInline.js | 2 +- www/src/examples/Form/CheckInline.js | 2 +- www/src/examples/Form/ValidationNative.js | 2 +- www/src/examples/Nav/Basic.js | 2 +- www/src/examples/Nav/Dropdown.js | 2 +- www/src/examples/Overlay.js | 4 +- www/src/examples/OverlayCustom.js | 4 +- www/src/examples/Overlays/PopoverContained.js | 2 +- .../examples/Overlays/PopoverPositioned.js | 2 +- .../Overlays/PopoverPositionedScrolling.js | 2 +- .../Overlays/PopoverTriggerBehaviors.js | 2 +- www/src/examples/Overlays/TooltipOverlay.js | 2 +- .../examples/Overlays/TooltipPositioned.js | 2 +- www/src/examples/Tabs/Controlled.js | 6 ++- www/src/layouts/index.js | 14 ++--- www/src/withLayout.js | 2 +- www/src/wrap-page.js | 14 ++--- yarn.lock | 8 +-- 100 files changed, 254 insertions(+), 380 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 6c3fae1e49..425e7bd12a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,6 @@ const { DefinePlugin } = require('webpack'); -module.exports = config => { +module.exports = (config) => { const { env } = process; config.set({ diff --git a/package.json b/package.json index 5890797e70..9b93b52544 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "lint-staged": "^10.0.8", "lodash": "^4.17.15", "mocha": "^7.1.0", - "prettier": "^1.19.1", + "prettier": "^2.0.1", "react": "^16.13.0", "react-dom": "^16.13.0", "react-test-renderer": "^16.13.0", diff --git a/src/AbstractNav.js b/src/AbstractNav.js index 0bc33221ea..ffa0035ec0 100644 --- a/src/AbstractNav.js +++ b/src/AbstractNav.js @@ -60,7 +60,7 @@ const AbstractNav = React.forwardRef( const listNode = useRef(null); - const getNextActiveChild = offset => { + const getNextActiveChild = (offset) => { if (!listNode.current) return null; let items = qsa(listNode.current, '[data-rb-event-key]:not(.disabled)'); @@ -81,7 +81,7 @@ const AbstractNav = React.forwardRef( if (parentOnSelect) parentOnSelect(key, event); }; - const handleKeyDown = event => { + const handleKeyDown = (event) => { if (onKeyDown) onKeyDown(event); let nextActiveChild; diff --git a/src/AbstractNavItem.js b/src/AbstractNavItem.js index 0619e952c0..8682d6bf8f 100644 --- a/src/AbstractNavItem.js +++ b/src/AbstractNavItem.js @@ -61,7 +61,7 @@ const AbstractNavItem = React.forwardRef( props['aria-selected'] = isActive; } - const handleOnclick = useEventCallback(e => { + const handleOnclick = useEventCallback((e) => { if (onClick) onClick(e); if (navKey == null) return; if (onSelect) onSelect(navKey, e); diff --git a/src/AccordionToggle.js b/src/AccordionToggle.js index d88f314ed0..19f6b8186e 100644 --- a/src/AccordionToggle.js +++ b/src/AccordionToggle.js @@ -24,7 +24,7 @@ export function useAccordionToggle(eventKey, onClick) { const contextEventKey = useContext(AccordionContext); const onSelect = useContext(SelectableContext); - return e => { + return (e) => { /* Compare the event key in context with the given event key. If they are the same, then collapse the component. diff --git a/src/Alert.js b/src/Alert.js index 4c26b9d22d..e8c6b4a6a3 100644 --- a/src/Alert.js +++ b/src/Alert.js @@ -79,7 +79,7 @@ const Alert = React.forwardRef((uncontrolledProps, ref) => { } = useUncontrolled(uncontrolledProps, controllables); const prefix = useBootstrapPrefix(bsPrefix, 'alert'); - const handleClose = useEventCallback(e => { + const handleClose = useEventCallback((e) => { onClose(false, e); }); diff --git a/src/BootstrapModalManager.js b/src/BootstrapModalManager.js index 040560ba1e..7561e56efb 100644 --- a/src/BootstrapModalManager.js +++ b/src/BootstrapModalManager.js @@ -32,13 +32,13 @@ export default class BootstrapModalManager extends ModalManager { if (!containerState.overflowing) return; const size = getScrollbarSize(); - qsa(container, Selector.FIXED_CONTENT).forEach(el => + qsa(container, Selector.FIXED_CONTENT).forEach((el) => this.adjustAndStore('paddingRight', el, size), ); - qsa(container, Selector.STICKY_CONTENT).forEach(el => + qsa(container, Selector.STICKY_CONTENT).forEach((el) => this.adjustAndStore('margingRight', el, -size), ); - qsa(container, Selector.NAVBAR_TOGGLER).forEach(el => + qsa(container, Selector.NAVBAR_TOGGLER).forEach((el) => this.adjustAndStore('margingRight', el, size), ); } @@ -46,13 +46,13 @@ export default class BootstrapModalManager extends ModalManager { removeContainerStyle(containerState, container) { super.removeContainerStyle(containerState, container); - qsa(container, Selector.FIXED_CONTENT).forEach(el => + qsa(container, Selector.FIXED_CONTENT).forEach((el) => this.restore('paddingRight', el), ); - qsa(container, Selector.STICKY_CONTENT).forEach(el => + qsa(container, Selector.STICKY_CONTENT).forEach((el) => this.restore('margingRight', el), ); - qsa(container, Selector.NAVBAR_TOGGLER).forEach(el => + qsa(container, Selector.NAVBAR_TOGGLER).forEach((el) => this.restore('margingRight', el), ); } diff --git a/src/Carousel.js b/src/Carousel.js index be4dc8f6a8..73fce4b1e4 100644 --- a/src/Carousel.js +++ b/src/Carousel.js @@ -228,7 +228,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { ).length; const prev = useCallback( - event => { + (event) => { if (isSliding) { return; } @@ -250,7 +250,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { ); // This is used in the setInterval, so it should not invalidate. - const next = useEventCallback(event => { + const next = useEventCallback((event) => { if (isSliding) { return; } @@ -300,7 +300,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { const directionalClassName = `${prefix}-item-${slideDirection}`; const handleEnter = useCallback( - node => { + (node) => { triggerBrowserReflow(node); if (onSlide) { @@ -319,7 +319,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { }, [onSlid, renderedActiveIndex, slideDirection]); const handleKeyDown = useCallback( - event => { + (event) => { if (keyboard && !/input|textarea/i.test(event.target.tagName)) { switch (event.key) { case 'ArrowLeft': @@ -344,7 +344,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { const [pausedOnHover, setPausedOnHover] = useState(false); const handleMouseOver = useCallback( - event => { + (event) => { if (pause === 'hover') { setPausedOnHover(true); } @@ -357,7 +357,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { ); const handleMouseOut = useCallback( - event => { + (event) => { setPausedOnHover(false); if (onMouseOut) { @@ -373,7 +373,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { const touchUnpauseTimeout = useTimeout(); const handleTouchStart = useCallback( - event => { + (event) => { touchStartXRef.current = event.touches[0].clientX; touchDeltaXRef.current = 0; @@ -389,7 +389,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { ); const handleTouchMove = useCallback( - event => { + (event) => { if (event.touches && event.touches.length > 1) { touchDeltaXRef.current = 0; } else { @@ -405,7 +405,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { ); const handleTouchEnd = useCallback( - event => { + (event) => { if (touch) { const touchDeltaX = touchDeltaXRef.current; @@ -454,7 +454,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { const indicatorOnClicks = useMemo( () => indicators && - Array.from({ length: numChildren }, (_, index) => event => { + Array.from({ length: numChildren }, (_, index) => (event) => { onSelect(index, event); }), [indicators, numChildren, onSelect], @@ -500,7 +500,7 @@ const Carousel = React.forwardRef((uncontrolledProps, ref) => { onEntered={isActive ? handleEntered : null} addEndListener={transitionEnd} > - {status => + {(status) => React.cloneElement(child, { className: classNames( child.props.className, diff --git a/src/Col.js b/src/Col.js index 8548e8fa95..858eed8573 100644 --- a/src/Col.js +++ b/src/Col.js @@ -77,7 +77,7 @@ const Col = React.forwardRef( const spans = []; const classes = []; - DEVICE_SIZES.forEach(brkPoint => { + DEVICE_SIZES.forEach((brkPoint) => { let propValue = props[brkPoint]; delete props[brkPoint]; diff --git a/src/Collapse.js b/src/Collapse.js index ce32515b94..a0d38fd732 100644 --- a/src/Collapse.js +++ b/src/Collapse.js @@ -138,21 +138,21 @@ class Collapse extends React.Component { } /* -- Expanding -- */ - handleEnter = elem => { + handleEnter = (elem) => { elem.style[this.getDimension()] = '0'; }; - handleEntering = elem => { + handleEntering = (elem) => { const dimension = this.getDimension(); elem.style[dimension] = this._getScrollDimensionValue(elem, dimension); }; - handleEntered = elem => { + handleEntered = (elem) => { elem.style[this.getDimension()] = null; }; /* -- Collapsing -- */ - handleExit = elem => { + handleExit = (elem) => { const dimension = this.getDimension(); elem.style[dimension] = `${this.props.getDimensionValue( dimension, @@ -161,7 +161,7 @@ class Collapse extends React.Component { triggerBrowserReflow(elem); }; - handleExiting = elem => { + handleExiting = (elem) => { elem.style[this.getDimension()] = null; }; diff --git a/src/DropdownItem.js b/src/DropdownItem.js index cdfcf4d2bf..c7da5fac86 100644 --- a/src/DropdownItem.js +++ b/src/DropdownItem.js @@ -83,7 +83,7 @@ const DropdownItem = React.forwardRef( ? makeEventKey(activeKey) === key : propActive; - const handleClick = useEventCallback(event => { + const handleClick = useEventCallback((event) => { // SafeAnchor handles the disabled case, but we handle it here // for other components if (disabled) return; diff --git a/src/ElementChildren.js b/src/ElementChildren.js index 73f3cab67c..8938db4294 100644 --- a/src/ElementChildren.js +++ b/src/ElementChildren.js @@ -11,7 +11,7 @@ import React from 'react'; function map(children, func) { let index = 0; - return React.Children.map(children, child => + return React.Children.map(children, (child) => React.isValidElement(child) ? func(child, index++) : child, ); } @@ -24,7 +24,7 @@ function map(children, func) { */ function forEach(children, func) { let index = 0; - React.Children.forEach(children, child => { + React.Children.forEach(children, (child) => { if (React.isValidElement(child)) func(child, index++); }); } diff --git a/src/Fade.js b/src/Fade.js index 00da3a1a56..4d2b2eb5d7 100644 --- a/src/Fade.js +++ b/src/Fade.js @@ -78,7 +78,7 @@ const fadeStyles = { const Fade = React.forwardRef(({ className, children, ...props }, ref) => { const handleEnter = useCallback( - node => { + (node) => { triggerBrowserReflow(node); if (props.onEnter) props.onEnter(node); }, diff --git a/src/InputGroup.js b/src/InputGroup.js index c822821b63..132b3d7e80 100644 --- a/src/InputGroup.js +++ b/src/InputGroup.js @@ -64,13 +64,13 @@ const InputGroupText = createWithBsPrefix('input-group-text', { Component: 'span', }); -const InputGroupCheckbox = props => ( +const InputGroupCheckbox = (props) => ( ); -const InputGroupRadio = props => ( +const InputGroupRadio = (props) => ( diff --git a/src/ListGroupItem.js b/src/ListGroupItem.js index 35f901f672..a712d83fb5 100644 --- a/src/ListGroupItem.js +++ b/src/ListGroupItem.js @@ -72,7 +72,7 @@ const ListGroupItem = React.forwardRef( bsPrefix = useBootstrapPrefix(bsPrefix, 'list-group-item'); const handleClick = useCallback( - event => { + (event) => { if (disabled) { event.preventDefault(); event.stopPropagation(); diff --git a/src/Modal.js b/src/Modal.js index 641fe892f8..f06eb96b59 100644 --- a/src/Modal.js +++ b/src/Modal.js @@ -203,7 +203,7 @@ class Modal extends React.Component { removeEventListener(window, 'resize', this.handleWindowResize); } - setModalRef = ref => { + setModalRef = (ref) => { this._modal = ref; }; @@ -214,14 +214,14 @@ class Modal extends React.Component { this._waitingForMouseUp = true; }; - handleMouseUp = e => { + handleMouseUp = (e) => { if (this._waitingForMouseUp && e.target === this._modal.dialog) { this._ignoreBackdropClick = true; } this._waitingForMouseUp = false; }; - handleClick = e => { + handleClick = (e) => { if (this._ignoreBackdropClick || e.target !== e.currentTarget) { this._ignoreBackdropClick = false; return; @@ -294,7 +294,7 @@ class Modal extends React.Component { }); } - renderBackdrop = props => { + renderBackdrop = (props) => { const { bsPrefix, backdropClassName, animation } = this.props; return ( diff --git a/src/NavbarCollapse.js b/src/NavbarCollapse.js index 34c5ceaf96..b87fb3d27c 100644 --- a/src/NavbarCollapse.js +++ b/src/NavbarCollapse.js @@ -15,7 +15,7 @@ const NavbarCollapse = React.forwardRef( bsPrefix = useBootstrapPrefix(bsPrefix, 'navbar-collapse'); return ( - {context => ( + {(context) => (
{children} diff --git a/src/NavbarToggle.js b/src/NavbarToggle.js index 72cb21b071..c0a92644c2 100644 --- a/src/NavbarToggle.js +++ b/src/NavbarToggle.js @@ -46,7 +46,7 @@ const NavbarToggle = React.forwardRef( const { onToggle, expanded } = useContext(NavbarContext) || {}; - const handleClick = useEventCallback(e => { + const handleClick = useEventCallback((e) => { if (onClick) onClick(e); if (onToggle) onToggle(); }); diff --git a/src/Overlay.js b/src/Overlay.js index 445d122f1a..6fb1cec16b 100644 --- a/src/Overlay.js +++ b/src/Overlay.js @@ -115,9 +115,9 @@ function wrapRefs(props, arrowProps) { const { ref } = props; const { ref: aRef } = arrowProps; - props.ref = ref.__wrapped || (ref.__wrapped = r => ref(findDOMNode(r))); + props.ref = ref.__wrapped || (ref.__wrapped = (r) => ref(findDOMNode(r))); arrowProps.ref = - aRef.__wrapped || (aRef.__wrapped = r => aRef(findDOMNode(r))); + aRef.__wrapped || (aRef.__wrapped = (r) => aRef(findDOMNode(r))); } function Overlay({ children: overlay, transition, ...outerProps }) { diff --git a/src/OverlayTrigger.js b/src/OverlayTrigger.js index 30afb3e164..29be918c1b 100644 --- a/src/OverlayTrigger.js +++ b/src/OverlayTrigger.js @@ -152,7 +152,7 @@ function OverlayTrigger({ }, [delay.hide, timeout]); const handleFocus = useCallback( - e => { + (e) => { handleShow(e); if (onFocus) onFocus(e); }, @@ -160,7 +160,7 @@ function OverlayTrigger({ ); const handleBlur = useCallback( - e => { + (e) => { handleHide(e); if (onBlur) onBlur(e); }, @@ -168,22 +168,22 @@ function OverlayTrigger({ ); const handleClick = useCallback( - e => { - setShow(prevShow => !prevShow); + (e) => { + setShow((prevShow) => !prevShow); if (onClick) onClick(e); }, [onClick], ); const handleMouseOver = useCallback( - e => { + (e) => { handleMouseOverOut(handleShow, e, 'fromElement'); }, [handleShow], ); const handleMouseOut = useCallback( - e => { + (e) => { handleMouseOverOut(handleHide, e, 'toElement'); }, [handleHide], diff --git a/src/ProgressBar.js b/src/ProgressBar.js index 9652696349..578151305c 100644 --- a/src/ProgressBar.js +++ b/src/ProgressBar.js @@ -19,7 +19,7 @@ function onlyProgressBar(props, propName, componentName) { let error = null; - React.Children.forEach(children, child => { + React.Children.forEach(children, (child) => { if (error) { return; } @@ -188,7 +188,7 @@ const ProgressBar = React.forwardRef(({ isChild, ...props }, ref) => { className={classNames(className, bsPrefix)} > {children - ? map(children, child => cloneElement(child, { isChild: true })) + ? map(children, (child) => cloneElement(child, { isChild: true })) : renderProgressBar( { min, diff --git a/src/Row.js b/src/Row.js index 85754e436f..cbb65e5fc4 100644 --- a/src/Row.js +++ b/src/Row.js @@ -81,7 +81,7 @@ const Row = React.forwardRef( const sizePrefix = `${decoratedBsPrefix}-cols`; const classes = []; - DEVICE_SIZES.forEach(brkPoint => { + DEVICE_SIZES.forEach((brkPoint) => { const propValue = props[brkPoint]; delete props[brkPoint]; diff --git a/src/SafeAnchor.js b/src/SafeAnchor.js index af1bc3763e..909520a627 100644 --- a/src/SafeAnchor.js +++ b/src/SafeAnchor.js @@ -39,7 +39,7 @@ const SafeAnchor = React.forwardRef( }, ref, ) => { - const handleClick = event => { + const handleClick = (event) => { const { href, onClick } = props; if (disabled || isTrivialHref(href)) { @@ -56,7 +56,7 @@ const SafeAnchor = React.forwardRef( } }; - const handleKeyDown = event => { + const handleKeyDown = (event) => { if (event.key === ' ') { event.preventDefault(); handleClick(event); diff --git a/src/TabContainer.js b/src/TabContainer.js index 3445877782..3bc61a42e2 100644 --- a/src/TabContainer.js +++ b/src/TabContainer.js @@ -81,7 +81,7 @@ const propTypes = { activeKey: PropTypes.any, }; -const TabContainer = props => { +const TabContainer = (props) => { const { id, generateChildId: generateCustomChildId, @@ -107,8 +107,8 @@ const TabContainer = props => { transition, mountOnEnter, unmountOnExit, - getControlledId: key => generateChildId(key, 'tabpane'), - getControllerId: key => generateChildId(key, 'tab'), + getControlledId: (key) => generateChildId(key, 'tabpane'), + getControllerId: (key) => generateChildId(key, 'tab'), }), [ onSelect, diff --git a/src/Tabs.js b/src/Tabs.js index 4c39db04dd..9637a5c42e 100644 --- a/src/Tabs.js +++ b/src/Tabs.js @@ -84,7 +84,7 @@ const defaultProps = { function getDefaultActiveKey(children) { let defaultActiveKey; - forEach(children, child => { + forEach(children, (child) => { if (defaultActiveKey == null) { defaultActiveKey = child.props.eventKey; } @@ -140,7 +140,7 @@ const Tabs = React.forwardRef((props, ref) => { - {map(children, child => { + {map(children, (child) => { const childProps = { ...child.props }; delete childProps.title; diff --git a/src/ToggleButton.js b/src/ToggleButton.js index 3b0ccf594d..8a69e7c912 100644 --- a/src/ToggleButton.js +++ b/src/ToggleButton.js @@ -65,11 +65,11 @@ const ToggleButton = React.forwardRef( ) => { const [focused, setFocused] = useState(false); - const handleFocus = useCallback(e => { + const handleFocus = useCallback((e) => { if (e.target.tagName === 'INPUT') setFocused(true); }, []); - const handleBlur = useCallback(e => { + const handleBlur = useCallback((e) => { if (e.target.tagName === 'INPUT') setFocused(false); }, []); diff --git a/src/ToggleButtonGroup.js b/src/ToggleButtonGroup.js index 175faf9f09..e76b73f458 100644 --- a/src/ToggleButtonGroup.js +++ b/src/ToggleButtonGroup.js @@ -68,7 +68,7 @@ const ToggleButtonGroup = React.forwardRef((props, ref) => { if (isActive) { onChange( - values.filter(n => n !== inputVal), + values.filter((n) => n !== inputVal), event, ); } else { @@ -84,10 +84,10 @@ const ToggleButtonGroup = React.forwardRef((props, ref) => { return ( - {map(children, child => { + {map(children, (child) => { const values = getValues(); const { value: childVal, onChange: childOnChange } = child.props; - const handler = e => handleToggle(childVal, e); + const handler = (e) => handleToggle(childVal, e); return React.cloneElement(child, { type, diff --git a/src/createChainedFunction.js b/src/createChainedFunction.js index 147ebe2cea..77a5deb694 100644 --- a/src/createChainedFunction.js +++ b/src/createChainedFunction.js @@ -9,7 +9,7 @@ */ function createChainedFunction(...funcs) { return funcs - .filter(f => f != null) + .filter((f) => f != null) .reduce((acc, f) => { if (typeof f !== 'function') { throw new Error( diff --git a/src/createWithBsPrefix.js b/src/createWithBsPrefix.js index 209789a02c..ac8bc74d2c 100644 --- a/src/createWithBsPrefix.js +++ b/src/createWithBsPrefix.js @@ -3,7 +3,7 @@ import camelize from 'dom-helpers/camelize'; import React from 'react'; import { useBootstrapPrefix } from './ThemeProvider'; -const pascalCase = str => str[0].toUpperCase() + camelize(str).slice(1); +const pascalCase = (str) => str[0].toUpperCase() + camelize(str).slice(1); export default function createWithBsPrefix( prefix, diff --git a/src/divWithClassName.js b/src/divWithClassName.js index 5e443ffe52..02e10cef20 100644 --- a/src/divWithClassName.js +++ b/src/divWithClassName.js @@ -1,7 +1,7 @@ import React from 'react'; import classNames from 'classnames'; -export default className => +export default (className) => React.forwardRef((p, ref) => (
)); diff --git a/src/useWrappedRefWithWarning.js b/src/useWrappedRefWithWarning.js index e2c3449ac2..5ad931a942 100644 --- a/src/useWrappedRefWithWarning.js +++ b/src/useWrappedRefWithWarning.js @@ -7,7 +7,7 @@ export default function useWrappedRefWithWarning(ref, componentName) { // eslint-disable-next-line react-hooks/rules-of-hooks const warningRef = useCallback( - refValue => { + (refValue) => { invariant( refValue == null || !refValue.isReactComponent, `${componentName} injected a ref to a provided \`as\` component that resolved to a component instance instead of a DOM element. ` + diff --git a/test/AccordionSpec.js b/test/AccordionSpec.js index d01d6e30fe..e71be53be7 100644 --- a/test/AccordionSpec.js +++ b/test/AccordionSpec.js @@ -32,14 +32,8 @@ describe('', () => { ); const collapses = wrapper.find('AccordionCollapse'); - collapses - .at(0) - .getDOMNode() - .className.should.include('show'); - collapses - .at(1) - .getDOMNode() - .className.should.include('collapse'); + collapses.at(0).getDOMNode().className.should.include('show'); + collapses.at(1).getDOMNode().className.should.include('collapse'); }); it('should expand next card and collapse current card on click', () => { @@ -64,29 +58,19 @@ describe('', () => { , ); - wrapper - .find('CardHeader') - .at(1) - .find('button') - .simulate('click'); + wrapper.find('CardHeader').at(1).find('button').simulate('click'); onClickSpy.should.be.calledOnce; const collapses = wrapper.find('AccordionCollapse'); - collapses - .at(0) - .getDOMNode() - .className.should.include('collapse'); + collapses.at(0).getDOMNode().className.should.include('collapse'); // Enzyme doesn't really provide support for async utilities // on components, but in an ideal setup we should be testing for // this className to be `show` after the collapsing animation is done // (which is possible in `@testing-library` via `waitForElement`). // https://testing-library.com/docs/dom-testing-library/api-async#waitforelement - collapses - .at(1) - .getDOMNode() - .className.should.include('collapsing'); + collapses.at(1).getDOMNode().className.should.include('collapsing'); }); }); diff --git a/test/AlertSpec.js b/test/AlertSpec.js index a9cb825df2..2160d5d366 100644 --- a/test/AlertSpec.js +++ b/test/AlertSpec.js @@ -18,7 +18,7 @@ describe('', () => { ); }); - it('Should call onClose callback on dismiss click', done => { + it('Should call onClose callback on dismiss click', (done) => { let doneOp = () => { done(); }; diff --git a/test/BreadcrumbItemSpec.js b/test/BreadcrumbItemSpec.js index 8fa394210a..98bf8e0f83 100644 --- a/test/BreadcrumbItemSpec.js +++ b/test/BreadcrumbItemSpec.js @@ -17,9 +17,7 @@ describe('', () => { 'li', ); li.should.have.length(1); - li.children() - .html() - .should.eql('Active Crumb'); + li.children().html().should.eql('Active Crumb'); }); it('Should render `li` with no children as inner element when active and has href', () => { @@ -29,9 +27,7 @@ describe('', () => { , ).find('li'); li.should.have.length(1); - li.children() - .html() - .should.eql('Active Crumb'); + li.children().html().should.eql('Active Crumb'); }); it('Should add custom classes onto `li` wrapper element', () => { @@ -95,10 +91,7 @@ describe('', () => { , ); - instance - .find('a') - .prop('title') - .should.eq('test-title'); + instance.find('a').prop('title').should.eq('test-title'); }); it('Should not apply properties for inner `anchor` onto `li` wrapper element', () => { @@ -120,10 +113,7 @@ describe('', () => { Crumb , ); - instance - .find('a') - .prop('target') - .should.eq('_blank'); + instance.find('a').prop('target').should.eq('_blank'); }); it('Should have li as default component', () => { @@ -138,9 +128,6 @@ describe('', () => { it('Should spread property on customized inner link element', () => { const instance = mount(); - instance - .find('button') - .prop('type') - .should.eq('submit'); + instance.find('button').prop('type').should.eq('submit'); }); }); diff --git a/test/ButtonGroupSpec.js b/test/ButtonGroupSpec.js index fd3312ef56..0fbc8f39a6 100644 --- a/test/ButtonGroupSpec.js +++ b/test/ButtonGroupSpec.js @@ -26,7 +26,7 @@ describe('ButtonGroup', () => { , ) - .tap(b => b.assertSingle('.btn-group-vertical')) + .tap((b) => b.assertSingle('.btn-group-vertical')) .assertNone('.btn-group'); }); diff --git a/test/ButtonSpec.js b/test/ButtonSpec.js index 0ec89e7295..c6a48505ba 100644 --- a/test/ButtonSpec.js +++ b/test/ButtonSpec.js @@ -53,7 +53,7 @@ describe(').assertSingle(`a[href="${href}"]`); }); - it('Should call onClick callback', done => { + it('Should call onClick callback', (done) => { mount().simulate('click'); }); diff --git a/test/CarouselSpec.js b/test/CarouselSpec.js index d6098fcd43..5fa86df8f9 100644 --- a/test/CarouselSpec.js +++ b/test/CarouselSpec.js @@ -49,7 +49,7 @@ describe('', () => { expect(wrapper.find('.carousel-indicators > li')).to.have.lengthOf(2); }); - it('should call onSelect when indicator selected', done => { + it('should call onSelect when indicator selected', (done) => { function onSelect(index) { expect(index).to.equal(0); @@ -62,14 +62,11 @@ describe('', () => { , ); - wrapper - .find('.carousel-indicators li') - .first() - .simulate('click'); + wrapper.find('.carousel-indicators li').first().simulate('click'); }); - ['onSlide', 'onSlid'].forEach(eventName => { - it(`should call ${eventName} with previous index and direction`, done => { + ['onSlide', 'onSlid'].forEach((eventName) => { + it(`should call ${eventName} with previous index and direction`, (done) => { function onEvent(index, direction) { expect(index).to.equal(0); expect(direction).to.equal('right'); @@ -83,13 +80,10 @@ describe('', () => { , ); - wrapper - .find('.carousel-indicators li') - .first() - .simulate('click'); + wrapper.find('.carousel-indicators li').first().simulate('click'); }); - it(`should call ${eventName} with next index and direction`, done => { + it(`should call ${eventName} with next index and direction`, (done) => { function onEvent(index, direction) { const lastPossibleIndex = items.length - 1; expect(index).to.equal(lastPossibleIndex); @@ -104,10 +98,7 @@ describe('', () => { , ); - wrapper - .find('.carousel-indicators li') - .last() - .simulate('click'); + wrapper.find('.carousel-indicators li').last().simulate('click'); }); }); @@ -190,7 +181,7 @@ describe('', () => { it('should not render labels when values are null or undefined', () => { // undefined (as in nothing passed) renders default labels - [null, ''].forEach(falsyValue => { + [null, ''].forEach((falsyValue) => { const wrapper = mount( ', () => { }); }); - it('should transition properly when slide animation is disabled', done => { + it('should transition properly when slide animation is disabled', (done) => { const spy = sinon.spy(); const wrapper = mount( @@ -462,7 +453,7 @@ describe('', () => { sinon.assert.notCalled(onSelectSpy); }); - ['ArrowUp', 'ArrowRightLeft', 'Onwards'].forEach(key => { + ['ArrowUp', 'ArrowRightLeft', 'Onwards'].forEach((key) => { it('should do nothing for non left or right keys', () => { const onSelectSpy = sinon.spy(); const wrapper = mount( diff --git a/test/CloseButton.js b/test/CloseButton.js index 01996217f0..505397c567 100644 --- a/test/CloseButton.js +++ b/test/CloseButton.js @@ -29,7 +29,7 @@ describe('', () => { assert.equal(ReactDOM.findDOMNode(instance).getAttribute('class'), 'close'); }); - it('Should call onClick callback', done => { + it('Should call onClick callback', (done) => { let doneOp = () => { done(); }; diff --git a/test/CollapseSpec.js b/test/CollapseSpec.js index 60fe48df85..3b5509f483 100644 --- a/test/CollapseSpec.js +++ b/test/CollapseSpec.js @@ -13,7 +13,7 @@ describe('', () => { return ( (this.collapse = r)} + ref={(r) => (this.collapse = r)} getDimensionValue={() => 15} {...props} {...this.state} @@ -53,7 +53,7 @@ describe('', () => { assert.equal(wrapper.getDOMNode().className, 'collapsing'); }); - it('Should set initial 0px height', done => { + it('Should set initial 0px height', (done) => { let node = wrapper.getDOMNode(); function onEnter() { @@ -75,7 +75,7 @@ describe('', () => { assert.equal(node.style.height, '15px'); }); - it('Should transition from collapsing to not collapsing', done => { + it('Should transition from collapsing to not collapsing', (done) => { let node = wrapper.getDOMNode(); function onEntered() { @@ -88,7 +88,7 @@ describe('', () => { assert.equal(node.className, 'collapsing'); }); - it('Should clear height after transition complete', done => { + it('Should clear height after transition complete', (done) => { let node = wrapper.getDOMNode(); function onEntered() { @@ -133,7 +133,7 @@ describe('', () => { assert.equal(node.style.height, ''); }); - it('Should transition from collapsing to not collapsing', done => { + it('Should transition from collapsing to not collapsing', (done) => { let node = wrapper.getDOMNode(); function onExited() { @@ -146,7 +146,7 @@ describe('', () => { assert.equal(node.className, 'collapsing'); }); - it('Should have no height after transition complete', done => { + it('Should have no height after transition complete', (done) => { let node = wrapper.getDOMNode(); function onExited() { diff --git a/test/DropdownButtonSpec.js b/test/DropdownButtonSpec.js index c9cf21c78b..25c85efcae 100644 --- a/test/DropdownButtonSpec.js +++ b/test/DropdownButtonSpec.js @@ -48,10 +48,10 @@ describe('', () => { ).find('button.dropdown-toggle.btn-success.btn-sm'); }); - it('forwards onSelect handler to DropdownItems', done => { + it('forwards onSelect handler to DropdownItems', (done) => { const selectedEvents = []; - const onSelect = eventKey => { + const onSelect = (eventKey) => { selectedEvents.push(eventKey); if (selectedEvents.length === 4) { @@ -73,7 +73,7 @@ describe('', () => { , ); - instance.find('a').forEach(item => { + instance.find('a').forEach((item) => { item.simulate('click'); }); }); @@ -93,17 +93,10 @@ describe('', () => { ); wrapper.find('button').simulate('click'); - wrapper - .find('.dropdown-menu a') - .first() - .simulate('click'); + wrapper.find('.dropdown-menu a').first().simulate('click'); handleSelect.should.have.been.calledWith(false); - wrapper - .find('Dropdown') - .first() - .prop('show') - .should.equal(true); + wrapper.find('Dropdown').first().prop('show').should.equal(true); }); it('Should pass disabled to button', () => { @@ -131,11 +124,7 @@ describe('', () => { ); expect(wrapper.children().props().defaultShow).to.equal(true); - expect( - wrapper - .find('DropdownToggle') - .first() - .props().defaultShow, - ).to.not.exist; + expect(wrapper.find('DropdownToggle').first().props().defaultShow).to.not + .exist; }); }); diff --git a/test/DropdownItemSpec.js b/test/DropdownItemSpec.js index c1e2820893..99f281d46a 100644 --- a/test/DropdownItemSpec.js +++ b/test/DropdownItemSpec.js @@ -38,14 +38,14 @@ describe('', () => { node.style.height.should.equal('100px'); }); - it('renders menu item link', done => { + it('renders menu item link', (done) => { mount( done()} href="/herpa-derpa"> Item , ) .assertSingle('a.dropdown-item[href="/herpa-derpa"]') - .tap(a => a.text().should.equal('Item')) + .tap((a) => a.text().should.equal('Item')) .simulate('keyDown', { key: 'a' }); }); @@ -55,8 +55,8 @@ describe('', () => { ); }); - it('click handling with onSelect prop', done => { - const handleSelect = eventKey => { + it('click handling with onSelect prop', (done) => { + const handleSelect = (eventKey) => { eventKey.should.equal('1'); done(); }; @@ -67,8 +67,8 @@ describe('', () => { ).simulate('click'); }); - it('click handling with onSelect prop (no eventKey)', done => { - const handleSelect = eventKey => { + it('click handling with onSelect prop (no eventKey)', (done) => { + const handleSelect = (eventKey) => { expect(eventKey).to.not.exist; done(); }; diff --git a/test/DropdownSpec.js b/test/DropdownSpec.js index af96fb797f..98bd272fd6 100644 --- a/test/DropdownSpec.js +++ b/test/DropdownSpec.js @@ -104,10 +104,7 @@ describe('', () => { wrapper.assertSingle('.dropdown.show'); - wrapper - .find('.dropdown-menu a') - .first() - .simulate('click'); + wrapper.find('.dropdown-menu a').first().simulate('click'); onToggle.should.have.been.calledWith(false); }); @@ -135,16 +132,16 @@ describe('', () => { return ( { + ref={(dropdown) => { this.dropdown = dropdown; }} id="test" > (this.toggle = toggle)} + ref={(toggle) => (this.toggle = toggle)} /> - (this.menu = menu)} /> + (this.menu = menu)} /> ); } @@ -221,10 +218,7 @@ describe('', () => { expect(spy).to.have.been.calledOnce; - wrapper - .find('a') - .first() - .simulate('click'); + wrapper.find('a').first().simulate('click'); expect(spy).to.have.been.calledTwice; expect(spy.getCall(1).args.length).to.equal(3); diff --git a/test/DropdownToggleSpec.js b/test/DropdownToggleSpec.js index 294d7ab9e7..80838e984f 100644 --- a/test/DropdownToggleSpec.js +++ b/test/DropdownToggleSpec.js @@ -31,8 +31,8 @@ describe('', () => { .should.equal('herpa derpa'); }); - it('forwards onClick handler', done => { - const handleClick = event => { + it('forwards onClick handler', (done) => { + const handleClick = (event) => { event.should.be.ok; done(); }; diff --git a/test/FadeSpec.js b/test/FadeSpec.js index e946598d23..7b182c397d 100644 --- a/test/FadeSpec.js +++ b/test/FadeSpec.js @@ -12,7 +12,7 @@ describe('Fade', () => { let { children, ...props } = this.props; return ( - (this.fade = r)} {...props} {...this.state}> + (this.fade = r)} {...props} {...this.state}>
{children}
); @@ -34,7 +34,7 @@ describe('Fade', () => { assert.equal(wrapper.getDOMNode().className, 'fade'); }); - it('Should add "in" class when entering', done => { + it('Should add "in" class when entering', (done) => { wrapper = mount(Panel content); function onEntering() { @@ -47,7 +47,7 @@ describe('Fade', () => { wrapper.setState({ in: true, onEntering }); }); - it('Should remove "in" class when exiting', done => { + it('Should remove "in" class when exiting', (done) => { wrapper = mount(Panel content); function onExiting() { diff --git a/test/FormCheckSpec.js b/test/FormCheckSpec.js index 1a6aab4994..c6b7d929bc 100644 --- a/test/FormCheckSpec.js +++ b/test/FormCheckSpec.js @@ -68,7 +68,7 @@ describe('', () => { render() { return ( { + ref={(ref) => { this.input = ref; }} /> diff --git a/test/FormControlSpec.js b/test/FormControlSpec.js index f04c378348..264f58dacb 100644 --- a/test/FormControlSpec.js +++ b/test/FormControlSpec.js @@ -76,7 +76,7 @@ describe('', () => { { + ref={(ref) => { this.input = ref; }} /> diff --git a/test/FormFileSpec.js b/test/FormFileSpec.js index df86217963..ca61d79785 100644 --- a/test/FormFileSpec.js +++ b/test/FormFileSpec.js @@ -31,7 +31,7 @@ describe('', () => { render() { return ( { + ref={(ref) => { this.input = ref; }} /> diff --git a/test/FormLabelSpec.js b/test/FormLabelSpec.js index 3985dda3a6..a0d6eee5f5 100644 --- a/test/FormLabelSpec.js +++ b/test/FormLabelSpec.js @@ -58,7 +58,7 @@ describe('', () => { { + ref={(ref) => { this.input = ref; }} /> diff --git a/test/ModalSpec.js b/test/ModalSpec.js index 27b2ae49c2..f42aa9cf46 100644 --- a/test/ModalSpec.js +++ b/test/ModalSpec.js @@ -32,7 +32,7 @@ describe('', () => { expect(node.style.display).to.equal('block'); }); - it('Should close the modal when the modal dialog is clicked', done => { + it('Should close the modal when the modal dialog is clicked', (done) => { const doneOp = () => { done(); }; @@ -59,7 +59,7 @@ describe('', () => { expect(onHideSpy).to.not.have.been.called; }); - it('Should close the modal when the modal close button is clicked', done => { + it('Should close the modal when the modal close button is clicked', (done) => { const doneOp = () => { done(); }; @@ -138,7 +138,7 @@ describe('', () => { ).assertSingle('.custom-dialog'); }); - it('Should pass transition callbacks to Transition', done => { + it('Should pass transition callbacks to Transition', (done) => { const increment = sinon.spy(); const instance = mount( diff --git a/test/NavDropdownSpec.js b/test/NavDropdownSpec.js index e85464a482..ff1a3251c5 100644 --- a/test/NavDropdownSpec.js +++ b/test/NavDropdownSpec.js @@ -21,10 +21,7 @@ describe('', () => { wrapper.assertSingle('div.dropdown.test-class'); - wrapper - .assertSingle('a.nav-link') - .text() - .should.equal('Title'); + wrapper.assertSingle('a.nav-link').text().should.equal('Title'); }); it('renders active toggle', () => { diff --git a/test/NavLinkSpec.js b/test/NavLinkSpec.js index 0fb430cc84..a41356ca47 100644 --- a/test/NavLinkSpec.js +++ b/test/NavLinkSpec.js @@ -30,7 +30,7 @@ describe('', () => { ); }); - it('Should call `onSelect` when item is selected', done => { + it('Should call `onSelect` when item is selected', (done) => { function handleSelect(key, event) { assert.equal(key, '2'); assert.ok(event.target.tagName === 'A'); diff --git a/test/NavSpec.js b/test/NavSpec.js index 86ba10be5e..5c744968d1 100644 --- a/test/NavSpec.js +++ b/test/NavSpec.js @@ -84,7 +84,7 @@ describe('