fix sonarqube warning about js array sort

This commit is contained in:
Sebastian Sdorra
2019-10-30 14:52:46 +01:00
parent e878f86b46
commit f5fb4fb11a
2 changed files with 7 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import * as React from "react";
import React, { ReactNode } from "react";
import { apiClient, Loading } from "@scm-manager/ui-components";
import { getUiPluginsLink } from "../modules/indexResource";
import { connect } from "react-redux";
@@ -6,7 +6,7 @@ import loadBundle from "./loadBundle";
type Props = {
loaded: boolean;
children: React.Node;
children: ReactNode;
link: string;
callback: () => void;
};
@@ -55,7 +55,7 @@ class PluginLoader extends React.Component<Props, State> {
});
const promises = [];
const sortedPlugins = plugins.sort(comparePluginsByName);
const sortedPlugins = [...plugins].sort(comparePluginsByName);
for (const plugin of sortedPlugins) {
promises.push(this.loadPlugin(plugin));
}
@@ -96,7 +96,8 @@ const comparePluginsByName = (a: Plugin, b: Plugin) => {
}
return 0;
};
const mapStateToProps = state => {
const mapStateToProps = (state: any) => {
const link = getUiPluginsLink(state);
return {
link

View File

@@ -87,7 +87,8 @@ class FileTree extends React.Component<Props> {
};
if (tree._embedded && tree._embedded.children) {
files.push(...tree._embedded.children.sort(compareFiles));
const children = [...tree._embedded.children].sort(compareFiles);
files.push(...children);
}
if (files && files.length > 0) {