Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] Fix eslint and prettier errors #117

Merged
merged 4 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kafka-ui-react-app/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
{ "extensions": [".js", ".jsx", ".ts", ".tsx"] }
],
"jsx-a11y/label-has-associated-control": "off",
"no-param-reassign": [2, { "props": false }]
"no-param-reassign": [2, { "props": false }],
"import/prefer-default-export": "off"
},
"overrides": [
{
Expand Down
4,485 changes: 2,461 additions & 2,024 deletions kafka-ui-react-app/package-lock.json

Large diffs are not rendered by default.

42 changes: 23 additions & 19 deletions kafka-ui-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"private": true,
"dependencies": {
"@types/react-datepicker": "^3.0.2",
"@types/uuid": "^8.3.0",
"bulma": "^0.8.0",
"bulma-switch": "^2.0.0",
"classnames": "^2.2.6",
"date-fns": "^2.14.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-import-resolver-typescript": "^2.3.0",
"immer": "^6.0.5",
"lodash": "^4.17.15",
"pretty-ms": "^6.0.1",
Expand All @@ -24,25 +25,28 @@
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"typesafe-actions": "^5.1.0",
"use-debounce": "^3.4.3"
"use-debounce": "^3.4.3",
"uuid": "^8.3.1"
},
"lint-staged": {
"*.{js,ts,jsx,tsx}": [
"eslint -c .eslintrc.json --fix"
"eslint -c .eslintrc.json --fix",
"git add"
]
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"lint": "esprint check",
"lint:fix": "esprint check --fix",
"lint": "eslint --ext .tsx,.ts src/",
"lint:fix": "eslint --ext .tsx,.ts src/ --fix",
"test": "react-scripts test",
"eject": "react-scripts eject",
"mock": "node ./mock/index.js"
"mock": "node ./mock/index.js",
"tsc": "tsc"
},
"husky": {
"hooks": {
"pre-commit": "yarn tsc --noEmit && lint-staged"
"pre-commit": "npm run tsc --noEmit && lint-staged"
}
},
"eslintConfig": {
Expand Down Expand Up @@ -74,24 +78,24 @@
"@types/react-router-dom": "^5.1.3",
"@types/redux": "^3.6.0",
"@types/redux-thunk": "^2.1.0",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"dotenv": "^8.2.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.19.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^2.5.1",
"esprint": "^0.6.0",
"husky": "^4.2.5",
"husky": "^4.3.0",
"json-server": "^0.15.1",
"lint-staged": ">=10",
"lint-staged": "^10.5.1",
"node-sass": "^4.13.1",
"prettier": "^2.0.4",
"react-scripts": "3.4.0",
"prettier": "^2.1.2",
"react-scripts": "3.4.4",
"typescript": "~3.7.4"
},
"proxy": "http://localhost:8080"
Expand Down
8 changes: 3 additions & 5 deletions kafka-ui-react-app/src/components/AppContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { connect } from 'react-redux';
import {
fetchClustersList,
} from 'redux/actions';
import App from './App';
import { fetchClustersList } from 'redux/actions';
import { getIsClusterListFetched } from 'redux/reducers/clusters/selectors';
import { RootState } from 'redux/interfaces';
import App from './App';

const mapStateToProps = (state: RootState) => ({
isClusterListFetched: getIsClusterListFetched(state),
});

const mapDispatchToProps = {
fetchClustersList,
}
};

export default connect(mapStateToProps, mapDispatchToProps)(App);
37 changes: 18 additions & 19 deletions kafka-ui-react-app/src/components/Brokers/Brokers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ const Topics: React.FC<Props> = ({
fetchBrokers,
fetchBrokerMetrics,
}) => {
React.useEffect(
() => {
fetchBrokers(clusterName);
fetchBrokerMetrics(clusterName);
},
[fetchBrokers, fetchBrokerMetrics, clusterName],
);
React.useEffect(() => {
fetchBrokers(clusterName);
fetchBrokerMetrics(clusterName);
}, [fetchBrokers, fetchBrokerMetrics, clusterName]);

useInterval(() => { fetchBrokerMetrics(clusterName); }, 5000);
useInterval(() => {
fetchBrokerMetrics(clusterName);
}, 5000);

const zkOnline = zooKeeperStatus === ZooKeeperStatus.online;

Expand All @@ -44,12 +43,8 @@ const Topics: React.FC<Props> = ({
<Breadcrumb>Brokers overview</Breadcrumb>

<MetricsWrapper title="Uptime">
<Indicator label="Total Brokers">
{brokerCount}
</Indicator>
<Indicator label="Active Controllers">
{activeControllers}
</Indicator>
<Indicator label="Total Brokers">{brokerCount}</Indicator>
<Indicator label="Active Controllers">{activeControllers}</Indicator>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it better?

<Indicator label="Zookeeper Status">
<span className={cx('tag', zkOnline ? 'is-primary' : 'is-danger')}>
{zkOnline ? 'Online' : 'Offline'}
Expand All @@ -59,17 +54,21 @@ const Topics: React.FC<Props> = ({

<MetricsWrapper title="Partitions">
<Indicator label="Online">
<span className={cx({'has-text-danger': offlinePartitionCount !== 0})}>
<span
className={cx({ 'has-text-danger': offlinePartitionCount !== 0 })}
>
{onlinePartitionCount}
</span>
<span className="subtitle has-text-weight-light"> of {onlinePartitionCount + offlinePartitionCount}</span>
<span className="subtitle has-text-weight-light">
{' '}
of
{onlinePartitionCount + offlinePartitionCount}
</span>
</Indicator>
<Indicator label="URP" title="Under replicated partitions">
{underReplicatedPartitionCount}
</Indicator>
<Indicator label="In Sync Replicas">
{inSyncReplicasCount}
</Indicator>
<Indicator label="In Sync Replicas">{inSyncReplicasCount}</Indicator>
<Indicator label="Out of Sync Replicas">
{outOfSyncReplicasCount}
</Indicator>
Expand Down
25 changes: 16 additions & 9 deletions kafka-ui-react-app/src/components/Brokers/BrokersContainer.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { connect } from 'react-redux';
import {
fetchBrokers,
fetchBrokerMetrics,
} from 'redux/actions';
import Brokers from './Brokers';
import { fetchBrokers, fetchBrokerMetrics } from 'redux/actions';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it better?

import * as brokerSelectors from 'redux/reducers/brokers/selectors';
import { RootState, ClusterName } from 'redux/interfaces';
import { RouteComponentProps } from 'react-router-dom';
import Brokers from './Brokers';

interface RouteProps {
clusterName: ClusterName;
}

interface OwnProps extends RouteComponentProps<RouteProps> { }
type OwnProps = RouteComponentProps<RouteProps>;

const mapStateToProps = (state: RootState, { match: { params: { clusterName } }}: OwnProps) => ({
const mapStateToProps = (
state: RootState,
{
match: {
params: { clusterName },
},
}: OwnProps
) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it better? Somewhere you collapse objects, and somewhere you don't. What logic should we follow? only the length of the line?

isFetched: brokerSelectors.getIsBrokerListFetched(state),
clusterName,
brokerCount: brokerSelectors.getBrokerCount(state),
Expand All @@ -24,12 +28,15 @@ const mapStateToProps = (state: RootState, { match: { params: { clusterName } }}
offlinePartitionCount: brokerSelectors.getOfflinePartitionCount(state),
inSyncReplicasCount: brokerSelectors.getInSyncReplicasCount(state),
outOfSyncReplicasCount: brokerSelectors.getOutOfSyncReplicasCount(state),
underReplicatedPartitionCount: brokerSelectors.getUnderReplicatedPartitionCount(state)
underReplicatedPartitionCount: brokerSelectors.getUnderReplicatedPartitionCount(
state
),
});

const mapDispatchToProps = {
fetchBrokers: (clusterName: ClusterName) => fetchBrokers(clusterName),
fetchBrokerMetrics: (clusterName: ClusterName) => fetchBrokerMetrics(clusterName),
fetchBrokerMetrics: (clusterName: ClusterName) =>
fetchBrokerMetrics(clusterName),
};

export default connect(mapStateToProps, mapDispatchToProps)(Brokers);
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@ import { RouteComponentProps } from 'react-router-dom';
import ConsumerGroups from './ConsumerGroups';
import { getIsConsumerGroupsListFetched } from '../../redux/reducers/consumerGroups/selectors';


interface RouteProps {
clusterName: ClusterName;
}

interface OwnProps extends RouteComponentProps<RouteProps> { }
type OwnProps = RouteComponentProps<RouteProps>;

const mapStateToProps = (state: RootState, { match: { params: { clusterName } }}: OwnProps) => ({
const mapStateToProps = (
state: RootState,
{
match: {
params: { clusterName },
},
}: OwnProps
) => ({
isFetched: getIsConsumerGroupsListFetched(state),
clusterName,
});

const mapDispatchToProps = {
fetchConsumerGroupsList: (clusterName: ClusterName) => fetchConsumerGroupsList(clusterName),
fetchConsumerGroupsList: (clusterName: ClusterName) =>
fetchConsumerGroupsList(clusterName),
};

export default connect(mapStateToProps, mapDispatchToProps)(ConsumerGroups);
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
import { connect } from 'react-redux';
import Details from './Details';
import {ClusterName, RootState} from 'redux/interfaces';
import { ClusterName, RootState } from 'redux/interfaces';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { getIsConsumerGroupDetailsFetched, getConsumerGroupByID } from 'redux/reducers/consumerGroups/selectors';
import {
getIsConsumerGroupDetailsFetched,
getConsumerGroupByID,
} from 'redux/reducers/consumerGroups/selectors';
import { ConsumerGroupID } from 'redux/interfaces/consumerGroup';
import { fetchConsumerGroupDetails } from 'redux/actions/thunks';
import Details from './Details';

interface RouteProps {
clusterName: ClusterName;
consumerGroupID: string;
}

interface OwnProps extends RouteComponentProps<RouteProps> { }
type OwnProps = RouteComponentProps<RouteProps>;

const mapStateToProps = (state: RootState, { match: { params: { consumerGroupID, clusterName } } }: OwnProps) => ({
const mapStateToProps = (
state: RootState,
{
match: {
params: { consumerGroupID, clusterName },
},
}: OwnProps
) => ({
clusterName,
consumerGroupID,
isFetched: getIsConsumerGroupDetailsFetched(state),
...getConsumerGroupByID(state, consumerGroupID)
...getConsumerGroupByID(state, consumerGroupID),
});

const mapDispatchToProps = {
fetchConsumerGroupDetails: (clusterName: ClusterName, consumerGroupID: ConsumerGroupID) => fetchConsumerGroupDetails(clusterName, consumerGroupID),
fetchConsumerGroupDetails: (
clusterName: ClusterName,
consumerGroupID: ConsumerGroupID
) => fetchConsumerGroupDetails(clusterName, consumerGroupID),
};

export default withRouter(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { connect } from 'react-redux';
import {ClusterName, RootState} from 'redux/interfaces';
import { ClusterName, RootState } from 'redux/interfaces';
import { getConsumerGroupsList } from 'redux/reducers/consumerGroups/selectors';
import List from './List';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import List from './List';

interface RouteProps {
clusterName: ClusterName;
}

interface OwnProps extends RouteComponentProps<RouteProps> { }
type OwnProps = RouteComponentProps<RouteProps>;

const mapStateToProps = (state: RootState, { match: { params: { clusterName } } }: OwnProps) => ({
const mapStateToProps = (
state: RootState,
{
match: {
params: { clusterName },
},
}: OwnProps
) => ({
clusterName,
consumerGroups: getConsumerGroupsList(state)
consumerGroups: getConsumerGroupsList(state),
});

export default withRouter(
connect(mapStateToProps)(List)
);
export default withRouter(connect(mapStateToProps)(List));
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@ import formatBytes from 'lib/utils/formatBytes';
import { NavLink } from 'react-router-dom';
import { clusterBrokersPath } from 'lib/paths';

const ClusterWidget: React.FC<Cluster> = ({
name,
status,
topicCount,
brokerCount,
bytesInPerSec,
bytesOutPerSec,
onlinePartitionCount,
interface ClusterWidgetProps {
cluster: Cluster;
}

const ClusterWidget: React.FC<ClusterWidgetProps> = ({
cluster: {
name,
status,
topicCount,
brokerCount,
bytesInPerSec,
bytesOutPerSec,
onlinePartitionCount,
},
}) => (
<NavLink to={clusterBrokersPath(name)} className="column is-full-modile is-6">
<div className="box is-hoverable">
<div
className="title is-6 has-text-overflow-ellipsis"
title={name}
>
<div className="title is-6 has-text-overflow-ellipsis" title={name}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it better?

<div
className={`tag has-margin-right ${status === ClusterStatus.Online ? 'is-primary' : 'is-danger'}`}
className={`tag has-margin-right ${
status === ClusterStatus.Online ? 'is-primary' : 'is-danger'
}`}
>
{status}
</div>
Expand Down
Loading