mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Fix lint for non @k8slens/core packages
- Update eslint config to be tighter in control Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
fcef072859
commit
6184c2f03b
29 files changed
+291
-292
No files matched your search
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
|
||||
import "./button.scss";
|
||||
import type { ButtonHTMLAttributes } from "react";
|
||||
import type { AnchorHTMLAttributes, ButtonHTMLAttributes } from "react";
|
||||
import React from "react";
|
||||
import { cssNames, StrictReactNode } from "@k8slens/utilities";
|
||||
import { withTooltip } from "@k8slens/tooltip";
|
||||
|
||||
export interface ButtonProps extends ButtonHTMLAttributes<any> {
|
||||
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
label?: StrictReactNode;
|
||||
waiting?: boolean;
|
||||
primary?: boolean;
|
||||
@@ -21,7 +21,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<any> {
|
||||
active?: boolean;
|
||||
big?: boolean;
|
||||
round?: boolean;
|
||||
href?: string; // render as hyperlink
|
||||
href?: string;
|
||||
target?: "_blank"; // in case of using @href
|
||||
children?: StrictReactNode;
|
||||
}
|
||||
@@ -46,19 +46,21 @@ export const Button = withTooltip((props: ButtonProps) => {
|
||||
light,
|
||||
});
|
||||
|
||||
// render as link
|
||||
if (props.href) {
|
||||
return (
|
||||
<a {...btnProps}>
|
||||
<a {...(btnProps as AnchorHTMLAttributes<HTMLAnchorElement>)}>
|
||||
{label}
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
// render as button
|
||||
return (
|
||||
<button type="button" {...btnProps} data-waiting={typeof waiting === "boolean" ? String(waiting) : undefined}>
|
||||
<button
|
||||
type="button"
|
||||
{...(btnProps as ButtonHTMLAttributes<HTMLButtonElement>)}
|
||||
data-waiting={typeof waiting === "boolean" ? String(waiting) : undefined}
|
||||
>
|
||||
{label}
|
||||
{children}
|
||||
</button>
|
||||
|
||||
@@ -323,7 +323,7 @@ describe("computeNextPosition technical tests", () => {
|
||||
it("doesn't throw if the preferredPosition is invalid", () => {
|
||||
expect(
|
||||
computeNextPosition({
|
||||
preferredPositions: "some-invalid-data" as any,
|
||||
preferredPositions: "some-invalid-data" as unknown as TooltipPosition,
|
||||
offset: 10,
|
||||
target: {
|
||||
getBoundingClientRect: () =>
|
||||
|
||||
@@ -11,7 +11,6 @@ import { observer } from "mobx-react";
|
||||
import type { IClassName, StrictReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { observable, makeObservable, action, runInAction } from "mobx";
|
||||
import autoBindReact from "auto-bind/react";
|
||||
import { computeNextPosition } from "./helpers";
|
||||
|
||||
export enum TooltipPosition {
|
||||
@@ -67,7 +66,6 @@ class DefaultedTooltip extends React.Component<TooltipProps & typeof defaultProp
|
||||
constructor(props: TooltipProps & typeof defaultProps) {
|
||||
super(props);
|
||||
makeObservable(this);
|
||||
autoBindReact(this);
|
||||
}
|
||||
|
||||
get targetElem(): HTMLElement | null {
|
||||
@@ -97,17 +95,15 @@ class DefaultedTooltip extends React.Component<TooltipProps & typeof defaultProp
|
||||
this.hoverTarget?.removeEventListener("mouseleave", this.onLeaveTarget);
|
||||
}
|
||||
|
||||
@action
|
||||
protected onEnterTarget() {
|
||||
onEnterTarget = action(() => {
|
||||
this.isVisible = true;
|
||||
requestAnimationFrame(action(() => (this.isContentVisible = true)));
|
||||
}
|
||||
});
|
||||
|
||||
@action
|
||||
protected onLeaveTarget() {
|
||||
onLeaveTarget = action(() => {
|
||||
this.isVisible = false;
|
||||
this.isContentVisible = false;
|
||||
}
|
||||
});
|
||||
|
||||
refreshPosition() {
|
||||
const { preferredPositions, offset } = this.props;
|
||||
|
||||
@@ -49,10 +49,12 @@ export function withTooltip<TargetProps>(
|
||||
);
|
||||
}
|
||||
|
||||
const ResolvedTarget = Target as React.FunctionComponent<TargetProps>;
|
||||
|
||||
return (
|
||||
<Target id={targetId} {...(targetProps as any)}>
|
||||
<ResolvedTarget id={targetId} {...(targetProps as TargetProps)}>
|
||||
{targetChildren}
|
||||
</Target>
|
||||
</ResolvedTarget>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user