Skip to content

Commit

Permalink
[v5] break: remove various deprecated APIs, clean up ESLint comments (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored May 4, 2023
1 parent 46f2eb9 commit 8740c47
Show file tree
Hide file tree
Showing 34 changed files with 50 additions and 165 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ module.exports = {
"@typescript-eslint/no-unused-expressions": "off",
// HACKHACK: test dependencies are only declared at root but used in all packages.
"import/no-extraneous-dependencies": "off",
// HACKHACK: added to reduce diff in https://github.com/palantir/blueprint/pull/4644,
// can be removed in v4.0
"deprecation/deprecation": "off",
},
},
{
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/common/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ export const MULTISTEP_DIALOG = `${NS}-multistep-dialog`;
export const MULTISTEP_DIALOG_PANELS = `${MULTISTEP_DIALOG}-panels`;
export const MULTISTEP_DIALOG_LEFT_PANEL = `${MULTISTEP_DIALOG}-left-panel`;
export const MULTISTEP_DIALOG_RIGHT_PANEL = `${MULTISTEP_DIALOG}-right-panel`;
/** @deprecated use `Classes.DIALOG_FOOTER` instead */
export const MULTISTEP_DIALOG_FOOTER = `${MULTISTEP_DIALOG}-footer`;
export const MULTISTEP_DIALOG_NAV_TOP = `${MULTISTEP_DIALOG}-nav-top`;
export const MULTISTEP_DIALOG_NAV_RIGHT = `${MULTISTEP_DIALOG}-nav-right`;

Expand Down
23 changes: 0 additions & 23 deletions packages/core/src/common/constructor.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export { AbstractComponent } from "./abstractComponent";
export { AbstractPureComponent } from "./abstractPureComponent";
export { Alignment } from "./alignment";
export { Boundary } from "./boundary";
// eslint-disable-next-line deprecation/deprecation
export { Constructor } from "./constructor";
export { Elevation } from "./elevation";
export { Intent } from "./intent";
// eslint-disable-next-line deprecation/deprecation
Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/common/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ export function setRef<T>(refTarget: React.Ref<T> | undefined, ref: T | null): v
}
}

/** @deprecated use mergeRefs() instead */
export function combineRefs<T>(ref1: React.RefCallback<T>, ref2: React.RefCallback<T>) {
return mergeRefs(ref1, ref2);
}

/**
* Utility for merging refs into one singular callback ref.
* If using in a functional component, would recomend using `useMemo` to preserve function identity.
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/common/utils/compareUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export interface KeyDenylist<T> {
exclude: Array<keyof T>;
}

/* eslint-enable deprecation/deprecation */

/**
* Returns true if the arrays are equal. Elements will be shallowly compared by
* default, or they will be compared using the custom `compare` function if one
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/components/dialog/dialogStepButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ import { Tooltip, TooltipProps } from "../tooltip/tooltip";

export type DialogStepButtonProps = Partial<ButtonSharedPropsAndAttributes> & {
/** If defined, the button will be wrapped with a tooltip with the specified content. */
// eslint-disable-next-line deprecation/deprecation
tooltipContent?: TooltipProps["content"];
};

