Skip to content

Commit

Permalink
Add prettier always arrowParens (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
roginfarrer committed Apr 17, 2020
1 parent dea827f commit c428108
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Demo() {
<div>
<button
{...getToggleProps({
onClick: () => setOpen(oldOpen => !oldOpen),
onClick: () => setOpen((oldOpen) => !oldOpen),
})}
>
{isExpanded ? 'Collapse' : 'Expand'}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
}
},
"prettier": {
"bracketSpacing": true,
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "es5",
"arrowParens": "always"
},
"devDependencies": {
"@babel/core": "^7.8.4",
Expand Down
4 changes: 2 additions & 2 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function useControlledState({
: stateExpanded;
const toggleExpanded = useCallback(() => {
if (!initiallyControlled.current) {
setStateExpanded(oldExpanded => !oldExpanded);
setStateExpanded((oldExpanded) => !oldExpanded);
}
}, []);

Expand Down Expand Up @@ -70,7 +70,7 @@ export function usePaddingWarning(element: RefObject<HTMLElement>): void {
let warn = (el?: RefObject<HTMLElement>): void => {};

if (__DEV__) {
warn = el => {
warn = (el) => {
if (!el?.current) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function useCollapse({
);
const [mountChildren, setMountChildren] = useState<boolean>(isExpanded);
const mergeStyles = (newStyles: {}): void => {
setStyles(oldStyles => ({ ...oldStyles, ...newStyles }));
setStyles((oldStyles) => ({ ...oldStyles, ...newStyles }));
};

function getTransitionStyles(
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getElementHeight(

// Helper function for render props. Sets a function to be called, plus any additional functions passed in
export const callAll = (...fns: AnyFunction[]) => (...args: any[]): void =>
fns.forEach(fn => fn && fn(...args));
fns.forEach((fn) => fn && fn(...args));

// https://github.com/mui-org/material-ui/blob/da362266f7c137bf671d7e8c44c84ad5cfc0e9e2/packages/material-ui/src/styles/transitions.js#L89-L98
export function getAutoHeightDuration(height: number | string): number {
Expand Down Expand Up @@ -64,11 +64,11 @@ export function assignRef<RefValueType = any>(
export function mergeRefs<RefValueType = any>(
...refs: (AssignableRef<RefValueType> | null | undefined)[]
) {
if (refs.every(ref => ref == null)) {
if (refs.every((ref) => ref == null)) {
return null;
}
return (node: any) => {
refs.forEach(ref => {
refs.forEach((ref) => {
assignRef(ref, node);
});
};
Expand Down
2 changes: 1 addition & 1 deletion stories/basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Controlled = () => {

return (
<div>
<Toggle {...getToggleProps({ onClick: () => setOpen(old => !old) })}>
<Toggle {...getToggleProps({ onClick: () => setOpen((old) => !old) })}>
{isExpanded ? 'Close' : 'Open'}
</Toggle>
<Collapse {...getCollapseProps()}>{excerpt}</Collapse>
Expand Down

0 comments on commit c428108

Please sign in to comment.