Skip to content

Commit

Permalink
chore: upgrade to Prettier 2.0 (#4081)
Browse files Browse the repository at this point in the history
Prettier changed their method chain breaking heuristic, so there are a bunch of autoformatted lines changed in this PR.
  • Loading branch information
adidahiya authored Apr 21, 2020
1 parent f4e58c6 commit 4873110
Show file tree
Hide file tree
Showing 41 changed files with 149 additions and 588 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"http-server": "^0.11.1",
"lerna": "^2.11.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"sinon": "^7.3.2",
"stylelint-config-palantir": "^4.0.0",
"stylelint-scss": "^3.9.2",
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/editable-text/editableText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ export class EditableText extends AbstractPureComponent2<IEditableTextProps, IEd
return (
<div className={classes} onFocus={this.handleFocus} tabIndex={tabIndex}>
{alwaysRenderInput || this.state.isEditing ? this.renderInput(value) : undefined}
{shouldHideContents ? (
undefined
) : (
{shouldHideContents ? undefined : (
<span className={Classes.EDITABLE_TEXT_CONTENT} ref={this.refHandlers.content} style={contentStyle}>
{hasValue ? value : this.props.placeholder}
</span>
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/components/hotkeys/hotkeyParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,7 @@ export function comboMatches(a: IKeyCombo, b: IKeyCombo) {
* unshifted version. For example, `@` is equivalent to `shift+2`.
*/
export const parseKeyCombo = (combo: string): IKeyCombo => {
const pieces = combo
.replace(/\s/g, "")
.toLowerCase()
.split("+");
const pieces = combo.replace(/\s/g, "").toLowerCase().split("+");
let modifiers = 0;
let key = null as string;
for (let piece of pieces) {
Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/context-menu/contextMenuTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ describe("ContextMenu", () => {
rightClickMe.simulate("contextmenu");
assertContextMenuWasRendered();

rightClickMe
.find(RightClickMe)
.last()
.simulate("contextmenu");
rightClickMe.find(RightClickMe).last().simulate("contextmenu");
assertContextMenuWasRendered(childItems.length);
});

Expand Down
20 changes: 4 additions & 16 deletions packages/core/test/controls/numericInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ describe("<NumericInput>", () => {
incrementButton.simulate("mousedown");
dispatchMouseEvent(document, "mouseup");

const inputElement = component
.find("input")
.first()
.getDOMNode();
const inputElement = component.find("input").first().getDOMNode();
expect(onValueChangeSpy.calledOnceWithExactly(1, "1", inputElement)).to.be.true;
});

Expand Down Expand Up @@ -629,10 +626,7 @@ describe("<NumericInput>", () => {
const newValue = component.state().value;
expect(newValue).to.equal("0");

const inputElement = component
.find("input")
.first()
.getDOMNode();
const inputElement = component.find("input").first().getDOMNode();
expect(onValueChangeSpy.calledOnceWithExactly(0, "0", inputElement)).to.be.true;
});

Expand Down Expand Up @@ -706,10 +700,7 @@ describe("<NumericInput>", () => {
const newValue = component.state().value;
expect(newValue).to.equal("0");

const inputElement = component
.find("input")
.first()
.getDOMNode();
const inputElement = component.find("input").first().getDOMNode();
expect(onValueChangeSpy.calledOnceWithExactly(0, "0", inputElement)).to.be.true;
});

Expand Down Expand Up @@ -740,10 +731,7 @@ describe("<NumericInput>", () => {
.simulate("mousedown");
expect(component.state().value).to.equal("2");

const inputElement = component
.find("input")
.first()
.getDOMNode();
const inputElement = component.find("input").first().getDOMNode();
expect(onValueChangeSpy.calledOnceWithExactly(2, "2", inputElement)).to.be.true;
});
});
Expand Down
8 changes: 1 addition & 7 deletions packages/core/test/controls/radioGroupTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ describe("<RadioGroup>", () => {
const OPTIONS = [{ value: "text" }, { value: 23 }];
const group = mount(<RadioGroup onChange={emptyHandler} options={OPTIONS} selectedValue="b" />);
OPTIONS.forEach(props => {
assert.strictEqual(
findInput(group, props)
.parents()
.first()
.text(),
props.value.toString(),
);
assert.strictEqual(findInput(group, props).parents().first().text(), props.value.toString());
});
});

Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/dialog/dialogTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ describe("<Dialog>", () => {
dialog body
</Dialog>,
);
dialog
.find(`.${Classes.DIALOG_HEADER}`)
.find(Button)
.simulate("click");
dialog.find(`.${Classes.DIALOG_HEADER}`).find(Button).simulate("click");
assert.isTrue(onClose.calledOnce, "onClose not called");
});
});
Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/drawer/drawerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,7 @@ describe("<Drawer>", () => {
drawer body
</Drawer>,
);
drawer
.find(`.${Classes.DRAWER_HEADER}`)
.find(Button)
.simulate("click");
drawer.find(`.${Classes.DRAWER_HEADER}`).find(Button).simulate("click");
assert.isTrue(onClose.calledOnce, "onClose not called");
});
});
Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/editable-text/editableTextTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@ describe("<EditableText>", () => {
}

function simulateHelper(wrapper: ReactWrapper<any, {}>, value: string, e: IFakeKeyboardEvent) {
wrapper
.find("textarea")
.simulate("change", { target: { value } })
.simulate("keydown", e);
wrapper.find("textarea").simulate("change", { target: { value } }).simulate("keydown", e);
}
});
});
13 changes: 2 additions & 11 deletions packages/core/test/menu/menuItemTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ describe("MenuItem", () => {
<Button />
</Popover>,
);
wrapper
.find(MenuItem)
.find("a")
.simulate("click");
wrapper.find(MenuItem).find("a").simulate("click");
assert.isTrue(handleClose.notCalled);
});

