From bbaf62ace992f40e8db4d73f55f3d8b697e1151f Mon Sep 17 00:00:00 2001 From: Gildas Garcia Date: Sat, 15 Jun 2019 11:03:23 +0200 Subject: [PATCH] Prettier --- .../ra-core/src/controller/EditController.tsx | 6 ++- .../ra-core/src/controller/ShowController.tsx | 6 ++- .../field/ReferenceFieldController.tsx | 5 ++- .../src/field/ReferenceField.js | 18 ++++++--- .../ra-ui-materialui/src/form/TabbedForm.js | 4 +- .../src/form/TabbedFormTabs.js | 17 +++++--- .../src/form/TabbedFormTabs.spec.js | 6 +-- .../src/input/AutocompleteArrayInput.js | 40 +++++++++++-------- 8 files changed, 66 insertions(+), 36 deletions(-) diff --git a/packages/ra-core/src/controller/EditController.tsx b/packages/ra-core/src/controller/EditController.tsx index 5f6fa7d013..de0564a814 100644 --- a/packages/ra-core/src/controller/EditController.tsx +++ b/packages/ra-core/src/controller/EditController.tsx @@ -81,7 +81,11 @@ interface Props { * export default App; */ const EditController = (props: Props) => { - useCheckMinimumRequiredProps('Edit', ['basePath', 'resource', 'children'], props); + useCheckMinimumRequiredProps( + 'Edit', + ['basePath', 'resource', 'children'], + props + ); const { basePath, children, id, resource, undoable } = props; const translate = useTranslate(); const dispatch = useDispatch(); diff --git a/packages/ra-core/src/controller/ShowController.tsx b/packages/ra-core/src/controller/ShowController.tsx index bdbda6682d..270f36aa14 100644 --- a/packages/ra-core/src/controller/ShowController.tsx +++ b/packages/ra-core/src/controller/ShowController.tsx @@ -71,7 +71,11 @@ interface Props { * export default App; */ const ShowController = (props: Props) => { - useCheckMinimumRequiredProps('Show', ['basePath', 'resource', 'children'], props); + useCheckMinimumRequiredProps( + 'Show', + ['basePath', 'resource', 'children'], + props + ); const { basePath, children, id, resource } = props; const translate = useTranslate(); const version = useVersion(); diff --git a/packages/ra-core/src/controller/field/ReferenceFieldController.tsx b/packages/ra-core/src/controller/field/ReferenceFieldController.tsx index 131c7d7376..f6172e714e 100644 --- a/packages/ra-core/src/controller/field/ReferenceFieldController.tsx +++ b/packages/ra-core/src/controller/field/ReferenceFieldController.tsx @@ -1,6 +1,9 @@ import { FunctionComponent, ReactNode, ReactElement } from 'react'; import { Record } from '../../types'; -import useReference, { UseReferenceProps, LinkToFunctionType } from './useReference'; +import useReference, { + UseReferenceProps, + LinkToFunctionType, +} from './useReference'; interface Props { allowEmpty?: boolean; diff --git a/packages/ra-ui-materialui/src/field/ReferenceField.js b/packages/ra-ui-materialui/src/field/ReferenceField.js index 04f63fd426..ac291146c4 100644 --- a/packages/ra-ui-materialui/src/field/ReferenceField.js +++ b/packages/ra-ui-materialui/src/field/ReferenceField.js @@ -117,16 +117,16 @@ ReferenceFieldView.propTypes = { * * * - * + * * @default * Alternatively, you can also pass a custom function to `link`. It must take reference and record * as arguments and return a string - * + * * @example * "/path/to/${reference}/${record}"}> * * - * + * * @default * In previous versions of React-Admin, the prop `linkType` was used. It is now deprecated and replaced with `link`. However * backward-compatibility is still kept @@ -168,8 +168,16 @@ ReferenceField.propTypes = { sortBy: PropTypes.string, source: PropTypes.string.isRequired, translateChoice: PropTypes.func, - linkType: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.func]), - link: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.func]).isRequired, + linkType: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.bool, + PropTypes.func, + ]), + link: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.bool, + PropTypes.func, + ]).isRequired, }; ReferenceField.defaultProps = { diff --git a/packages/ra-ui-materialui/src/form/TabbedForm.js b/packages/ra-ui-materialui/src/form/TabbedForm.js index 5abfeacdc5..cfd709f82f 100644 --- a/packages/ra-ui-materialui/src/form/TabbedForm.js +++ b/packages/ra-ui-materialui/src/form/TabbedForm.js @@ -99,7 +99,7 @@ export class TabbedForm extends Component { value, version, ...rest - } = this.props; + } = this.props; return (
diff --git a/packages/ra-ui-materialui/src/form/TabbedFormTabs.js b/packages/ra-ui-materialui/src/form/TabbedFormTabs.js index 5c6c7b39a2..3170f50e61 100644 --- a/packages/ra-ui-materialui/src/form/TabbedFormTabs.js +++ b/packages/ra-ui-materialui/src/form/TabbedFormTabs.js @@ -1,15 +1,20 @@ import React, { Children, cloneElement, isValidElement } from 'react'; import PropTypes from 'prop-types'; import Tabs from '@material-ui/core/Tabs'; -import compose from 'recompose/compose'; const getTabFullPath = (tab, index, baseUrl) => `${baseUrl}${ tab.props.path ? `/${tab.props.path}` : index > 0 ? `/${index}` : '' }`; -const TabbedFormTabs = ({ children, classes, currentLocationPath, match, tabsWithErrors, ...rest }) => { - +const TabbedFormTabs = ({ + children, + classes, + currentLocationPath, + match, + tabsWithErrors, + ...rest +}) => { const validTabPaths = Children.toArray(children).map((tab, index) => getTabFullPath(tab, index, match.url) ); @@ -26,7 +31,7 @@ const TabbedFormTabs = ({ children, classes, currentLocationPath, match, tabsWit : validTabPaths[0]; return ( - + {Children.map(children, (tab, index) => { if (!isValidElement(tab)) return null; @@ -41,7 +46,7 @@ const TabbedFormTabs = ({ children, classes, currentLocationPath, match, tabsWit value: tabPath, className: tabsWithErrors.includes(tab.props.label) && - currentLocationPath !== tabPath + currentLocationPath !== tabPath ? classes.errorTabButton : null, }); @@ -58,4 +63,4 @@ TabbedFormTabs.propTypes = { tabsWithErrors: PropTypes.arrayOf(PropTypes.string), }; -export default TabbedFormTabs; \ No newline at end of file +export default TabbedFormTabs; diff --git a/packages/ra-ui-materialui/src/form/TabbedFormTabs.spec.js b/packages/ra-ui-materialui/src/form/TabbedFormTabs.spec.js index c108039d3a..b2bf30bc74 100644 --- a/packages/ra-ui-materialui/src/form/TabbedFormTabs.spec.js +++ b/packages/ra-ui-materialui/src/form/TabbedFormTabs.spec.js @@ -12,7 +12,7 @@ describe('', () => { classes={{ errorTabButton: 'error' }} currentLocationPath={'/posts/12'} match={{ url: '/posts/12' }} - tabsWithErrors={['tab2']} + tabsWithErrors={['tab2']} > @@ -33,7 +33,7 @@ describe('', () => { classes={{ errorTabButton: 'error' }} currentLocationPath={'/posts/12'} match={{ url: '/posts/12' }} - tabsWithErrors={['tab1']} + tabsWithErrors={['tab1']} > @@ -47,4 +47,4 @@ describe('', () => { assert.equal(tab1.prop('className'), null); assert.equal(tab2.prop('className'), null); }); -}); \ No newline at end of file +}); diff --git a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js index 0a24e2b977..79dd177bfe 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js +++ b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js @@ -147,13 +147,15 @@ export class AutocompleteArrayInput extends React.Component { this.updateFilter(''); } else if (!isEqual(choices, this.props.choices)) { this.setState(({ searchText }) => ({ - suggestions: this.limitSuggestions(choices.filter(suggestion => - inputValueMatcher( - searchText, - suggestion, - this.getSuggestionText + suggestions: this.limitSuggestions( + choices.filter(suggestion => + inputValueMatcher( + searchText, + suggestion, + this.getSuggestionText + ) ) - )), + ), })); } } @@ -192,13 +194,15 @@ export class AutocompleteArrayInput extends React.Component { const { choices, inputValueMatcher } = this.props; this.setState(({ searchText }) => ({ - suggestions: this.limitSuggestions(choices.filter(suggestion => - inputValueMatcher( - searchText, - suggestion, - this.getSuggestionText + suggestions: this.limitSuggestions( + choices.filter(suggestion => + inputValueMatcher( + searchText, + suggestion, + this.getSuggestionText + ) ) - )), + ), })); }; @@ -418,11 +422,13 @@ export class AutocompleteArrayInput extends React.Component { } else { this.setState({ searchText: value, - suggestions: this.limitSuggestions(choices.filter(choice => - this.getSuggestionText(choice) - .toLowerCase() - .includes(value.toLowerCase()) - )), + suggestions: this.limitSuggestions( + choices.filter(choice => + this.getSuggestionText(choice) + .toLowerCase() + .includes(value.toLowerCase()) + ) + ), }); } }