Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to prettier v2.6 #5271

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"http-server": "^0.12.3",
"lerna": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "~2.2.1",
"prettier": "~2.6.2",
"sinon": "^9.2.1",
"stylelint-config-palantir": "^6.0.1",
"stylelint-scss": "^4.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/utils/compareUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export function deepCompareKeys(objA: any, objB: any, keys?: Array<string | numb
* between two provided objects. Useful for debugging shouldComponentUpdate.
*/
export function getDeepUnequalKeyValues<T extends {}>(
objA: T = ({} as any) as T,
objB: T = ({} as any) as T,
objA: T = {} as any as T,
objB: T = {} as any as T,
keys?: Array<keyof T>,
) {
const filteredKeys = keys == null ? unionKeys(objA, objB) : keys;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/common/utils/domUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ function throttleImpl<T extends Function>(
isRunning = false;
});
};
return (func as any) as T;
return func as any as T;
}
9 changes: 2 additions & 7 deletions packages/core/src/components/dialog/multistepDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,8 @@ export class MultistepDialog extends AbstractPureComponent2<MultistepDialogProps
public state: IMultistepDialogState = this.getInitialIndexFromProps(this.props);

public render() {
const {
className,
navigationPosition,
showCloseButtonInFooter,
isCloseButtonShown,
...otherProps
} = this.props;
const { className, navigationPosition, showCloseButtonInFooter, isCloseButtonShown, ...otherProps } =
this.props;

// Only one close button should be displayed. If the footer close button
// is shown, we need to ensure the dialog close button is not displayed.
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/hotkeys/hotkeysDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export interface IHotkeysDialogProps extends DialogProps {
const DELAY_IN_MS = 10;

class HotkeysDialog {
public componentProps = ({
public componentProps = {
globalHotkeysGroup: "Global hotkeys",
} as any) as IHotkeysDialogProps;
} as any as IHotkeysDialogProps;

private container: HTMLElement | null = null;

Expand Down
10 changes: 2 additions & 8 deletions packages/core/src/components/overlay/overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,8 @@ export class Overlay extends AbstractPureComponent2<OverlayProps, IOverlayState>
};

private maybeRenderBackdrop() {
const {
backdropClassName,
backdropProps,
hasBackdrop,
isOpen,
transitionDuration,
transitionName,
} = this.props;
const { backdropClassName, backdropProps, hasBackdrop, isOpen, transitionDuration, transitionName } =
this.props;

if (hasBackdrop && isOpen) {
return (
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/components/panel-stack2/panelStack2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export const PanelStack2: PanelStack2Component = <T extends Panel<object>>(props
const [localStack, setLocalStack] = React.useState<T[]>(
props.initialPanel !== undefined ? [props.initialPanel] : [],
);
const stack = React.useMemo(() => (propsStack != null ? propsStack.slice().reverse() : localStack), [
localStack,
propsStack,
]);
const stack = React.useMemo(
() => (propsStack != null ? propsStack.slice().reverse() : localStack),
[localStack, propsStack],
);
const stackLength = React.useRef<number>(stack.length);
React.useEffect(() => {
if (stack.length !== stackLength.current) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export class Popover extends AbstractPureComponent2<IPopoverProps, IPopoverState
// lost focus (e.g. due to switching tabs).
return;
}
this.handleMouseEnter((e as unknown) as React.MouseEvent<HTMLElement>);
this.handleMouseEnter(e as unknown as React.MouseEvent<HTMLElement>);
}
this.props.targetProps?.onFocus?.(e);
};
Expand All @@ -490,7 +490,7 @@ export class Popover extends AbstractPureComponent2<IPopoverProps, IPopoverState
// it won't be set. So, we filter those out here and assume that a click handler somewhere else will
// close the popover if necessary.
if (e.relatedTarget != null && !this.isElementInPopover(e.relatedTarget as HTMLElement)) {
this.handleMouseLeave((e as unknown) as React.MouseEvent<HTMLElement>);
this.handleMouseLeave(e as unknown as React.MouseEvent<HTMLElement>);
}
}
this.lostFocusOnSamePage = e.relatedTarget != null;
Expand Down
14 changes: 7 additions & 7 deletions packages/core/test/hotkeys/hotkeysTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,28 +458,28 @@ describe("Hotkeys", () => {
const ignored = 16;
tests.push(makeComboTest("shift", { shiftKey: true, which: ignored } as any));
tests.push(
makeComboTest("ctrl + alt + shift", ({
makeComboTest("ctrl + alt + shift", {
altKey: true,
ctrlKey: true,
shiftKey: true,
which: ignored,
} as any) as KeyboardEvent),
} as any as KeyboardEvent),
);
tests.push(
makeComboTest("ctrl + meta", ({
makeComboTest("ctrl + meta", {
ctrlKey: true,
metaKey: true,
which: ignored,
} as any) as KeyboardEvent),
} as any as KeyboardEvent),
);
verifyCombos(tests);
});

it("adds shift to keys that imply it", () => {
const tests = [] as IComboTest[];
tests.push(makeComboTest("!", ({ shiftKey: true, which: 49 } as any) as KeyboardEvent));
tests.push(makeComboTest("@", ({ shiftKey: true, which: 50 } as any) as KeyboardEvent));
tests.push(makeComboTest("{", ({ shiftKey: true, which: 219 } as any) as KeyboardEvent));
tests.push(makeComboTest("!", { shiftKey: true, which: 49 } as any as KeyboardEvent));
tests.push(makeComboTest("@", { shiftKey: true, which: 50 } as any as KeyboardEvent));
tests.push(makeComboTest("{", { shiftKey: true, which: 219 } as any as KeyboardEvent));
// don't verify the strings because these will be converted to
// `shift + 1`, etc.
verifyCombos(tests, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class PanelStackExample extends React.PureComponent<IExampleProps, IPanel
private addToPanelStack = (newPanel: IPanel) => {
this.setState(state => ({
// HACKHACK: https://github.com/palantir/blueprint/issues/4272
currentPanelStack: [(newPanel as unknown) as IPanel<IPanelExampleProps>, ...state.currentPanelStack],
currentPanelStack: [newPanel as unknown as IPanel<IPanelExampleProps>, ...state.currentPanelStack],
}));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,49 @@ interface ITimezone {

const LOCAL_TIMEZONE_OFFSET_MSEC = new Date().getTimezoneOffset() * 60 * 1000;

const TIME_ZONES: ITimezone[] = ([
["-12:00", -12.0, "Etc/GMT+12"],
["-11:00", -11.0, "Pacific/Midway"],
["-10:00", -10.0, "Pacific/Honolulu"],
["-09:30", -9.5, "Pacific/Marquesas"],
["-09:00", -9.0, "America/Anchorage"],
["-08:00", -8.0, "America/Los_Angeles"],
["-07:00", -7.0, "America/Denver"],
["-06:00", -6.0, "America/Chicago"],
["-05:00", -5.0, "America/New_York"],
["-04:30", -4.5, "America/Caracas"],
["-04:00", -4.0, "America/Puerto_Rico"],
["-03:30", -3.5, "America/St_Johns"],
["-03:00", -3.0, "America/Buenos_Aires"],
["-02:00", -2.0, "America/Noronha"],
["-01:00", -1.0, "Atlantic/Azores"],
["+00:00", 0.0, "UTC"],
["+01:00", 1.0, "Europe/Berlin"],
["+02:00", 2.0, "Africa/Cairo"],
["+03:00", 3.0, "Asia/Baghdad"],
["+04:00", 4.0, "Asia/Dubai"],
["+04:30", 4.5, "Asia/Kabul"],
["+05:00", 5.0, "Asia/Karachi"],
["+05:30", 5.5, "Asia/Kolkata"],
["+05:45", 5.75, "Asia/Kathmandu"],
["+06:00", 6.0, "Asia/Dhaka"],
["+06:30", 6.5, "Asia/Rangoon"],
["+07:00", 7.0, "Asia/Bangkok"],
["+08:00", 8.0, "Asia/Hong_Kong"],
["+08:45", 8.0, "Australia/Eucla"],
["+09:00", 9.0, "Asia/Tokyo"],
["+09:30", 9.5, "Australia/Darwin"],
["+10:00", 10.0, "Australia/Sydney"],
["+10:30", 10.5, "Australia/Lord_Howe"],
["+11:00", 11.0, "Asia/Magadan"],
["+11:30", 11.5, "Pacific/Norfolk"],
["+12:00", 12.0, "Pacific/Auckland"],
["+12:45", 12.75, "Pacific/Chatham"],
["+13:00", 13.0, "Pacific/Tongatapu"],
["+14:00", 14.0, "Pacific/Kiritimati"],
] as Array<[string, number, string]>).map(arr => {
const TIME_ZONES: ITimezone[] = (
[
["-12:00", -12.0, "Etc/GMT+12"],
["-11:00", -11.0, "Pacific/Midway"],
["-10:00", -10.0, "Pacific/Honolulu"],
["-09:30", -9.5, "Pacific/Marquesas"],
["-09:00", -9.0, "America/Anchorage"],
["-08:00", -8.0, "America/Los_Angeles"],
["-07:00", -7.0, "America/Denver"],
["-06:00", -6.0, "America/Chicago"],
["-05:00", -5.0, "America/New_York"],
["-04:30", -4.5, "America/Caracas"],
["-04:00", -4.0, "America/Puerto_Rico"],
["-03:30", -3.5, "America/St_Johns"],
["-03:00", -3.0, "America/Buenos_Aires"],
["-02:00", -2.0, "America/Noronha"],
["-01:00", -1.0, "Atlantic/Azores"],
["+00:00", 0.0, "UTC"],
["+01:00", 1.0, "Europe/Berlin"],
["+02:00", 2.0, "Africa/Cairo"],
["+03:00", 3.0, "Asia/Baghdad"],
["+04:00", 4.0, "Asia/Dubai"],
["+04:30", 4.5, "Asia/Kabul"],
["+05:00", 5.0, "Asia/Karachi"],
["+05:30", 5.5, "Asia/Kolkata"],
["+05:45", 5.75, "Asia/Kathmandu"],
["+06:00", 6.0, "Asia/Dhaka"],
["+06:30", 6.5, "Asia/Rangoon"],
["+07:00", 7.0, "Asia/Bangkok"],
["+08:00", 8.0, "Asia/Hong_Kong"],
["+08:45", 8.0, "Australia/Eucla"],
["+09:00", 9.0, "Asia/Tokyo"],
["+09:30", 9.5, "Australia/Darwin"],
["+10:00", 10.0, "Australia/Sydney"],
["+10:30", 10.5, "Australia/Lord_Howe"],
["+11:00", 11.0, "Asia/Magadan"],
["+11:30", 11.5, "Pacific/Norfolk"],
["+12:00", 12.0, "Pacific/Auckland"],
["+12:45", 12.75, "Pacific/Chatham"],
["+13:00", 13.0, "Pacific/Tongatapu"],
["+14:00", 14.0, "Pacific/Kiritimati"],
] as Array<[string, number, string]>
).map(arr => {
return {
name: arr[2],
offsetMsec: (arr[1] as number) * 60 * 60 * 1000 + LOCAL_TIMEZONE_OFFSET_MSEC,
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-theme/src/components/baseExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function handleStringChange(handler: (value: string) => void) {

/** Event handler that exposes the target element's value as an inferred generic type. */
export function handleValueChange<T>(handler: (value: T) => void) {
return (event: React.FormEvent<HTMLElement>) => handler(((event.target as HTMLInputElement).value as unknown) as T);
return (event: React.FormEvent<HTMLElement>) => handler((event.target as HTMLInputElement).value as unknown as T);
}

/** Event handler that exposes the target element's value as a number. */
Expand Down
62 changes: 30 additions & 32 deletions packages/eslint-plugin/src/rules/utils/addImportToFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,39 @@ import { AST_NODE_TYPES, TSESLint, TSESTree } from "@typescript-eslint/utils";
* Return a function which when provided with a fixer will produce a RuleFix to add the
* specified imports from the specified packageName at the top of the file (in alphabetical order)
*/
export const addImportToFile = (
program: TSESTree.Program,
imports: string[],
packageName: string,
): TSESLint.ReportFixFunction => fixer => {
const fileImports = program.body.filter(
node => node.type === AST_NODE_TYPES.ImportDeclaration,
) as TSESTree.ImportDeclaration[];
const nodeToModify = fileImports.find(node => node.source.value === packageName);
export const addImportToFile =
(program: TSESTree.Program, imports: string[], packageName: string): TSESLint.ReportFixFunction =>
fixer => {
const fileImports = program.body.filter(
node => node.type === AST_NODE_TYPES.ImportDeclaration,
) as TSESTree.ImportDeclaration[];
const nodeToModify = fileImports.find(node => node.source.value === packageName);

if (
nodeToModify !== undefined &&
nodeToModify.specifiers.every(node => node.type === AST_NODE_TYPES.ImportSpecifier)
) {
// Module imports
const existingImports = nodeToModify.specifiers.map(node => node.local.name);
const newImports = Array.from(new Set(existingImports.concat(imports))).sort();
const importString = `import { ${newImports.join(", ")} } from "${nodeToModify.source.value}";`;
return fixer.replaceText(nodeToModify, importString);
} else {
// Default imports
if (
nodeToModify !== undefined &&
nodeToModify.specifiers.every(node => node.type === AST_NODE_TYPES.ImportSpecifier)
) {
// Module imports
const existingImports = nodeToModify.specifiers.map(node => node.local.name);
const newImports = Array.from(new Set(existingImports.concat(imports))).sort();
const importString = `import { ${newImports.join(", ")} } from "${nodeToModify.source.value}";`;
return fixer.replaceText(nodeToModify, importString);
} else {
// Default imports

// Find the node thats alphabetically after the new one, so we can insert before it
const followingImportNode = fileImports.find(imp => {
return imp.source.value != null && compare(imp.source.value.toString(), packageName) === 1;
});
// Find the node thats alphabetically after the new one, so we can insert before it
const followingImportNode = fileImports.find(imp => {
return imp.source.value != null && compare(imp.source.value.toString(), packageName) === 1;
});

const onlyImport = fileImports.length === 0;
return fixer.insertTextBefore(
followingImportNode !== undefined ? followingImportNode : program.body[0],
// If we are adding the first import, add a 2nd new line afterwards
`import { ${imports.sort().join(", ")} } from "${packageName}";\n${onlyImport ? "\n" : ""}`,
);
}
};
const onlyImport = fileImports.length === 0;
return fixer.insertTextBefore(
followingImportNode !== undefined ? followingImportNode : program.body[0],
// If we are adding the first import, add a 2nd new line afterwards
`import { ${imports.sort().join(", ")} } from "${packageName}";\n${onlyImport ? "\n" : ""}`,
);
}
};

function isLow(value: string) {
return value[0] === "." || value[0] === "/";
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/src/type-utils/camel-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Only to be used by `CamelCaseStringArray<>`.
*/
type InnerCamelCaseStringArray<Parts extends any[], PreviousPart> = Parts extends [
`${infer FirstPart}`,
...infer RemainingParts
...infer RemainingParts,
]
? FirstPart extends undefined
? ""
Expand Down
6 changes: 3 additions & 3 deletions packages/icons/src/type-utils/delimiter-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type SplitIncludingDelimiters<Source extends string, Delimiter extends st
? [
...SplitIncludingDelimiters<FirstPart, Delimiter>,
UsedDelimiter,
...SplitIncludingDelimiters<SecondPart, Delimiter>
...SplitIncludingDelimiters<SecondPart, Delimiter>,
]
: never
: never
Expand All @@ -30,7 +30,7 @@ type StringPartToDelimiterCase<
StringPart extends string,
UsedWordSeparators extends string,
UsedUpperCaseCharacters extends string,
Delimiter extends string
Delimiter extends string,
> = StringPart extends UsedWordSeparators
? Delimiter
: StringPart extends UsedUpperCaseCharacters
Expand All @@ -48,7 +48,7 @@ type StringArrayToDelimiterCase<
Parts extends any[],
UsedWordSeparators extends string,
UsedUpperCaseCharacters extends string,
Delimiter extends string
Delimiter extends string,
> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts]
? `${StringPartToDelimiterCase<
FirstPart,
Expand Down
2 changes: 1 addition & 1 deletion packages/node-build-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"postcss-cli": "^9.1.0",
"postcss-discard-comments": "^5.1.1",
"postcss-scss": "^4.0.3",
"prettier": "~2.2.1",
"prettier": "~2.6.2",
"sass": "^1.49.10",
"strip-css-comments": "^4.1.0",
"stylelint": "^14.6.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/popover2/src/popover2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class Popover2<T> extends AbstractPureComponent2<Popover2Props<T>, IPopov
[CoreClasses.ACTIVE]: !isControlled && isOpen && !isHoverInteractionKind,
}),
ref,
...((targetEventHandlers as unknown) as T),
...(targetEventHandlers as unknown as T),
};

let target: JSX.Element | undefined;
Expand Down Expand Up @@ -526,7 +526,7 @@ export class Popover2<T> extends AbstractPureComponent2<Popover2Props<T>, IPopov
// lost focus (e.g. due to switching tabs).
return;
}
this.handleMouseEnter((e as unknown) as React.MouseEvent<HTMLElement>);
this.handleMouseEnter(e as unknown as React.MouseEvent<HTMLElement>);
}
};

Expand All @@ -539,10 +539,10 @@ export class Popover2<T> extends AbstractPureComponent2<Popover2Props<T>, IPopov
e.relatedTarget !== this.popoverElement &&
!this.isElementInPopover(e.relatedTarget as HTMLElement)
) {
this.handleMouseLeave((e as unknown) as React.MouseEvent<HTMLElement>);
this.handleMouseLeave(e as unknown as React.MouseEvent<HTMLElement>);
}
} else {
this.handleMouseLeave((e as unknown) as React.MouseEvent<HTMLElement>);
this.handleMouseLeave(e as unknown as React.MouseEvent<HTMLElement>);
}
}
this.lostFocusOnSamePage = e.relatedTarget != null;
Expand Down
Loading