Expand All @@ -124,13 +121,7 @@ describe("MenuItem", () => {
</MenuItem>,
);
assert.strictEqual(wrapper.find(Popover).prop("interactionKind"), popoverProps.interactionKind);
assert.notStrictEqual(
wrapper
.find(Popover)
.prop("popoverClassName")
.indexOf(popoverProps.popoverClassName),
0,
);
assert.notStrictEqual(wrapper.find(Popover).prop("popoverClassName").indexOf(popoverProps.popoverClassName), 0);
assert.notStrictEqual(wrapper.find(Popover).prop("content"), popoverProps.content);
});

Expand Down
8 changes: 2 additions & 6 deletions packages/core/test/overflow-list/overflowListTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ITEMS: ITestItem[] = IDS.map(id => ({ id }));
const TestItem: React.SFC<ITestItem> = () => <div style={{ width: 10, flex: "0 0 auto" }} />;
const TestOverflow: React.SFC<{ items: ITestItem[] }> = () => <div />;

describe("<OverflowList>", function(this) {
describe("<OverflowList>", function (this) {
// these tests rely on DOM measurement which can be flaky, so we allow some retries
this.retries(3);

Expand All @@ -58,11 +58,7 @@ describe("<OverflowList>", function(this) {
});

it("adds className to itself", () => {
assert.isTrue(
overflowList(30, { className: "winner" })
.find(".winner")
.exists(),
);
assert.isTrue(overflowList(30, { className: "winner" }).find(".winner").exists());
});

it("uses custom tagName", () => {
Expand Down
10 changes: 2 additions & 8 deletions packages/core/test/panel-stack/panelStackTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,11 @@ describe("<PanelStack>", () => {
const backButtonWithoutTitle = panelStackWrapper.findClass(Classes.PANEL_STACK_HEADER_BACK);
assert.equal(backButtonWithoutTitle.text(), "chevron-left");

const newPanelButtonOnNotEmpty = panelStackWrapper
.find("#new-panel-button")
.hostNodes()
.at(1);
const newPanelButtonOnNotEmpty = panelStackWrapper.find("#new-panel-button").hostNodes().at(1);
assert.exists(newPanelButtonOnNotEmpty);
newPanelButtonOnNotEmpty.simulate("click");

const backButtonWithTitle = panelStackWrapper
.findClass(Classes.PANEL_STACK_HEADER_BACK)
.hostNodes()
.at(1);
const backButtonWithTitle = panelStackWrapper.findClass(Classes.PANEL_STACK_HEADER_BACK).hostNodes().at(1);
assert.equal(backButtonWithTitle.text(), "chevron-left");
});

Expand Down
28 changes: 6 additions & 22 deletions packages/core/test/popover/popoverTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,7 @@ describe("<Popover>", () => {
openOnTargetFocus?: boolean,
) {
wrapper = renderPopover({ interactionKind, openOnTargetFocus, usePortal: true });
const targetElement = wrapper
.findClass(Classes.POPOVER_TARGET)
.childAt(0)
.getDOMNode();
const targetElement = wrapper.findClass(Classes.POPOVER_TARGET).childAt(0).getDOMNode();

if (shouldTabIndexExist) {
assert.equal(targetElement.getAttribute("tabindex"), "0");
Expand All @@ -384,11 +381,7 @@ describe("<Popover>", () => {

describe("in controlled mode", () => {
it("state respects isOpen prop", () => {
renderPopover()
.assertIsOpen(false)
.setProps({ isOpen: true })
.update()
.assertIsOpen();
renderPopover().assertIsOpen(false).setProps({ isOpen: true }).update().assertIsOpen();
});

it("state does not update on user (click) interaction", () => {
Expand All @@ -401,9 +394,7 @@ describe("<Popover>", () => {
});

it("state does not update on user (key) interaction", () => {
renderPopover({ canEscapeKeyClose: true, isOpen: true })
.sendEscapeKey()
.assertIsOpen();
renderPopover({ canEscapeKeyClose: true, isOpen: true }).sendEscapeKey().assertIsOpen();
});

describe("disabled=true takes precedence over isOpen=true", () => {
Expand Down Expand Up @@ -514,10 +505,7 @@ describe("<Popover>", () => {
});

it("with defaultIsOpen=true, popover can still be closed", () => {
renderPopover({ defaultIsOpen: true })
.assertIsOpen()
.simulateTarget("click")
.assertIsOpen(false);
renderPopover({ defaultIsOpen: true }).assertIsOpen().simulateTarget("click").assertIsOpen(false);
});

it("CLICK_TARGET_ONLY works properly", () => {
Expand Down Expand Up @@ -641,16 +629,12 @@ describe("<Popover>", () => {
afterEach(() => root.detach());

it("shows tooltip on hover", () => {
root.find(`.${Classes.POPOVER_TARGET}`)
.last()
.simulate("mouseenter");
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}`)
.first()
.simulate("click");
root.find(`.${Classes.POPOVER_TARGET}`).first().simulate("click");
assert.lengthOf(root.find(`.${Classes.POPOVER}`), 1);
});
});
Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/slider/multiSliderTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ describe("<MultiSlider>", () => {
describe("handles", () => {
it("handle values are automatically sorted", () => {
const slider = renderSlider({ values: [5, 10, 0], onRelease });
slider
.find(Handle)
.first()
.simulate("mousedown", { clientX: 0 });
slider.find(Handle).first().simulate("mousedown", { clientX: 0 });
mouseUpHorizontal(0);
assert.equal(onRelease.callCount, 1);
assert.deepEqual(onRelease.firstCall.args[0], [0, 5, 10]);
Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/tabs/tabsTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ describe("<Tabs>", () => {
);
assert.equal(wrapper.state("selectedTabId"), TAB_IDS[0]);
// last Tab is inside nested
wrapper
.find(TAB)
.last()
.simulate("click");
wrapper.find(TAB).last().simulate("click");
assert.equal(wrapper.state("selectedTabId"), TAB_IDS[0]);
assert.isTrue(changeSpy.notCalled, "onChange invoked");
});
Expand Down
23 changes: 4 additions & 19 deletions packages/core/test/tag-input/tagInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ describe("<TagInput>", () => {
const onRemove = sinon.spy();
// requires full mount to support data attributes and parentElement
const wrapper = mount(<TagInput onRemove={onRemove} values={VALUES} />);
wrapper
.find("button")
.at(1)
.simulate("click");
wrapper.find("button").at(1).simulate("click");
assert.isTrue(onRemove.calledOnce);
assert.sameMembers(onRemove.args[0], [VALUES[1], 1]);
});
Expand Down Expand Up @@ -378,10 +375,7 @@ describe("<TagInput>", () => {
it("is invoked when a tag is removed by clicking", () => {
const onChange = sinon.stub();
const wrapper = mount(<TagInput onChange={onChange} values={VALUES} />);
wrapper
.find("button")
.at(1)
.simulate("click");
wrapper.find("button").at(1).simulate("click");
assert.isTrue(onChange.calledOnce);
assert.deepEqual(onChange.args[0][0], [VALUES[0], VALUES[2]]);
});
Expand Down Expand Up @@ -527,13 +521,7 @@ describe("<TagInput>", () => {
wrapper.childAt(0).hasClass(Classes.DISABLED),
`.${Classes.DISABLED} should be applied to tag-input`,
);
assert.isTrue(
wrapper
.find(`.${Classes.INPUT_GHOST}`)
.first()
.prop("disabled"),
"input should be disabled",
);
assert.isTrue(wrapper.find(`.${Classes.INPUT_GHOST}`).first().prop("disabled"), "input should be disabled");
wrapper.find(Tag).forEach(tag => {
assert.lengthOf(tag.find("." + Classes.TAG_REMOVE), 0, "tag should not have tag-remove button");
});
Expand Down Expand Up @@ -611,10 +599,7 @@ function runKeyPressTest(callbackName: "onKeyDown" | "onKeyUp", startIndex: numb
wrapper.setState({ activeIndex: startIndex });

const eventName = callbackName === "onKeyDown" ? "keydown" : "keyup";
wrapper
.find("input")
.simulate("focus")
.simulate(eventName, { which: Keys.ENTER });
wrapper.find("input").simulate("focus").simulate(eventName, { which: Keys.ENTER });

assert.strictEqual(callbackSpy.callCount, 1, "container callback call count");
assert.strictEqual(callbackSpy.firstCall.args[0].which, Keys.ENTER, "first arg (event)");
Expand Down
Loading

1 comment on commit 4873110

@blueprint-bot
Copy link

Choose a reason for hiding this comment

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

chore: upgrade to Prettier 2.0 (#4081)

Previews: documentation | landing | table

Please sign in to comment.