1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Enable object-shorthand rule (#1500)

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
Panu Horsmalahti 2020-11-24 13:16:35 +02:00 committed by GitHub
parent 2a8cfe5e67
commit ff93760dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 69 additions and 66 deletions

View File

@ -26,6 +26,7 @@ module.exports = {
}],
"no-unused-vars": "off",
"semi": ["error", "always"],
"object-shorthand": "error",
}
},
{
@ -58,6 +59,7 @@ module.exports = {
}],
"semi": "off",
"@typescript-eslint/semi": ["error"],
"object-shorthand": "error",
},
},
{
@ -90,6 +92,7 @@ module.exports = {
}],
"semi": "off",
"@typescript-eslint/semi": ["error"],
"object-shorthand": "error",
},
}
]

View File

@ -84,7 +84,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
super({
configName: "lens-cluster-store",
accessPropertiesByDotNotation: false, // To make dots safe in cluster context names
migrations: migrations,
migrations,
});
this.pushStateToViewsAutomatically();

View File

@ -36,7 +36,7 @@ export class UserStore extends BaseStore<UserStoreModel> {
private constructor() {
super({
// configName: "lens-user-store", // todo: migrate from default "config.json"
migrations: migrations,
migrations,
});
this.handleOnLoad();

View File

@ -11,7 +11,7 @@ export class LensMainExtension extends LensExtension {
const windowManager = WindowManager.getInstance<WindowManager>();
const pageUrl = getExtensionPageUrl({
extensionId: this.name,
pageId: pageId,
pageId,
params: params ?? {}, // compile to url with params
});
await windowManager.navigate(pageUrl, frameId);

View File

@ -19,7 +19,7 @@ export class LensRendererExtension extends LensExtension {
const { navigate } = await import("../renderer/navigation");
const pageUrl = getExtensionPageUrl({
extensionId: this.name,
pageId: pageId,
pageId,
params: params ?? {}, // compile to url with params
});
navigate(pageUrl);

View File

@ -13,7 +13,7 @@ export class ClusterIdDetector extends BaseClusterDetector {
id = this.cluster.apiUrl;
}
const value = createHash("sha256").update(id).digest("hex");
return { value: value, accuracy: 100 };
return { value, accuracy: 100 };
}
protected async getDefaultNamespaceId() {

View File

@ -91,7 +91,7 @@ export class ContextHandler {
return {
target: proxyUrl,
changeOrigin: true,
timeout: timeout,
timeout,
headers: {
"Host": this.clusterUrl.hostname,
},

View File

@ -8,7 +8,7 @@ export class HelmCli extends LensBinary {
public constructor(baseDir: string, version: string) {
const opts: LensBinaryOpts = {
version,
baseDir: baseDir,
baseDir,
originalBinaryName: "helm",
newBinaryName: "helm3"
};

View File

@ -40,7 +40,7 @@ export class HelmReleaseManager {
log: stdout,
release: {
name: releaseName,
namespace: namespace
namespace
}
};
} finally {

View File

@ -67,15 +67,15 @@ export class Router {
output: "data",
});
return {
cluster: cluster,
cluster,
path: url.pathname,
raw: {
req: req,
req,
},
response: res,
query: url.searchParams,
payload: payload,
params: params
payload,
params
};
}

View File

@ -78,16 +78,16 @@ class PortForwardRoute extends LensApi {
let portForward = PortForward.getPortforward({
clusterId: cluster.id, kind: resourceType, name: resourceName,
namespace: namespace, port: port
namespace, port
});
if (!portForward) {
logger.info(`Creating a new port-forward ${namespace}/${resourceType}/${resourceName}:${port}`);
portForward = new PortForward({
clusterId: cluster.id,
kind: resourceType,
namespace: namespace,
namespace,
name: resourceName,
port: port,
port,
kubeConfig: cluster.getProxyKubeconfigPath()
});
const started = await portForward.start();

View File

@ -47,7 +47,7 @@ export class ShellSession extends EventEmitter {
this.shellProcess = pty.spawn(shell, args, {
cols: 80,
cwd: this.cwd() || env.HOME,
env: env,
env,
name: "xterm-256color",
rows: 30,
});

View File

@ -124,7 +124,7 @@ export class WindowManager extends Singleton {
await this.ensureMainWindow();
this.sendToView({
channel: "renderer:navigate",
frameId: frameId,
frameId,
data: [url],
});
}

View File

@ -26,7 +26,7 @@ export default migration({
user["auth-provider"].config = authConfig;
kubeConfig.users = [{
name: userObj.name,
user: user
user
}];
cluster.kubeConfig = yaml.safeDump(kubeConfig);
store.set(clusterKey, cluster);

View File

@ -8,7 +8,7 @@ export class ClusterApi extends KubeApi<Cluster> {
async getMetrics(nodeNames: string[], params?: IMetricsReqParams): Promise<IClusterMetrics> {
const nodes = nodeNames.join("|");
const opts = { category: "cluster", nodes: nodes };
const opts = { category: "cluster", nodes };
return metricsApi.getMetrics({
memoryUsage: opts,

View File

@ -20,7 +20,7 @@ export class DeploymentApi extends KubeApi<Deployment> {
data: {
metadata: params,
spec: {
replicas: replicas
replicas
}
}
});

View File

@ -119,7 +119,7 @@ export const helmReleasesApi = {
const path = endpoint({ name, namespace }) + "/rollback";
return apiBase.put(path, {
data: {
revision: revision
revision
}
});
}

View File

@ -84,8 +84,8 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
}
const infoLog: JsonApiLog = {
method: reqInit.method.toUpperCase(),
reqUrl: reqUrl,
reqInit: reqInit,
reqUrl,
reqInit,
};
return cancelableFetch(reqUrl, reqInit).then(res => {
return this.parseResponse<D>(res, infoLog);

View File

@ -73,7 +73,7 @@ export function forCluster<T extends KubeObject>(cluster: IKubeApiCluster, kubeC
});
return new KubeApi({
objectConstructor: kubeClass,
request: request
request
});
}
@ -228,7 +228,7 @@ export class KubeApi<T extends KubeObject = any> {
apiVersion: this.apiVersionWithGroup,
resource: this.apiResource,
namespace: this.isNamespaced ? namespace : undefined,
name: name,
name,
});
return resourcePath + (query ? `?` + stringify(this.normalizeQuery(query)) : "");
}
@ -256,7 +256,7 @@ export class KubeApi<T extends KubeObject = any> {
this.setResourceVersion("", metadata.resourceVersion);
return items.map(item => new KubeObjectConstructor({
kind: this.kind,
apiVersion: apiVersion,
apiVersion,
...item,
}));
}

View File

@ -152,7 +152,7 @@ export class AddCluster extends React.Component {
: ClusterStore.embedCustomKubeConfig(clusterId, kubeConfig); // save in app-files folder
return {
id: clusterId,
kubeConfigPath: kubeConfigPath,
kubeConfigPath,
workspace: workspaceStore.currentWorkspaceId,
contextName: kubeConfig.currentContext,
preferences: {

View File

@ -36,7 +36,7 @@ export class HelmChartStore extends ItemStore<HelmChart> {
const loadVersions = (repo: string) => {
return helmChartsApi.get(repo, chartName).then(({ versions }) => {
return versions.map(chart => ({
repo: repo,
repo,
version: chart.getVersion()
}));
});

View File

@ -27,7 +27,7 @@ export const ClusterMetrics = observer(() => {
id: metricType + metricNodeRole,
label: metricType.toUpperCase() + " usage",
borderColor: colors[metricType],
data: data
data
}];
const cpuOptions: ChartOptions = {
scales: {

View File

@ -92,11 +92,11 @@ export class AddSecretDialog extends React.Component<Props> {
const { name, namespace, type } = this;
const { data = [], labels = [], annotations = [] } = this.secret[type];
const secret: Partial<Secret> = {
type: type,
type,
data: this.getDataFromFields(data, val => val ? base64.encode(val) : ""),
metadata: {
name: name,
namespace: namespace,
name,
namespace,
annotations: this.getDataFromFields(annotations),
labels: this.getDataFromFields(labels),
} as IKubeObjectMetadata

View File

@ -60,7 +60,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
kind: "Namespace",
apiVersion: "v1",
metadata: {
name: name,
name,
uid: "",
resourceVersion: "",
selfLink: `/api/v1/namespaces/${name}`

View File

@ -137,7 +137,7 @@ export class AddRoleBindingDialog extends React.Component<Props> {
else {
const name = useRoleForBindingName ? selectedRole.getName() : bindingName;
roleBinding = await roleBindingsStore.create({ name, namespace }, {
subjects: subjects,
subjects,
roleRef: {
name: selectedRole.getName(),
kind: selectedRole.kind,

View File

@ -88,7 +88,7 @@ export class ServiceAccountsDetails extends React.Component<Props> {
apiVersion: "v1",
kind: "Secret",
metadata: {
name: name,
name,
uid: null,
selfLink: null,
resourceVersion: null

View File

@ -59,7 +59,7 @@ export class App extends React.Component {
name: "cluster",
action: "open",
params: {
clusterId: clusterId
clusterId
}
});
window.addEventListener("online", () => {

View File

@ -30,7 +30,7 @@ export class Checkbox extends React.PureComponent<CheckboxProps> {
render() {
const { label, inline, className, value, theme, children, ...inputProps } = this.props;
const componentClass = cssNames('Checkbox flex', className, {
inline: inline,
inline,
checked: value,
disabled: this.props.disabled,
["theme-" + theme]: theme,

View File

@ -55,7 +55,7 @@ export class EditResource extends React.Component<Props> {
}
editResourceStore.setData(this.tabId, {
...this.tabData,
draft: draft,
draft,
});
}

View File

@ -38,7 +38,7 @@ export class FileInput extends React.Component<Props> {
const reader = new FileReader();
reader.onloadend = () => {
resolve({
file: file,
file,
data: reader.result,
error: reader.error ? String(reader.error) : null,
});

View File

@ -149,7 +149,7 @@ export class Input extends React.Component<InputProps, State> {
this.setState({
validating: false,
valid: !errors.length,
errors: errors,
errors,
});
}
@ -273,11 +273,11 @@ export class Input extends React.Component<InputProps, State> {
const className = cssNames("Input", this.props.className, {
[`theme ${theme}`]: theme,
focused: focused,
disabled: disabled,
focused,
disabled,
invalid: !valid,
dirty: dirty,
validating: validating,
dirty,
validating,
validatingLine: validating && showValidationLine,
});

View File

@ -81,7 +81,7 @@ export class MenuActions extends React.Component<MenuActionsProps> {
...menuProps
} = this.props;
const menuClassName = cssNames("MenuActions flex", className, {
toolbar: toolbar,
toolbar,
gaps: toolbar, // add spacing for .flex
});
const autoClose = !toolbar;

View File

@ -15,7 +15,7 @@ export class Notifications extends React.Component {
static ok(message: NotificationMessage) {
notificationsStore.add({
message: message,
message,
timeout: 2500,
status: NotificationStatus.OK
});
@ -23,7 +23,7 @@ export class Notifications extends React.Component {
static error(message: NotificationMessage) {
notificationsStore.add({
message: message,
message,
timeout: 10000,
status: NotificationStatus.ERROR
});
@ -33,7 +33,7 @@ export class Notifications extends React.Component {
return notificationsStore.add({
status: NotificationStatus.INFO,
timeout: 0,
message: message,
message,
...customOpts,
});
}

View File

@ -24,10 +24,10 @@ export class RadioGroup extends React.Component<RadioGroupProps, {}> {
<div className={className}>
{radios.map(radio => {
return React.cloneElement(radio, {
name: name,
name,
disabled: disabled !== undefined ? disabled : radio.props.disabled,
checked: radio.props.value === value,
onChange: onChange
onChange
} as any);
})}
</div>
@ -66,7 +66,7 @@ export class Radio extends React.Component<RadioProps> {
render() {
const { className, label, checked, children, ...inputProps } = this.props;
const componentClass = cssNames('Radio flex align-center', className, {
checked: checked,
checked,
disabled: this.props.disabled,
});
return (

View File

@ -60,7 +60,7 @@ export class TableCell extends React.Component<TableCellProps> {
render() {
const { className, checkbox, isChecked, sortBy, _sort, _sorting, _nowrap, children, title, renderBoolean: displayBoolean, ...cellProps } = this.props;
const classNames = cssNames("TableCell", className, {
checkbox: checkbox,
checkbox,
nowrap: _nowrap,
sorting: this.isSortable,
});

View File

@ -82,7 +82,7 @@ export class Table extends React.Component<TableProps> {
typeof elem.props.children === "string" ? elem.props.children : undefined
);
return React.cloneElement(elem, {
title: title,
title,
_sort: this.sort,
_sorting: this.sortParams,
_nowrap: headElem.props.nowrap,

View File

@ -32,10 +32,10 @@ export class Tabs extends React.PureComponent<TabsProps> {
render() {
const { center, wrap, onChange, value, autoFocus, scrollable = true, withBorder, ...elemProps } = this.props;
const className = cssNames("Tabs", this.props.className, {
center: center,
wrap: wrap,
scrollable: scrollable,
withBorder: withBorder,
center,
wrap,
scrollable,
withBorder,
});
return (
<TabsContext.Provider value={{ autoFocus, value, onChange }}>
@ -120,7 +120,7 @@ export class Tab extends React.PureComponent<TabProps> {
let { className } = this.props;
className = cssNames("Tab flex gaps align-center", className, {
"active": this.isActive,
"disabled": disabled,
disabled,
});
return (
<div

View File

@ -180,8 +180,8 @@ export class Tooltip extends React.Component<TooltipProps> {
break;
}
return {
left: left,
top: top,
left,
top,
right: left + tooltipBounds.width,
bottom: top + tooltipBounds.height,
};

View File

@ -146,7 +146,7 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
protected bindWatchEventsUpdater(delay = 1000) {
return reaction(() => this.eventsBuffer.toJS()[0], this.updateFromEventsBuffer, {
delay: delay
delay
});
}

View File

@ -67,7 +67,7 @@ export function getSelectedDetails() {
export function getDetailsUrl(details: string) {
if (!details) return "";
return getQueryString({
details: details,
details,
selected: getSelectedDetails(),
});
}

View File

@ -1,5 +1,5 @@
export function downloadFile(filename: string, contents: any, type: string) {
const data = new Blob([contents], { type: type });
const data = new Blob([contents], { type });
const url = URL.createObjectURL(data);
const link = document.createElement("a");
link.href = url;

View File

@ -7,19 +7,19 @@ export function interval(timeSec = 1, callback: IntervalCallback, autoRun = fals
let timer = -1;
let isRunning = false;
const intervalManager = {
start: function (runImmediately = false) {
start (runImmediately = false) {
if (isRunning) return;
const tick = () => callback(++count);
isRunning = true;
timer = window.setInterval(tick, 1000 * timeSec);
if (runImmediately) tick();
},
stop: function () {
stop () {
count = 0;
isRunning = false;
clearInterval(timer);
},
restart: function (runImmediately = false) {
restart (runImmediately = false) {
this.stop();
this.start(runImmediately);
},