cleanup Lens repo with tighter linting

Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
Sebastian Malton committed 2020-07-09 17:00:23 -04:00
1 parent e468105143
commit b1ff34879a
470 files changed
+8447 -7443

No files matched your search

+2 -2
View File
@@ -1,2 +1,2 @@
export * from './tooltip'
export * from './withTooltip'
export * from './tooltip';
export * from './withTooltip';
+16 -16
View File
@@ -1,9 +1,9 @@
import './tooltip.scss'
import './tooltip.scss';
import React from "react"
import React from "react";
import { observer } from "mobx-react";
import { observable } from "mobx";
import { createPortal } from "react-dom"
import { createPortal } from "react-dom";
import { autobind, cssNames } from "../../utils";
import { Animate } from "../animate";
@@ -42,12 +42,12 @@ export class Tooltip extends React.Component<TooltipProps> {
@observable isVisible = false;
componentDidMount() {
componentDidMount(): void {
const { htmlFor } = this.props;
this.anchor = htmlFor ? document.getElementById(htmlFor) : this.elem.parentElement;
if (this.anchor) {
if (window.getComputedStyle(this.anchor).position === "static") {
this.anchor.style.position = "relative"
this.anchor.style.position = "relative";
}
this.anchor.addEventListener("mouseenter", this.onMouseEnter);
this.anchor.addEventListener("mouseleave", this.onMouseLeave);
@@ -55,7 +55,7 @@ export class Tooltip extends React.Component<TooltipProps> {
}
}
componentWillUnmount() {
componentWillUnmount(): void {
if (this.anchor) {
this.anchor.removeEventListener("mouseenter", this.onMouseEnter);
this.anchor.removeEventListener("mouseleave", this.onMouseLeave);
@@ -64,18 +64,18 @@ export class Tooltip extends React.Component<TooltipProps> {
}
@autobind()
onMouseEnter(evt: MouseEvent) {
onMouseEnter(evt: MouseEvent): void {
this.isVisible = true;
this.onMouseMove(evt);
}
@autobind()
onMouseLeave(evt: MouseEvent) {
onMouseLeave(_evt: MouseEvent): void {
this.isVisible = false;
}
@autobind()
onMouseMove(evt: MouseEvent) {
onMouseMove(evt: MouseEvent): void {
if (!this.props.following) {
return;
}
@@ -90,7 +90,7 @@ export class Tooltip extends React.Component<TooltipProps> {
left: "auto",
right: (innerWidth - clientX + offsetX) + "px",
bottom: (innerHeight - clientY + offsetY) + "px",
}
};
Object.assign(this.elem.style, initialPos);
@@ -98,20 +98,20 @@ export class Tooltip extends React.Component<TooltipProps> {
const { left, top } = this.elem.getBoundingClientRect();
if (left < 0) {
this.elem.style.left = clientX + offsetX + "px";
this.elem.style.right = "auto"
this.elem.style.right = "auto";
}
if (top < 0) {
this.elem.style.top = clientY + offsetY + "px";
this.elem.style.bottom = "auto"
this.elem.style.bottom = "auto";
}
}
@autobind()
bindRef(elem: HTMLElement) {
bindRef(elem: HTMLElement): void {
this.elem = elem;
}
render() {
render(): JSX.Element {
const { isVisible } = this;
const { useAnimation, position, following, style, children } = this.props;
let { className } = this.props;
@@ -140,12 +140,12 @@ interface TooltipContentProps {
}
export class TooltipContent extends React.Component<TooltipContentProps> {
render() {
render(): JSX.Element {
const { className, children, ...modifiers } = this.props;
return (
<div className={cssNames("TooltipContent", className, modifiers)}>
{children}
</div>
)
);
}
}
@@ -1,10 +1,10 @@
// Tooltip decorator for simple composition with other components
import React, { HTMLAttributes, ReactNode } from "react"
import React, { HTMLAttributes, ReactNode } from "react";
import hoistNonReactStatics from "hoist-non-react-statics";
import { Tooltip, TooltipProps } from "./tooltip";
import { isReactNode } from "../../utils/isReactNode";
import uniqueId from "lodash/uniqueId"
import uniqueId from "lodash/uniqueId";
export interface TooltipDecoratorProps {
tooltip?: ReactNode | Omit<TooltipProps, "htmlFor">;
@@ -16,7 +16,7 @@ export function withTooltip<T extends React.ComponentType<any>>(Target: T): T {
protected tooltipId = uniqueId("tooltip_target_");
render() {
render(): JSX.Element {
const { tooltip, ...targetProps } = this.props;
if (tooltip) {
@@ -30,7 +30,7 @@ export function withTooltip<T extends React.ComponentType<any>>(Target: T): T {
targetProps.style = {
position: "relative",
...(targetProps.style || {})
}
};
}
targetProps.id = tooltipId;
targetProps.children = (
@@ -38,11 +38,11 @@ export function withTooltip<T extends React.ComponentType<any>>(Target: T): T {
{targetProps.children}
<Tooltip {...tooltipProps}/>
</>
)
);
}
return <Target {...targetProps as any}/>;
}
}
};
return hoistNonReactStatics(DecoratedComponent, Target) as any;
}