export function DialogStepButton({ tooltipContent, ...props }: DialogStepButtonProps) {
const button = <AnchorButton {...props} />;

if (tooltipContent !== undefined) {
// eslint-disable-next-line deprecation/deprecation
return <Tooltip content={tooltipContent}>{button}</Tooltip>;
} else {
return button;
Expand Down
7 changes: 1 addition & 6 deletions packages/core/src/components/dialog/multistepDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,7 @@ export class MultistepDialog extends AbstractPureComponent<MultistepDialogProps,
const maybeCloseButton = !showCloseButtonInFooter ? undefined : (
<DialogStepButton text="Close" onClick={onClose} {...closeButtonProps} />
);
return (
// eslint-disable-next-line deprecation/deprecation -- need to keep adding this class for backcompat, can be removed in next major version
<DialogFooter className={Classes.MULTISTEP_DIALOG_FOOTER} actions={this.renderButtons()}>
{maybeCloseButton}
</DialogFooter>
);
return <DialogFooter actions={this.renderButtons()}>{maybeCloseButton}</DialogFooter>;
}

private renderButtons() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/menu/menuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const MenuItem: React.FC<MenuItemProps> = React.forwardRef<HTMLLIElement,
{
// for menuitems, onClick when enter key pressed doesn't take effect like it does for a button-- fix this
onKeyDown: clickElementOnKeyPress(["Enter", " "]),
// if hasSubmenu, must apply correct role and tabIndex to the outer Popover2 target <span> instead of this target element
// if hasSubmenu, must apply correct role and tabIndex to the outer popover target <span> instead of this target element
role: hasSubmenu ? "none" : targetRole,
tabIndex: hasSubmenu ? -1 : 0,
...removeNonHTMLProps(htmlProps),
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/components/panel-stack/panelProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
* limitations under the License.
*/

import * as React from "react";
/**
* @fileoverview This component is DEPRECATED, and the code is frozen.
* All changes & bugfixes should be made to PanelStack2 instead.
*/

/* eslint-disable deprecation/deprecation */

import * as React from "react";

/**
* An object describing a panel in a `PanelStack`.
*
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/components/panel-stack/panelView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
* limitations under the License.
*/

/**
* @fileoverview This component is DEPRECATED, and the code is frozen.
* All changes & bugfixes should be made to PanelStack2 instead.
*/

/* eslint-disable deprecation/deprecation */

import * as React from "react";

import { AbstractPureComponent, Classes } from "../../common";
import { Button } from "../button/buttons";
import { Text } from "../text/text";
import { IPanel } from "./panelProps";

/* eslint-disable deprecation/deprecation */

export interface IPanelViewProps {
/**
* Callback invoked when the user presses the back button or a panel invokes
Expand Down
7 changes: 2 additions & 5 deletions packages/core/src/legacy/contextMenuLegacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* All changes & bugfixes should be made to ContextMenu2 instead.
*/

/* eslint-disable deprecation/deprecation */

import classNames from "classnames";
import * as React from "react";
import * as ReactDOM from "react-dom";
Expand Down Expand Up @@ -65,7 +67,6 @@ class ContextMenuLegacy extends AbstractPureComponent<ContextMenuLegacyProps, Co

// wrap the popover in a positioned div to make sure it is properly
// offset on the screen.
/* eslint-disable deprecation/deprecation */
return (
<div className={Classes.CONTEXT_MENU} style={this.state.offset}>
<Popover
Expand All @@ -87,7 +88,6 @@ class ContextMenuLegacy extends AbstractPureComponent<ContextMenuLegacyProps, Co
</Popover>
</div>
);
/* eslint-enable deprecation/deprecation */
}

public show(menu: JSX.Element, offset: Offset, onClose?: () => void, isDarkTheme = false) {
Expand Down Expand Up @@ -127,7 +127,6 @@ class ContextMenuLegacy extends AbstractPureComponent<ContextMenuLegacyProps, Co
}

let contextMenuElement: HTMLElement | undefined;
// eslint-disable-next-line deprecation/deprecation
let contextMenu: ContextMenuLegacy | undefined;

/**
Expand All @@ -142,12 +141,10 @@ export function show(menu: JSX.Element, offset: Offset, onClose?: () => void, is
contextMenuElement = document.createElement("div");
contextMenuElement.classList.add(Classes.CONTEXT_MENU);
document.body.appendChild(contextMenuElement);
/* eslint-disable deprecation/deprecation */
contextMenu = ReactDOM.render<ContextMenuLegacyProps>(
<ContextMenuLegacy onClosed={remove} />,
contextMenuElement,
) as ContextMenuLegacy;
/* eslint-enable deprecation/deprecation */
}

contextMenu!.show(menu, offset, onClose, isDarkTheme);
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/legacy/contextMenuTargetLegacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
* limitations under the License.
*/

/**
* @fileoverview This component is DEPRECATED, and the code is frozen.
* All changes & bugfixes should be made to ContextMenu2 instead.
*/

/* eslint-disable deprecation/deprecation */

import * as React from "react";
import * as ReactDOM from "react-dom";

Expand All @@ -30,8 +37,6 @@ export interface ContextMenuTargetLegacyComponent extends React.Component {
onContextMenuClose?: () => void;
}

/* eslint-disable deprecation/deprecation */

/**
* ContextMenuTarget decorator.
*
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/collapse/collapseTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe("<Collapse>", () => {
});

it("supports custom Component", () => {
// eslint-disable-next-line deprecation/deprecation
assert.isTrue(shallow(<Collapse component={MenuItem} />).is(MenuItem));
});

Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/menu/menuTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ describe("<MenuDivider>", () => {
});
});

/* eslint-disable deprecation/deprecation */

describe("<Menu>", () => {
it("React renders Menu with children", () => {
const menu = shallow(
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/multistep-dialog/multistepDialogTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ describe("<MultistepDialog>", () => {
Classes.MULTISTEP_DIALOG_PANELS,
Classes.MULTISTEP_DIALOG_LEFT_PANEL,
Classes.MULTISTEP_DIALOG_RIGHT_PANEL,
// eslint-disable-next-line deprecation/deprecation -- need to keep adding this class for backcompat, can be removed in next major version
Classes.MULTISTEP_DIALOG_FOOTER,
Classes.DIALOG_STEP,
Classes.DIALOG_STEP_CONTAINER,
Classes.DIALOG_STEP_ICON,
Expand Down
9 changes: 7 additions & 2 deletions packages/core/test/panel-stack/panelStackTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
* limitations under the License.
*/

/**
* @fileoverview This component is DEPRECATED, and the code is frozen.
* All changes & bugfixes should be made to PanelStack2 instead.
*/

/* eslint-disable deprecation/deprecation */

import { assert } from "chai";
import { mount, ReactWrapper } from "enzyme";
import * as React from "react";
import { spy } from "sinon";

import { Classes, IPanel, IPanelProps, PanelStack, PanelStackProps } from "../../src";

/* eslint-disable deprecation/deprecation */

export class TestPanel extends React.Component<IPanelProps> {
public render() {
return (
Expand Down
11 changes: 2 additions & 9 deletions packages/datetime/src/common/timezoneDisplayFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ export const TimezoneDisplayFormat = {
*/
LONG_NAME: "long-name" as "long-name",

/**
* @deprecated use {@link TimezoneDisplayFormat.CODE} instead
*/
// eslint-disable-next-line deprecation/deprecation
NAME: "name" as "name",

/**
* Offset format: "-10:00", "-5:00", etc.
*/
Expand All @@ -68,9 +62,6 @@ export function formatTimezone(
switch (displayFormat) {
case TimezoneDisplayFormat.ABBREVIATION:
return timezone.shortName;
// eslint-disable-next-line deprecation/deprecation
case TimezoneDisplayFormat.NAME:
return timezone.ianaCode;
case TimezoneDisplayFormat.OFFSET:
return timezone.offset;
case TimezoneDisplayFormat.CODE:
Expand All @@ -83,5 +74,7 @@ export function formatTimezone(
return /[-\+]/.test(shortName) || shortName === timezone.label
? `${timezone.label} ${timezone.offset}`
: `${timezone.label} (${timezone.shortName}) ${timezone.offset}`;
default:
return undefined;
}
}
2 changes: 0 additions & 2 deletions packages/datetime/src/components/shortcuts/shortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ export class Shortcuts extends React.PureComponent<ShortcutsProps> {
: this.props.shortcuts;

const shortcutElements = shortcuts.map((shortcut, index) => (
// ok to use this here because it doesn't have a submenu
// eslint-disable-next-line deprecation/deprecation, @blueprintjs/no-deprecated-components
<MenuItem
active={this.props.selectedShortcutIndex === index}
disabled={!this.isShortcutInRange(shortcut.dateRange)}
Expand Down
4 changes: 0 additions & 4 deletions packages/demo-app/src/examples/MenuExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

/* eslint-disable deprecation/deprecation */

import * as React from "react";

import { Classes, Intent, Menu, MenuDivider, MenuItem } from "@blueprintjs/core";
Expand All @@ -30,7 +28,6 @@ export class MenuExample extends React.PureComponent {
<Menu className={Classes.ELEVATION_1}>
{Object.values(Intent).map(intent => (
<div key={`${intent}-menu-item`}>
{/* eslint-disable-next-line @blueprintjs/no-deprecated-components */}
<MenuItem intent={intent} icon="applications" text="Item" label="⌘M" />
{intent !== "danger" && <MenuDivider />}
</div>
Expand All @@ -41,7 +38,6 @@ export class MenuExample extends React.PureComponent {
<Menu className={Classes.ELEVATION_1}>
{Object.values(Intent).map(intent => (
<div key={`${intent}-menu-item`}>
{/* eslint-disable-next-line @blueprintjs/no-deprecated-components */}
<MenuItem disabled={true} intent={intent} icon="applications" text="Item" label="⌘M" />
{intent !== "danger" && <MenuDivider />}
</div>
Expand Down
7 changes: 1 addition & 6 deletions packages/docs-theme/src/components/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ import * as React from "react";

import { Props } from "@blueprintjs/core";

/** @deprecated use ExampleProps */
// eslint-disable-next-line @typescript-eslint/ban-types
export type IExampleProps<T = {}> = ExampleProps<T>;

// eslint-disable-next-line @typescript-eslint/ban-types
export interface ExampleProps<T = {}> extends Props {
export interface ExampleProps<T = object> extends Props {
/**
* Identifier of this example.
* This will appear as the `data-example-id` attribute on the DOM element.
Expand Down
3 changes: 0 additions & 3 deletions packages/select/src/common/listItemsProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ export type ItemsEqualComparator<T> = (itemA: T, itemB: T) => boolean;
*/
export type ItemsEqualProp<T> = ItemsEqualComparator<T> | keyof T;

/** @deprecated use ListItemsProps */
export type IListItemsProps<T> = ListItemsProps<T>;

/** Reusable generic props for a component that operates on a filterable, selectable list of `items`. */
export interface ListItemsProps<T> extends Props {
/**
Expand Down
3 changes: 0 additions & 3 deletions packages/select/src/common/listItemsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

/* eslint-disable no-underscore-dangle */

/** @deprecated use CreateNewItem */
export type ICreateNewItem = CreateNewItem;

/**
* The reserved type of the "Create Item" option in item lists. This is intended
* not to conflict with any custom item type `T` that might be used in item
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/common/selectPopoverProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface SelectPopoverProps {
* Optional ref for the Popover component instance.
* This is sometimes useful to reposition the popover.
*
* Note that this is defined as a specific kind of Popover2 which should be compatible with
* Note that this is defined as a specific kind of Popover instance which should be compatible with
* most use cases, since it uses the default target props interface.
*/
popoverRef?: React.RefObject<Popover<DefaultPopoverTargetHTMLProps>>;
Expand Down
1 change: 0 additions & 1 deletion packages/select/src/components/suggest/suggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ export class Suggest<T> extends AbstractPureComponent<SuggestProps<T>, SuggestSt
if (this.state.isOpen === false && prevState.isOpen === true) {
// just closed, likely by keyboard interaction
// wait until the transition ends so there isn't a flash of content in the popover
/* eslint-disable-next-line deprecation/deprecation */
const timeout = this.props.popoverProps?.transitionDuration ?? Popover.defaultProps.transitionDuration;
setTimeout(() => this.maybeResetActiveItemToSelectedItem(), timeout);
}
Expand Down
1 change: 0 additions & 1 deletion packages/select/test/suggestTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ describe("Suggest", () => {
const modifiers = {}; // our own instance
const wrapper = suggest({ popoverProps: getPopoverProps(false, modifiers) });
wrapper.setProps({ popoverProps: getPopoverProps(true, modifiers) }).update();
/* eslint-disable-next-line deprecation/deprecation */
assert.strictEqual(wrapper.find(Popover).prop("modifiers"), modifiers);
assert.isTrue(onOpening.calledOnce);
});
Expand Down
Loading

1 comment on commit 8740c47

@adidahiya
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[v5] break: remove various deprecated APIs, clean up ESLint comments (#6125)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.