Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuyang Li committed Feb 20, 2019
1 parent 3dcbb01 commit 373765e
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 81 deletions.
5 changes: 1 addition & 4 deletions packages/core/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,7 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState>
}

private isArrowEnabled() {
const {
minimal,
modifiers: { arrow },
} = this.props;
const { minimal, modifiers: { arrow } } = this.props;
// omitting `arrow` from `modifiers` uses Popper default, which does show an arrow.
return !minimal && (arrow == null || arrow.enabled);
}
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/components/slider/handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,8 @@ export class Handle extends AbstractPureComponent<IInternalHandleProps, IHandleS
const handleRect = handleElement.getBoundingClientRect();

const sizeKey = vertical
? useOppositeDimension
? "width"
: "height"
: useOppositeDimension
? "height"
: "width";
? useOppositeDimension ? "width" : "height"
: useOppositeDimension ? "height" : "width";

// "bottom" value seems to be consistently incorrect, so explicitly
// calculate it using the window offset instead.
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/components/slider/multiSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,9 @@ function getSortedInteractiveHandleProps(props: IChildrenProps): IHandleProps[]
}

function getSortedHandleProps({ children }: IChildrenProps, predicate: (props: IHandleProps) => boolean = () => true) {
const maybeHandles = React.Children.map(children, child =>
Utils.isElementOfType(child, MultiSlider.Handle) && predicate(child.props) ? child.props : null,
const maybeHandles = React.Children.map(
children,
child => (Utils.isElementOfType(child, MultiSlider.Handle) && predicate(child.props) ? child.props : null),
);
let handles = maybeHandles != null ? maybeHandles : [];
handles = handles.filter(handle => handle !== null);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/spinner/spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Spinner extends AbstractPureComponent<ISpinnerProps, {}> {
);

// keep spinner track width consistent at all sizes (down to about 10px).
const strokeWidth = Math.min(MIN_STROKE_WIDTH, (STROKE_WIDTH * Spinner.SIZE_LARGE) / size);
const strokeWidth = Math.min(MIN_STROKE_WIDTH, STROKE_WIDTH * Spinner.SIZE_LARGE / size);

const strokeOffset = PATH_LENGTH - PATH_LENGTH * (value == null ? 0.25 : clamp(value, 0, 1));

Expand Down
6 changes: 4 additions & 2 deletions packages/core/test/popover/popoverTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,16 @@ describe("<Popover>", () => {
afterEach(() => root.detach());

it("shows tooltip on hover", () => {
root.find(`.${Classes.POPOVER_TARGET}`)
root
.find(`.${Classes.POPOVER_TARGET}`)
.last()
.simulate("mouseenter");
assert.lengthOf(root.find(`.${Classes.TOOLTIP}`), 1);
});

it("shows popover on click", () => {
root.find(`.${Classes.POPOVER_TARGET}`)
root
.find(`.${Classes.POPOVER_TARGET}`)
.first()
.simulate("click");
assert.lengthOf(root.find(`.${Classes.POPOVER}`), 1);
Expand Down
4 changes: 1 addition & 3 deletions packages/datetime/src/datePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ export class DatePicker extends AbstractPureComponent<IDatePickerProps, IDatePic
private disabledDays = (day: Date) => !DateUtils.isDayInRange(day, [this.props.minDate, this.props.maxDate]);

private getDisabledDaysModifier = () => {
const {
dayPickerProps: { disabledDays },
} = this.props;
const { dayPickerProps: { disabledDays } } = this.props;

return Array.isArray(disabledDays) ? [this.disabledDays, ...disabledDays] : [this.disabledDays, disabledDays];
};
Expand Down
9 changes: 2 additions & 7 deletions packages/datetime/src/dateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ export class DateRangePicker extends AbstractPureComponent<IDateRangePickerProps
[`${SELECTED_RANGE_MODIFIER}-end`]: day => DateUtils.areSameDay(this.state.value[1], day),

[HOVERED_RANGE_MODIFIER]: day => {
const {
hoverValue,
value: [selectedStart, selectedEnd],
} = this.state;
const { hoverValue, value: [selectedStart, selectedEnd] } = this.state;
if (selectedStart == null && selectedEnd == null) {
return false;
}
Expand Down Expand Up @@ -266,9 +263,7 @@ export class DateRangePicker extends AbstractPureComponent<IDateRangePickerProps
private disabledDays = (day: Date) => !DateUtils.isDayInRange(day, [this.props.minDate, this.props.maxDate]);

private getDisabledDaysModifier = () => {
const {
dayPickerProps: { disabledDays },
} = this.props;
const { dayPickerProps: { disabledDays } } = this.props;

return disabledDays instanceof Array ? [this.disabledDays, ...disabledDays] : [this.disabledDays, disabledDays];
};
Expand Down
6 changes: 4 additions & 2 deletions packages/datetime/test/dateInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ describe("<DateInput>", () => {
const defaultValue = new Date(2018, Months.FEBRUARY, 6, 15, 0, 0, 0);
const { root, changeSelect } = wrap(<DateInput {...DATE_FORMAT} defaultValue={defaultValue} />);
root.setState({ isOpen: true });
root.find("input")
root
.find("input")
.simulate("focus")
.simulate("blur");
changeSelect(Classes.DATEPICKER_MONTH_SELECT, Months.FEBRUARY);
Expand All @@ -135,7 +136,8 @@ describe("<DateInput>", () => {
const defaultValue = new Date(2018, Months.FEBRUARY, 6, 15, 0, 0, 0);
const { root, changeSelect } = wrap(<DateInput {...DATE_FORMAT} defaultValue={defaultValue} />);
root.setState({ isOpen: true });
root.find("input")
root
.find("input")
.simulate("focus")
.simulate("blur");
changeSelect(Classes.DATEPICKER_YEAR_SELECT, 2016);
Expand Down
21 changes: 14 additions & 7 deletions packages/datetime/test/datePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ describe("<DatePicker>", () => {
it("calls onMonthChange on button next click", () => {
const onMonthChange = sinon.spy();
const { root } = wrap(<DatePicker defaultValue={defaultValue} dayPickerProps={{ onMonthChange }} />);
root.find(".DayPicker-NavButton--next")
root
.find(".DayPicker-NavButton--next")
.first()
.simulate("click");
assert.isTrue(onMonthChange.called);
Expand All @@ -146,7 +147,8 @@ describe("<DatePicker>", () => {
it("calls onMonthChange on button prev click", () => {
const onMonthChange = sinon.spy();
const { root } = wrap(<DatePicker defaultValue={defaultValue} dayPickerProps={{ onMonthChange }} />);
root.find(".DayPicker-NavButton--prev")
root
.find(".DayPicker-NavButton--prev")
.first()
.simulate("click");
assert.isTrue(onMonthChange.called);
Expand All @@ -155,7 +157,8 @@ describe("<DatePicker>", () => {
it("calls onMonthChange on month select change", () => {
const onMonthChange = sinon.spy();
const { root } = wrap(<DatePicker defaultValue={defaultValue} dayPickerProps={{ onMonthChange }} />);
root.find({ className: Classes.DATEPICKER_MONTH_SELECT })
root
.find({ className: Classes.DATEPICKER_MONTH_SELECT })
.first()
.find("select")
.simulate("change");
Expand All @@ -165,7 +168,8 @@ describe("<DatePicker>", () => {
it("calls onMonthChange on year select change", () => {
const onMonthChange = sinon.spy();
const { root } = wrap(<DatePicker defaultValue={defaultValue} dayPickerProps={{ onMonthChange }} />);
root.find({ className: Classes.DATEPICKER_YEAR_SELECT })
root
.find({ className: Classes.DATEPICKER_YEAR_SELECT })
.first()
.find("select")
.simulate("change");
Expand Down Expand Up @@ -499,7 +503,8 @@ describe("<DatePicker>", () => {
/>,
);
assert.isTrue(onChangeSpy.notCalled);
root.find(`.${Classes.TIMEPICKER_ARROW_BUTTON}.${Classes.TIMEPICKER_HOUR}`)
root
.find(`.${Classes.TIMEPICKER_ARROW_BUTTON}.${Classes.TIMEPICKER_HOUR}`)
.first()
.simulate("click");
assert.isTrue(onChangeSpy.calledOnce);
Expand Down Expand Up @@ -553,7 +558,8 @@ describe("<DatePicker>", () => {

it("selects the current day when Today is clicked", () => {
const { root } = wrap(<DatePicker showActionsBar={true} />);
root.find({ className: Classes.DATEPICKER_FOOTER })
root
.find({ className: Classes.DATEPICKER_FOOTER })
.find(Button)
.first()
.simulate("click");
Expand All @@ -568,7 +574,8 @@ describe("<DatePicker>", () => {
it("clears the value when Clear is clicked", () => {
const { getDay, root } = wrap(<DatePicker showActionsBar={true} />);
getDay().simulate("click");
root.find({ className: Classes.DATEPICKER_FOOTER })
root
.find({ className: Classes.DATEPICKER_FOOTER })
.find(Button)
.last()
.simulate("click");
Expand Down
33 changes: 22 additions & 11 deletions packages/datetime/test/dateRangePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ describe("<DateRangePicker>", () => {
describe("when only end date is defined", () => {
it("should show a hovered range of [end, day] if day > end", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.clickDay(14) // deselect start date
.mouseEnterDay(22);
Expand All @@ -723,7 +724,8 @@ describe("<DateRangePicker>", () => {

it("should show a hovered range of [null, null] if day === end", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.clickDay(14)
.mouseEnterDay(18);
Expand All @@ -732,7 +734,8 @@ describe("<DateRangePicker>", () => {

it("should show a hovered range of [day, end] if day < end", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.clickDay(14)
.mouseEnterDay(14);
Expand All @@ -743,47 +746,53 @@ describe("<DateRangePicker>", () => {
describe("when both start and end date are defined", () => {
it("should show a hovered range of [null, end] if day === start", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.mouseEnterDay(14);
assertHoveredDays(null, 18);
});

it("should show a hovered range of [start, null] if day === end", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.mouseEnterDay(18);
assertHoveredDays(14, null);
});

it("should show a hovered range of [day, null] if start < day < end", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.mouseEnterDay(16);
assertHoveredDays(16, null);
});

it("should show a hovered range of [day, null] if day < start", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.mouseEnterDay(10);
assertHoveredDays(10, null);
});

it("should show a hovered range of [day, null] if day > end", () => {
const { left, assertHoveredDays } = render();
left.clickDay(14)
left
.clickDay(14)
.clickDay(18)
.mouseEnterDay(22);
assertHoveredDays(22, null);
});

it("should show a hovered range of [null, null] if start === day === end", () => {
const { left, assertHoveredDays } = render({ allowSingleDayRange: true });
left.clickDay(14)
left
.clickDay(14)
.clickDay(14)
.mouseEnterDay(14);
assertHoveredDays(null, null);
Expand Down Expand Up @@ -975,7 +984,8 @@ describe("<DateRangePicker>", () => {
it("onHoverChange fired with `undefined` on mouseleave within a day", () => {
const { left } = render({ initialMonth: new Date(2015, Months.JANUARY, 1) });
assert.isTrue(onHoverChangeSpy.notCalled);
left.clickDay(1)
left
.clickDay(1)
.findDay(5)
.simulate("mouseleave");
assert.isTrue(onHoverChangeSpy.calledTwice);
Expand Down Expand Up @@ -1018,7 +1028,8 @@ describe("<DateRangePicker>", () => {

it("deselects endpoint when an endpoint of the current selection is clicked", () => {
const { assertSelectedDays, left } = render({ initialMonth: new Date(2015, Months.JANUARY, 1) });
left.clickDay(10)
left
.clickDay(10)
.clickDay(14)
.clickDay(10);
assertSelectedDays(14);
Expand Down
6 changes: 4 additions & 2 deletions packages/datetime/test/dateTimePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ describe("<DateTimePicker>", () => {
/>,
);
assert.isTrue(onChangeSpy.notCalled);
root.find(`.${Classes.TIMEPICKER_ARROW_BUTTON}.${Classes.TIMEPICKER_HOUR}`)
root
.find(`.${Classes.TIMEPICKER_ARROW_BUTTON}.${Classes.TIMEPICKER_HOUR}`)
.first()
.simulate("click");
assert.isTrue(onChangeSpy.calledOnce);
Expand All @@ -79,7 +80,8 @@ describe("<DateTimePicker>", () => {
<DateTimePicker defaultValue={defaultValue} timePickerProps={{ showArrowButtons: true }} />,
);
getDay(5).simulate("click");
root.find(`.${Classes.TIMEPICKER_ARROW_BUTTON}.${Classes.TIMEPICKER_HOUR}`)
root
.find(`.${Classes.TIMEPICKER_ARROW_BUTTON}.${Classes.TIMEPICKER_HOUR}`)
.first()
.simulate("click");
getDay(15).simulate("click");
Expand Down
8 changes: 2 additions & 6 deletions packages/docs-app/src/components/colorPalettes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ const ColorSwatch: React.SFC<{ colorName: string; hexCode: string }> = ({ colorN
// vertical list of swatches for each color
const ColorPalette: React.SFC<{ colors: string[] }> = ({ colors }) => (
<div className={classNames("docs-color-palette", { "docs-color-palette-single": colors.length === 1 })}>
{colors.map((name, i) => (
<ColorSwatch colorName={name} hexCode={getHexCode(name)} key={i} />
))}
{colors.map((name, i) => <ColorSwatch colorName={name} hexCode={getHexCode(name)} key={i} />)}
</div>
);

Expand Down Expand Up @@ -94,9 +92,7 @@ export const ColorBar: React.SFC<{ colors: string[] }> = ({ colors }) => {
function createPaletteBook(palettes: string[][], className?: string): React.SFC<{}> {
return () => (
<section className={classNames("docs-color-book", className)}>
{palettes.map((palette, index) => (
<ColorPalette colors={palette} key={index} />
))}
{palettes.map((palette, index) => <ColorPalette colors={palette} key={index} />)}
</section>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ export class PanelStackExample extends React.PureComponent<IExampleProps, IPanel
const stackList = (
<>
<H5>Current stack</H5>
<UL>
{this.state.currentPanelStack.map((p, i) => (
<li key={i}>{p.title}</li>
))}
</UL>
<UL>{this.state.currentPanelStack.map((p, i) => <li key={i}>{p.title}</li>)}</UL>
</>
);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export class FormatSelect extends React.PureComponent<IFormatSelectProps> {
const value = FORMATS.indexOf(this.props.format);
return (
<RadioGroup label="Date format" onChange={this.handleChange} selectedValue={value}>
{FORMATS.map((format, index) => (
<Radio key={index} label={format.placeholder} value={index} />
))}
{FORMATS.map((format, index) => <Radio key={index} label={format.placeholder} value={index} />)}
</RadioGroup>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ export class DateRangePickerExample extends React.PureComponent<IExampleProps, I
<Label>
{label}
<HTMLSelect value={selectedValue} onChange={onChange}>
{options.map((opt, i) => (
<option key={i} value={i} label={opt.label} />
))}
{options.map((opt, i) => <option key={i} value={i} label={opt.label} />)}
</HTMLSelect>
</Label>
);
Expand Down
Loading

0 comments on commit 373765e

Please sign in to comment.