Skip to content

Commit 31e7f67

Browse files
committed
auto fix lint/prettier
1 parent c49389e commit 31e7f67

19 files changed

+95
-175
lines changed

src/scripts/AutoAlign.tsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ function ignoreFirstCall(func: Function) {
143143
function removeAbsoluteAlign(
144144
alignment: RectangleAlignment
145145
): RectangleAlignment {
146-
return (alignment.map(
146+
return alignment.map(
147147
(a) => a.replace(/-absolute$/, '') as Align
148-
) as unknown) as RectangleAlignment;
148+
) as unknown as RectangleAlignment;
149149
}
150150

151151
export type AutoAlignOptions = {
@@ -287,12 +287,8 @@ export function autoAlign(options: AutoAlignOptions) {
287287
// eslint-disable-next-line react/destructuring-assignment
288288
const oldTriggerNodeRect = this.state.triggerNodeRect;
289289
if (triggerEl) {
290-
const {
291-
top,
292-
left,
293-
width,
294-
height,
295-
} = triggerEl.getBoundingClientRect();
290+
const { top, left, width, height } =
291+
triggerEl.getBoundingClientRect();
296292
if (
297293
!isEqualRect(oldTriggerNodeRect, { top, left, width, height })
298294
) {
@@ -307,10 +303,8 @@ export function autoAlign(options: AutoAlignOptions) {
307303
};
308304

309305
updateAlignment = (triggerNodeRect: Rect = EMPTY_RECT) => {
310-
const {
311-
triggerNodeRect: oldTriggerNodeRect,
312-
alignment: oldAlignment,
313-
} = this.state;
306+
const { triggerNodeRect: oldTriggerNodeRect, alignment: oldAlignment } =
307+
this.state;
314308
const rootNodeRect = this.node
315309
? this.node.getBoundingClientRect()
316310
: EMPTY_RECT;
@@ -355,10 +349,8 @@ export function autoAlign(options: AutoAlignOptions) {
355349
};
356350

357351
render() {
358-
const {
359-
triggerNodeRect = EMPTY_RECT,
360-
rootNodeRect = EMPTY_RECT,
361-
} = this.state;
352+
const { triggerNodeRect = EMPTY_RECT, rootNodeRect = EMPTY_RECT } =
353+
this.state;
362354
const {
363355
// eslint-disable-next-line react/destructuring-assignment
364356
alignment = this.state.alignment,
@@ -387,7 +379,7 @@ export function autoAlign(options: AutoAlignOptions) {
387379
<Cmp
388380
alignment={removeAbsoluteAlign(alignment)}
389381
ref={(cmp: any) => (this.content = cmp)}
390-
{...pprops as TOriginalProps}
382+
{...(pprops as TOriginalProps)}
391383
>
392384
{children}
393385
</Cmp>

src/scripts/CheckboxGroup.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ export class CheckboxGroup<
107107
{React.Children.map(children, this.renderControl)}
108108
{errorMessage ? (
109109
<div className='slds-form-element__help'>{errorMessage}</div>
110-
) : (
111-
undefined
112-
)}
110+
) : undefined}
113111
</div>
114112
</fieldset>
115113
);

src/scripts/ComponentSettings.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export const ComponentSettingsContext = createContext<
1919
/**
2020
*
2121
*/
22-
export class ComponentSettings extends React.PureComponent<
23-
ComponentSettingsProps
24-
> {
22+
export class ComponentSettings extends React.PureComponent<ComponentSettingsProps> {
2523
render() {
2624
const {
2725
assetRoot,

src/scripts/DateInput.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,7 @@ class DateInputInner extends Component<
385385
onSelect={this.onDatepickerSelect}
386386
onClose={this.onDatepickerClose}
387387
/>
388-
) : (
389-
undefined
390-
)}
388+
) : undefined}
391389
</div>
392390
</FormElement>
393391
);

src/scripts/Datepicker.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,8 @@ function createCalendarObject(date?: string, mnDate?: string, mxDate?: string) {
5252
}
5353
const year = d.year();
5454
const month = d.month();
55-
const first = moment(d)
56-
.startOf('month')
57-
.startOf('week');
58-
const last = moment(d)
59-
.endOf('month')
60-
.endOf('week');
55+
const first = moment(d).startOf('month').startOf('week');
56+
const last = moment(d).endOf('month').endOf('week');
6157
const weeks = [];
6258
let days = [];
6359
for (let dd = first; dd.isBefore(last); dd = dd.add(1, 'd')) {
@@ -197,9 +193,7 @@ class DatepickerInner extends Component<
197193
onMonthChange(month: number) {
198194
// eslint-disable-next-line react/no-access-state-in-setstate
199195
let targetDate = this.state.targetDate || this.props.selectedDate;
200-
targetDate = moment(targetDate)
201-
.add(month, 'months')
202-
.format('YYYY-MM-DD');
196+
targetDate = moment(targetDate).add(month, 'months').format('YYYY-MM-DD');
203197
this.setState({ targetDate });
204198
}
205199

src/scripts/DropdownButton.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ export type DropdownButtonProps<EventKey extends Key> = {
3535
onMenuSelect?: (eventKey: EventKey) => void;
3636
} & Omit<ButtonProps, 'onClick' | 'onBlur'>;
3737

38-
type DropdownButtonInnerProps<EventKey extends Key> = DropdownButtonProps<
39-
EventKey
40-
> & {
41-
getActiveElement: () => HTMLElement | null;
42-
};
38+
type DropdownButtonInnerProps<EventKey extends Key> =
39+
DropdownButtonProps<EventKey> & {
40+
getActiveElement: () => HTMLElement | null;
41+
};
4342

4443
type DropdownButtonInnerState = {
4544
opened: boolean;
@@ -243,7 +242,7 @@ class DropdownButtonInner<EventKey extends Key> extends Component<
243242
onMenuSelect={this.onMenuSelect}
244243
onMenuClose={this.onMenuClose}
245244
onBlur={this.onBlur}
246-
style={Object.assign({ transition: 'none' }, menuStyle)}
245+
style={{ transition: 'none', ...menuStyle }}
247246
>
248247
{children}
249248
</DropdownMenu>

src/scripts/DropdownMenu.tsx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -170,37 +170,36 @@ class DropdownMenuItemInner extends Component<
170170
}
171171
}
172172

173-
export const DropdownMenuItem = (props: DropdownMenuItemProps) => {
173+
export function DropdownMenuItem(props: DropdownMenuItemProps) {
174174
return (
175175
<DropdownMenuHandlerContext.Consumer>
176176
{(handlers) => <DropdownMenuItemInner {...props} {...handlers} />}
177177
</DropdownMenuHandlerContext.Consumer>
178178
);
179-
};
179+
}
180180

181181
export const MenuItem = DropdownMenuItem;
182182

183183
type Key = string | number;
184184

185-
export type DropdownMenuProps<EventKey extends Key> = HTMLAttributes<
186-
HTMLElement
187-
> & {
188-
size?: 'small' | 'medium' | 'large';
189-
header?: string;
190-
nubbin?:
191-
| 'top'
192-
| 'top left'
193-
| 'top right'
194-
| 'bottom'
195-
| 'bottom left'
196-
| 'bottom right'
197-
| 'auto';
198-
nubbinTop?: boolean; // for backward compatibility. use nubbin instead
199-
hoverPopup?: boolean;
200-
onMenuSelect?: (eventKey: EventKey) => void;
201-
onMenuClose?: () => void;
202-
dropdownMenuRef?: (node: HTMLDivElement) => void;
203-
};
185+
export type DropdownMenuProps<EventKey extends Key> =
186+
HTMLAttributes<HTMLElement> & {
187+
size?: 'small' | 'medium' | 'large';
188+
header?: string;
189+
nubbin?:
190+
| 'top'
191+
| 'top left'
192+
| 'top right'
193+
| 'bottom'
194+
| 'bottom left'
195+
| 'bottom right'
196+
| 'auto';
197+
nubbinTop?: boolean; // for backward compatibility. use nubbin instead
198+
hoverPopup?: boolean;
199+
onMenuSelect?: (eventKey: EventKey) => void;
200+
onMenuClose?: () => void;
201+
dropdownMenuRef?: (node: HTMLDivElement) => void;
202+
};
204203

205204
class DropdownMenuInner<EventKey extends Key> extends Component<
206205
DropdownMenuProps<EventKey> & InjectedProps
@@ -312,9 +311,9 @@ function preventPortalizeOnHoverPopup<EventKey extends Key>(
312311
Cmp: ComponentType<DropdownMenuProps<EventKey> & AutoAlignProps>
313312
) {
314313
type ResultProps = DropdownMenuProps<EventKey> & AutoAlignProps;
315-
return (props: ResultProps) => (
316-
<Cmp preventPortalize={!!props.hoverPopup} {...props} />
317-
);
314+
return function (props: ResultProps) {
315+
return <Cmp preventPortalize={!!props.hoverPopup} {...props} />;
316+
};
318317
}
319318

320319
type DropdownMenuType = <EventKey extends Key>(

src/scripts/FormElement.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ export class FormElement extends React.Component<FormElementProps, {}> {
5757
{label}
5858
{required ? <abbr className='slds-required'>*</abbr> : undefined}
5959
</label>
60-
) : (
61-
undefined
62-
);
60+
) : undefined;
6361
}
6462

6563
renderControl(props: { children: any; dropdown: any; error: any }) {
@@ -90,9 +88,7 @@ export class FormElement extends React.Component<FormElementProps, {}> {
9088
<span key='slds-form-error' className='slds-form-element__help'>
9189
{errorMessage}
9290
</span>
93-
) : (
94-
undefined
95-
);
91+
) : undefined;
9692
}
9793

9894
render() {

src/scripts/Lookup.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,8 @@ type LookupCandidateListInternalProps<LookupEntry extends Entry> = {
380380
footer?: JSX.Element;
381381
};
382382

383-
export type LookupCandidateListProps<
384-
LookupEntry extends Entry
385-
> = LookupCandidateListInternalProps<LookupEntry> & InjectedProps;
383+
export type LookupCandidateListProps<LookupEntry extends Entry> =
384+
LookupCandidateListInternalProps<LookupEntry> & InjectedProps;
386385

387386
/**
388387
*
@@ -481,9 +480,7 @@ class LookupCandidateList<LookupEntry extends Entry> extends Component<
481480
icon={icon}
482481
size='small'
483482
/>
484-
) : (
485-
undefined
486-
)}
483+
) : undefined}
487484
<div className='slds-truncate'>
488485
<span className='slds-lookup__result-text slds-truncate'>
489486
{label}
@@ -492,9 +489,7 @@ class LookupCandidateList<LookupEntry extends Entry> extends Component<
492489
<span className='slds-lookup__result-meta slds-truncate'>
493490
{meta}
494491
</span>
495-
) : (
496-
undefined
497-
)}
492+
) : undefined}
498493
</div>
499494
</span>
500495
</a>
@@ -551,9 +546,7 @@ class LookupCandidateList<LookupEntry extends Entry> extends Component<
551546
style={{ margin: '0 auto' }}
552547
/>
553548
</li>
554-
) : (
555-
undefined
556-
)}
549+
) : undefined}
557550
</ul>
558551
{footer ? <div className='slds-lookup__item'>{footer}</div> : undefined}
559552
</div>
@@ -565,10 +558,10 @@ type LookupCandidateListPortalType = <LookupEntry extends Entry>(
565558
props: LookupCandidateListInternalProps<LookupEntry> & AutoAlignProps
566559
) => JSX.Element;
567560

568-
const LookupCandidateListPortal: LookupCandidateListPortalType = (autoAlign({
561+
const LookupCandidateListPortal: LookupCandidateListPortalType = autoAlign({
569562
triggerSelector: '.slds-lookup',
570563
alignmentStyle: 'menu',
571-
})(LookupCandidateList) as unknown) as LookupCandidateListPortalType;
564+
})(LookupCandidateList) as unknown as LookupCandidateListPortalType;
572565

573566
export type LookupProps<
574567
LookupEntry extends Entry,
@@ -871,9 +864,7 @@ export class LookupInner<
871864
onSelect={this.onLookupItemSelect.bind(this)}
872865
onBlur={this.onBlur.bind(this)}
873866
/>
874-
) : (
875-
undefined
876-
)}
867+
) : undefined}
877868
</div>
878869
</FormElement>
879870
);

src/scripts/Modal.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,8 @@ export class Modal extends Component<ModalProps> {
121121
}
122122

123123
render() {
124-
const {
125-
className,
126-
opened,
127-
children,
128-
size,
129-
containerStyle,
130-
...props
131-
} = this.props;
124+
const { className, opened, children, size, containerStyle, ...props } =
125+
this.props;
132126
delete props.onHide;
133127
const modalClassNames = classnames(className, 'slds-modal', {
134128
'slds-fade-in-open': opened,

0 commit comments

Comments
 (0)