Enforce semicolons in eslint

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
Panu Horsmalahti committed 2020-11-19 16:35:04 +02:00
1 parent 0f3f5611ba
commit 1477bb8274
531 files changed
+3979 -3975

No files matched your search

@@ -1,7 +1,7 @@
import "./create-resource.scss";
import React from "react";
import jsYaml from "js-yaml"
import jsYaml from "js-yaml";
import { observable } from "mobx";
import { observer } from "mobx-react";
import { Plural, t, Trans } from "@lingui/macro";
@@ -41,14 +41,14 @@ export class CreateResource extends React.Component<Props> {
if (this.error) return;
if (!this.data.trim()) return; // do not save when field is empty
const resources = jsYaml.safeLoadAll(this.data)
.filter(v => !!v) // skip empty documents if "---" pasted at the beginning or end
.filter(v => !!v); // skip empty documents if "---" pasted at the beginning or end
const createdResources: string[] = [];
const errors: string[] = [];
await Promise.all(
resources.map(data => {
return resourceApplierApi.update(data)
.then(item => createdResources.push(item.getName()))
.catch((err: JsonApiErrorParsed) => errors.push(err.toString()))
.catch((err: JsonApiErrorParsed) => errors.push(err.toString()));
})
);
if (errors.length) {
@@ -60,9 +60,9 @@ export class CreateResource extends React.Component<Props> {
<Plural value={createdResources.length} one="Resource" other="Resources"/>{" "}
<Trans><b>{createdResources.join(", ")}</b> successfully created</Trans>
</p>
)
Notifications.ok(successMessage)
return successMessage
);
Notifications.ok(successMessage);
return successMessage;
}
render() {
@@ -83,6 +83,6 @@ export class CreateResource extends React.Component<Props> {
onChange={onChange}
/>
</div>
)
);
}
}
@@ -28,16 +28,16 @@ export class DockTabStore<T = any> {
if (!currentTabs.includes(tabId)) {
this.clearData(tabId);
}
})
});
});
}
protected serializeData() {
const { storageSerializer } = this.options;
return Array.from(this.data).map(([tabId, tabData]) => {
if (storageSerializer) return [tabId, storageSerializer(tabData)]
if (storageSerializer) return [tabId, storageSerializer(tabData)];
return [tabId, tabData];
})
});
}
getData(tabId: TabId) {
+4 -4
View File
@@ -1,6 +1,6 @@
import "./dock-tab.scss"
import "./dock-tab.scss";
import React from "react"
import React from "react";
import { observer } from "mobx-react";
import { t } from "@lingui/macro";
import { autobind, cssNames, prevDefault } from "../../utils";
@@ -39,13 +39,13 @@ export class DockTab extends React.Component<DockTabProps> {
/>
)}
</div>
)
);
return (
<Tab
{...tabProps}
className={cssNames("DockTab", className, { pinned })}
label={label}
/>
)
);
}
}
+8 -8
View File
@@ -1,7 +1,7 @@
import MD5 from "crypto-js/md5";
import { action, computed, IReactionOptions, observable, reaction } from "mobx";
import { autobind, createStorage } from "../../utils";
import throttle from "lodash/throttle"
import throttle from "lodash/throttle";
export type TabId = string;
@@ -46,12 +46,12 @@ export class DockStore {
}
get maxHeight() {
const mainLayoutHeader = 40
const mainLayoutTabs = 33
const mainLayoutMargin = 16
const dockTabs = 33
const preferedMax = window.innerHeight - mainLayoutHeader - mainLayoutTabs - mainLayoutMargin - dockTabs
return Math.max(preferedMax, this.minHeight) // don't let max < min
const mainLayoutHeader = 40;
const mainLayoutTabs = 33;
const mainLayoutMargin = 16;
const dockTabs = 33;
const preferedMax = window.innerHeight - mainLayoutHeader - mainLayoutTabs - mainLayoutMargin - dockTabs;
return Math.max(preferedMax, this.minHeight); // don't let max < min
}
constructor() {
@@ -138,7 +138,7 @@ export class DockStore {
const tab: IDockTab = { id: tabId, ...anonTab };
if (addNumber) {
const tabNumber = this.getNewTabNumber(tab.kind);
if (tabNumber > 1) tab.title += ` (${tabNumber})`
if (tabNumber > 1) tab.title += ` (${tabNumber})`;
}
this.tabs.push(tab);
this.selectTab(tab.id);
+6 -6
View File
@@ -53,16 +53,16 @@ export class Dock extends React.Component<Props> {
@autobind()
renderTab(tab: IDockTab) {
if (isTerminalTab(tab)) {
return <TerminalTab value={tab} />
return <TerminalTab value={tab} />;
}
if (isCreateResourceTab(tab) || isEditResourceTab(tab)) {
return <DockTab value={tab} icon="edit" />
return <DockTab value={tab} icon="edit" />;
}
if (isInstallChartTab(tab) || isUpgradeChartTab(tab)) {
return <DockTab value={tab} icon={<Icon svg="install" />} />
return <DockTab value={tab} icon={<Icon svg="install" />} />;
}
if (isPodLogsTab(tab)) {
return <DockTab value={tab} icon="subject" />
return <DockTab value={tab} icon="subject" />;
}
}
@@ -78,7 +78,7 @@ export class Dock extends React.Component<Props> {
{isTerminalTab(tab) && <TerminalWindow tab={tab} />}
{isPodLogsTab(tab) && <PodLogs tab={tab} />}
</div>
)
);
}
render() {
@@ -139,6 +139,6 @@ export class Dock extends React.Component<Props> {
</div>
{this.renderTabContent()}
</div>
)
);
}
}
@@ -42,7 +42,7 @@ export class EditResourceStore extends DockTabStore<KubeEditResource> {
}, {
delay: 100 // make sure all stores initialized
}));
})
});
});
}
@@ -58,7 +58,7 @@ export class EditResourceStore extends DockTabStore<KubeEditResource> {
Array.from(this.watchers).forEach(([tabId, dispose]) => {
this.watchers.delete(tabId);
dispose();
})
});
}
}
@@ -3,7 +3,7 @@ import "./edit-resource.scss";
import React from "react";
import { autorun, observable } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react";
import jsYaml from "js-yaml"
import jsYaml from "js-yaml";
import { t, Trans } from "@lingui/macro";
import { IDockTab } from "./dock.store";
import { cssNames } from "../../utils";
@@ -110,6 +110,6 @@ export class EditResource extends React.Component<Props> {
onChange={onChange}
/>
</div>
)
);
}
}
@@ -1,5 +1,5 @@
import React from "react";
import jsYaml from "js-yaml"
import jsYaml from "js-yaml";
import { observable } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react";
import { cssNames } from "../../utils";
@@ -30,7 +30,7 @@ export class EditorPanel extends React.Component<Props> {
disposeOnUnmount(this, [
dockStore.onTabChange(this.onTabChange, { delay: 250 }),
dockStore.onResize(this.onResize, { delay: 250 }),
])
]);
}
validate(value: string) {
@@ -77,6 +77,6 @@ export class EditorPanel extends React.Component<Props> {
onCursorPosChange={this.onCursorPosChange}
ref={e => this.editor = e}
/>
)
);
}
}
+1 -1
View File
@@ -1 +1 @@
export * from "./dock"
export * from "./dock";
+3 -3
View File
@@ -46,9 +46,9 @@ export class InfoPanel extends Component<Props> {
componentDidMount() {
disposeOnUnmount(this, [
reaction(() => this.props.tabId, () => {
this.waiting = false
this.waiting = false;
})
])
]);
}
@computed get errorInfo() {
@@ -64,7 +64,7 @@ export class InfoPanel extends Component<Props> {
} catch (error) {
if (showNotifications) Notifications.error(error.toString());
} finally {
this.waiting = false
this.waiting = false;
}
}
@@ -30,24 +30,24 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
const { selectedTab, isOpen } = dockStore;
if (isInstallChartTab(selectedTab) && isOpen) {
this.loadData()
.catch(err => Notifications.error(String(err)))
.catch(err => Notifications.error(String(err)));
}
}, { delay: 250 })
}, { delay: 250 });
}
@action
async loadData(tabId = dockStore.selectedTabId) {
const promises = []
const promises = [];
if (!this.getData(tabId).values) {
promises.push(this.loadValues(tabId))
promises.push(this.loadValues(tabId));
}
if (!this.versions.getData(tabId)) {
promises.push(this.loadVersions(tabId))
promises.push(this.loadVersions(tabId));
}
await Promise.all(promises)
await Promise.all(promises);
}
@action
@@ -61,15 +61,15 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
@action
async loadValues(tabId: TabId) {
const data = this.getData(tabId)
const { repo, name, version } = data
const data = this.getData(tabId);
const { repo, name, version } = data;
// This loop is for "retrying" the "getValues" call
for (const _ of Array(3)) {
const values = await helmChartsApi.getValues(repo, name, version)
const values = await helmChartsApi.getValues(repo, name, version);
if (values) {
this.setData(tabId, { ...data, values })
return
this.setData(tabId, { ...data, values });
return;
}
}
}
@@ -137,7 +137,7 @@ export class InstallChart extends Component<Props> {
logs={this.releaseDetails.log}
/>
</div>
)
);
}
const { repo, name, version, namespace, releaseName } = chartData;
@@ -30,17 +30,17 @@ export const PodLogControls = observer((props: Props) => {
const toggleTimestamps = () => {
save({ showTimestamps: !showTimestamps });
}
};
const togglePrevious = () => {
save({ previous: !previous });
reload();
}
};
const downloadLogs = () => {
const fileName = selectedContainer ? selectedContainer.name : pod.getName();
downloadFile(fileName + ".log", logs.join("\n"), "text/plain");
}
};
const onContainerChange = (option: SelectOption) => {
const { containers, initContainers } = tabData;
@@ -48,9 +48,9 @@ export const PodLogControls = observer((props: Props) => {
selectedContainer: containers
.concat(initContainers)
.find(container => container.name === option.value)
})
});
reload();
}
};
const containerSelectOptions = () => {
const { containers, initContainers } = tabData;
@@ -58,22 +58,22 @@ export const PodLogControls = observer((props: Props) => {
{
label: _i18n._(t`Containers`),
options: containers.map(container => {
return { value: container.name }
return { value: container.name };
}),
},
{
label: _i18n._(t`Init Containers`),
options: initContainers.map(container => {
return { value: container.name }
return { value: container.name };
}),
}
];
}
};
const formatOptionLabel = (option: SelectOption) => {
const { value, label } = option;
return label || <><Icon small material="view_carousel"/> {value}</>;
}
};
return (
<div className="PodLogControls flex gaps align-center">
@@ -33,22 +33,22 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
const onPrevOverlay = () => {
setPrevOverlayActive();
toPrevOverlay();
}
};
const onNextOverlay = () => {
setNextOverlayActive();
toNextOverlay();
}
};
const onClear = () => {
setSearch("");
}
};
const onKeyDown = (evt: React.KeyboardEvent<any>) => {
if (evt.key === "Enter") {
onNextOverlay();
}
}
};
useEffect(() => {
// Refresh search when logs changed
@@ -25,9 +25,9 @@ export const logRange = 500;
@autobind()
export class PodLogsStore extends DockTabStore<IPodLogsData> {
private refresher = interval(10, () => {
const id = dockStore.selectedTabId
if (!this.logs.get(id)) return
this.loadMore(id)
const id = dockStore.selectedTabId;
if (!this.logs.get(id)) return;
this.loadMore(id);
});
@observable logs = observable.map<TabId, PodLogLine[]>();
@@ -48,12 +48,12 @@ export class PodLogsStore extends DockTabStore<IPodLogsData> {
reaction(() => this.logs.get(dockStore.selectedTabId), () => {
this.setNewLogSince(dockStore.selectedTabId);
})
});
reaction(() => dockStore.selectedTabId, () => {
// Clear search query on tab change
searchStore.reset();
})
});
}
/**
+4 -4
View File
@@ -1,7 +1,7 @@
import "./pod-logs.scss";
import React from "react";
import AnsiUp from 'ansi_up';
import DOMPurify from "dompurify"
import DOMPurify from "dompurify";
import { Trans } from "@lingui/macro";
import { action, computed, observable, reaction } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react";
@@ -205,14 +205,14 @@ export class PodLogs extends React.Component<Props> {
className={cssNames("overlay", { active })}
dangerouslySetInnerHTML={{ __html: ansiToHtml(overlayValue) }}
/> :
null
null;
contents.push(
<React.Fragment key={piece + index}>
<span dangerouslySetInnerHTML={{ __html: ansiToHtml(piece) }} />
{overlay}
</React.Fragment>
);
})
});
}
return (
<div className={cssNames("LogRow")}>
@@ -288,7 +288,7 @@ export class PodLogs extends React.Component<Props> {
toPrevOverlay={this.toOverlay}
toNextOverlay={this.toOverlay}
/>
)
);
return (
<div className={cssNames("PodLogs flex column", className, { noscroll: this.hideHorizontalScroll })}>
<InfoPanel
@@ -1,6 +1,6 @@
import "./terminal-tab.scss"
import "./terminal-tab.scss";
import React from "react"
import React from "react";
import { observer } from "mobx-react";
import { Trans } from "@lingui/macro";
import { autobind, cssNames } from "../../utils";
@@ -17,8 +17,8 @@ interface Props extends DockTabProps {
export class TerminalTab extends React.Component<Props> {
componentDidMount() {
reaction(() => this.isDisconnected === true, () => {
dockStore.closeTab(this.tabId)
})
dockStore.closeTab(this.tabId);
});
}
get tabId() {
@@ -55,6 +55,6 @@ export class TerminalTab extends React.Component<Props> {
/>
)}
/>
)
);
}
}
@@ -24,7 +24,7 @@ export class TerminalWindow extends React.Component<Props> {
reaction(() => this.props.tab.id, tabId => this.activate(tabId), {
fireImmediately: true
})
])
]);
}
activate(tabId = this.props.tab.id) {
@@ -40,6 +40,6 @@ export class TerminalWindow extends React.Component<Props> {
className={cssNames("TerminalWindow", className, themeStore.activeTheme.type)}
ref={e => this.elem = e}
/>
)
);
}
}
+2 -2
View File
@@ -15,7 +15,7 @@ export class Terminal {
// https://xtermjs.org/docs/api/terminal/classes/terminal/#open
const pool = document.createElement("div");
pool.className = "terminal-init";
pool.style.cssText = "position: absolute; top: 0; left: 0; height: 0; visibility: hidden; overflow: hidden"
pool.style.cssText = "position: absolute; top: 0; left: 0; height: 0; visibility: hidden; overflow: hidden";
document.body.appendChild(pool);
Terminal.spawningPool = pool;
}
@@ -36,7 +36,7 @@ export class Terminal {
protected setTheme(colors: Record<string, string>) {
// Replacing keys stored in styles to format accepted by terminal
// E.g. terminalBrightBlack -> brightBlack
const colorPrefix = "terminal"
const colorPrefix = "terminal";
const terminalColors = Object.entries(colors)
.filter(([name]) => name.startsWith(colorPrefix))
.reduce<any>((colors, [name, color]) => {
@@ -90,7 +90,7 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
const item = [...this.data].find(item => item[1].releaseName === releaseName);
if (item) {
const [tabId] = item;
return dockStore.getTabById(tabId)
return dockStore.getTabById(tabId);
}
}
}
@@ -113,7 +113,7 @@ export function createUpgradeChartTab(release: HelmRelease, tabParams: Partial<I
upgradeChartStore.setData(tab.id, {
releaseName: release.getName(),
releaseNamespace: release.getNs()
})
});
}
return tab;
}
@@ -1,4 +1,4 @@
import "./upgrade-chart.scss"
import "./upgrade-chart.scss";
import React from "react";
import { observable, reaction } from "mobx";
@@ -68,7 +68,7 @@ export class UpgradeChart extends React.Component<Props> {
if (this.error) return;
const { version, repo } = this.version;
const releaseName = this.release.getName();
const releaseNs = this.release.getNs()
const releaseNs = this.release.getNs();
await releaseStore.update(releaseName, releaseNs, {
chart: this.release.getChart(),
values: this.value,
@@ -78,7 +78,7 @@ export class UpgradeChart extends React.Component<Props> {
<p>
<Trans>Release <b>{releaseName}</b> successfully upgraded to version <b>{version}</b></Trans>
</p>
)
);
}
formatVersionLabel = ({ value }: SelectOption<IChartVersion>) => {
@@ -110,7 +110,7 @@ export class UpgradeChart extends React.Component<Props> {
onChange={({ value }: SelectOption) => this.version = value}
/>
</div>
)
);
return (
<div className={cssNames("UpgradeChart flex column", className)}>
<InfoPanel
@@ -127,6 +127,6 @@ export class UpgradeChart extends React.Component<Props> {
onChange={onChange}
/>
</div>
)
);
}
}