From 9be02f2fa9453dfdc4789d5cf9e0949cf29e18ef Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Tue, 17 Apr 2018 22:50:48 +0200 Subject: [PATCH] chore(prettier): Format codebase --- src/components/Tab.js | 12 +++++-- src/components/TabPanel.js | 6 +++- src/components/Tabs.js | 12 +++++-- src/components/UncontrolledTabs.js | 15 ++++++--- src/components/__tests__/TabList-test.js | 6 +++- src/components/__tests__/Tabs-test.js | 41 ++++++++++++++++++++---- src/helpers/childrenDeepMap.js | 12 +++++-- src/helpers/propTypes.js | 26 ++++++++++++--- 8 files changed, 107 insertions(+), 23 deletions(-) diff --git a/src/components/Tab.js b/src/components/Tab.js index 4c7198c92e..24117c1292 100644 --- a/src/components/Tab.js +++ b/src/components/Tab.js @@ -16,8 +16,16 @@ export default class Tab extends Component { }; static propTypes = { - children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]), - className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]), + children: PropTypes.oneOfType([ + PropTypes.array, + PropTypes.object, + PropTypes.string, + ]), + className: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.array, + PropTypes.object, + ]), disabled: PropTypes.bool, tabIndex: PropTypes.string, disabledClassName: PropTypes.string, diff --git a/src/components/TabPanel.js b/src/components/TabPanel.js index 3fefeaca55..d245a4897d 100644 --- a/src/components/TabPanel.js +++ b/src/components/TabPanel.js @@ -13,7 +13,11 @@ export default class TabPanel extends Component { static propTypes = { children: PropTypes.node, - className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]), + className: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.array, + PropTypes.object, + ]), forceRender: PropTypes.bool, id: PropTypes.string, // private selected: PropTypes.bool, // private diff --git a/src/components/Tabs.js b/src/components/Tabs.js index 36eba6820d..13bb25c70f 100644 --- a/src/components/Tabs.js +++ b/src/components/Tabs.js @@ -1,6 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { childrenPropType, onSelectPropType, selectedIndexPropType } from '../helpers/propTypes'; +import { + childrenPropType, + onSelectPropType, + selectedIndexPropType, +} from '../helpers/propTypes'; import UncontrolledTabs from './UncontrolledTabs'; import { getTabsCount } from '../helpers/count'; @@ -14,7 +18,11 @@ export default class Tabs extends Component { static propTypes = { children: childrenPropType, - className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]), + className: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.array, + PropTypes.object, + ]), defaultFocus: PropTypes.bool, defaultIndex: PropTypes.number, disabledTabClassName: PropTypes.string, diff --git a/src/components/UncontrolledTabs.js b/src/components/UncontrolledTabs.js index a32ed11c44..614ba8ac27 100644 --- a/src/components/UncontrolledTabs.js +++ b/src/components/UncontrolledTabs.js @@ -39,7 +39,11 @@ export default class UncontrolledTabs extends Component { static propTypes = { children: childrenPropType, - className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]), + className: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.array, + PropTypes.object, + ]), disabledTabClassName: PropTypes.string, domRef: PropTypes.func, focus: PropTypes.bool, @@ -172,8 +176,10 @@ export default class UncontrolledTabs extends Component { focus: selected && (focus || wasTabFocused), }; - if (selectedTabClassName) props.selectedClassName = selectedTabClassName; - if (disabledTabClassName) props.disabledClassName = disabledTabClassName; + if (selectedTabClassName) + props.selectedClassName = selectedTabClassName; + if (disabledTabClassName) + props.disabledClassName = disabledTabClassName; listIndex++; @@ -188,7 +194,8 @@ export default class UncontrolledTabs extends Component { }; if (forceRenderTabPanel) props.forceRender = forceRenderTabPanel; - if (selectedTabPanelClassName) props.selectedClassName = selectedTabPanelClassName; + if (selectedTabPanelClassName) + props.selectedClassName = selectedTabPanelClassName; index++; diff --git a/src/components/__tests__/TabList-test.js b/src/components/__tests__/TabList-test.js index a612746fa9..fa4ee1576c 100644 --- a/src/components/__tests__/TabList-test.js +++ b/src/components/__tests__/TabList-test.js @@ -51,7 +51,11 @@ describe('', () => { it('should display the custom classnames for selected and disabled tab specified on tabs', () => { expectToMatchSnapshot( - + Foo Bar diff --git a/src/components/__tests__/Tabs-test.js b/src/components/__tests__/Tabs-test.js index 84b74d708f..0f48cf7cf9 100644 --- a/src/components/__tests__/Tabs-test.js +++ b/src/components/__tests__/Tabs-test.js @@ -9,7 +9,11 @@ import TabList from '../TabList'; import TabPanel from '../TabPanel'; import Tabs from '../Tabs'; import { reset as resetIdCounter } from '../../helpers/uuid'; -import { TabListWrapper, TabWrapper, TabPanelWrapper } from './helpers/higherOrder'; +import { + TabListWrapper, + TabWrapper, + TabPanelWrapper, +} from './helpers/higherOrder'; Enzyme.configure({ adapter: new Adapter() }); @@ -195,7 +199,11 @@ describe('', () => { ); console.error = oldConsoleError; // eslint-disable-line no-console - const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs'); + const result = Tabs.propTypes.children( + wrapper.props(), + 'children', + 'Tabs', + ); expect(result).toBeInstanceOf(Error); }); @@ -214,7 +222,11 @@ describe('', () => { ); console.error = oldConsoleError; // eslint-disable-line no-console - const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs'); + const result = Tabs.propTypes.children( + wrapper.props(), + 'children', + 'Tabs', + ); expect(result).toBeInstanceOf(Error); }); @@ -235,7 +247,11 @@ describe('', () => { ); console.error = oldConsoleError; // eslint-disable-line no-console - const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs'); + const result = Tabs.propTypes.children( + wrapper.props(), + 'children', + 'Tabs', + ); expect(result).toBeInstanceOf(Error); }); @@ -299,7 +315,11 @@ describe('', () => { ); console.error = oldConsoleError; // eslint-disable-line no-console - const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs'); + const result = Tabs.propTypes.children( + wrapper.props(), + 'children', + 'Tabs', + ); expect(result).toBeInstanceOf(Error); }); @@ -327,7 +347,11 @@ describe('', () => { , ); - const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs'); + const result = Tabs.propTypes.children( + wrapper.props(), + 'children', + 'Tabs', + ); expect(result instanceof Error).toBe(false); }); @@ -484,7 +508,10 @@ describe('', () => { state = {}; handleSelect = () => this.setState({ foo: 'bar' }); render() { - return createTabs({ onSelect: this.handleSelect, className: this.state.foo }); + return createTabs({ + onSelect: this.handleSelect, + className: this.state.foo, + }); } } diff --git a/src/helpers/childrenDeepMap.js b/src/helpers/childrenDeepMap.js index 2f3d4e1813..2f080b6b64 100644 --- a/src/helpers/childrenDeepMap.js +++ b/src/helpers/childrenDeepMap.js @@ -15,7 +15,11 @@ export function deepMap(children, callback) { return callback(child); } - if (child.props && child.props.children && typeof child.props.children === 'object') { + if ( + child.props && + child.props.children && + typeof child.props.children === 'object' + ) { // Clone the child that has children and map them too return cloneElement(child, { ...child.props, @@ -35,7 +39,11 @@ export function deepForEach(children, callback) { if (isTab(child) || isTabPanel(child)) { callback(child); - } else if (child.props && child.props.children && typeof child.props.children === 'object') { + } else if ( + child.props && + child.props.children && + typeof child.props.children === 'object' + ) { if (isTabList(child)) callback(child); deepForEach(child.props.children, callback); } diff --git a/src/helpers/propTypes.js b/src/helpers/propTypes.js index b302f9a857..d964e89e14 100644 --- a/src/helpers/propTypes.js +++ b/src/helpers/propTypes.js @@ -11,8 +11,14 @@ export function childrenPropType(props, propName, componentName) { deepForEach(children, child => { if (isTabList(child)) { - if (child.props && child.props.children && typeof child.props.children === 'object') { - deepForEach(child.props.children, listChild => listTabs.push(listChild)); + if ( + child.props && + child.props.children && + typeof child.props.children === 'object' + ) { + deepForEach(child.props.children, listChild => + listTabs.push(listChild), + ); } if (tabListFound) { @@ -45,7 +51,13 @@ export function childrenPropType(props, propName, componentName) { return error; } -export function onSelectPropType(props, propName, componentName, location, propFullName) { +export function onSelectPropType( + props, + propName, + componentName, + location, + propFullName, +) { const prop = props[propName]; const name = propFullName || propName; let error = null; @@ -69,7 +81,13 @@ export function onSelectPropType(props, propName, componentName, location, propF return error; } -export function selectedIndexPropType(props, propName, componentName, location, propFullName) { +export function selectedIndexPropType( + props, + propName, + componentName, + location, + propFullName, +) { const prop = props[propName]; const name = propFullName || propName; let error = null;