Skip to content

Commit

Permalink
🔧 upgrade tslint (#3315)
Browse files Browse the repository at this point in the history
  • Loading branch information
giladgray authored and adidahiya committed Feb 12, 2019
1 parent dee3aea commit f78265f
Show file tree
Hide file tree
Showing 30 changed files with 160 additions and 127 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,10 @@ 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: 6 additions & 2 deletions packages/core/src/components/slider/handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@ 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: 2 additions & 3 deletions packages/core/src/components/slider/multiSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,8 @@ 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: 2 additions & 4 deletions packages/core/test/popover/popoverTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,16 +597,14 @@ 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: 3 additions & 1 deletion packages/datetime/src/datePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ 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
21 changes: 13 additions & 8 deletions packages/datetime/src/dateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ 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 @@ -263,7 +266,9 @@ 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 Expand Up @@ -564,12 +569,12 @@ export class DateRangePicker extends AbstractPureComponent<IDateRangePickerProps
}

/*
* The min / max months are offset by one because we are showing two months.
* We do a comparison check to see if
* a) the proposed [Month, Year] change throws the two calendars out of order
* b) the proposed [Month, Year] goes beyond the min / max months
* and rectify appropriately.
*/
* The min / max months are offset by one because we are showing two months.
* We do a comparison check to see if
* a) the proposed [Month, Year] change throws the two calendars out of order
* b) the proposed [Month, Year] goes beyond the min / max months
* and rectify appropriately.
*/
private handleLeftYearSelectChange = (leftDisplayYear: number) => {
let leftView = new MonthAndYear(this.state.leftView.getMonth(), leftDisplayYear);
Utils.safeInvoke(this.props.dayPickerProps.onMonthChange, leftView.getFullDate());
Expand Down
6 changes: 2 additions & 4 deletions packages/datetime/test/dateInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ 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 @@ -136,8 +135,7 @@ 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: 7 additions & 14 deletions packages/datetime/test/datePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ 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 @@ -147,8 +146,7 @@ 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 @@ -157,8 +155,7 @@ 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 @@ -168,8 +165,7 @@ 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 @@ -503,8 +499,7 @@ 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 @@ -558,8 +553,7 @@ 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 @@ -574,8 +568,7 @@ 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: 11 additions & 22 deletions packages/datetime/test/dateRangePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ 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 @@ -724,8 +723,7 @@ 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 @@ -734,8 +732,7 @@ 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 @@ -746,53 +743,47 @@ 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 @@ -984,8 +975,7 @@ 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 @@ -1028,8 +1018,7 @@ 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: 2 additions & 4 deletions packages/datetime/test/dateTimePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ 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 @@ -80,8 +79,7 @@ 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: 6 additions & 2 deletions packages/docs-app/src/components/colorPalettes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ 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 @@ -92,7 +94,9 @@ 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
8 changes: 4 additions & 4 deletions packages/docs-app/src/components/navIcons.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the terms of the LICENSE file distributed with this project.
*/
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the terms of the LICENSE file distributed with this project.
*/

import React from "react";

Expand Down
12 changes: 8 additions & 4 deletions packages/docs-app/src/examples/core-examples/collapseExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ export class CollapseExample extends React.PureComponent<IExampleProps, ICollaps
<Button onClick={this.handleClick}>{this.state.isOpen ? "Hide" : "Show"} build logs</Button>
<Collapse isOpen={this.state.isOpen} keepChildrenMounted={this.state.keepChildrenMounted}>
<Pre>
[11:53:30] Finished 'typescript-bundle-blueprint' after 769 ms<br />
[11:53:30] Starting 'typescript-typings-blueprint'...<br />
[11:53:30] Finished 'typescript-typings-blueprint' after 198 ms<br />
[11:53:30] write ./blueprint.css<br />
[11:53:30] Finished 'typescript-bundle-blueprint' after 769 ms
<br />
[11:53:30] Starting 'typescript-typings-blueprint'...
<br />
[11:53:30] Finished 'typescript-typings-blueprint' after 198 ms
<br />
[11:53:30] write ./blueprint.css
<br />
[11:53:30] Finished 'sass-compile-blueprint' after 2.84 s
</Pre>
</Collapse>
Expand Down
Loading

1 comment on commit f78265f

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 upgrade tslint (#3315)

Previews: documentation | landing | table

Please sign in to comment.