Skip to content

Commit

Permalink
Apply prettier to zipkin-lens for automatic whitespace formatting. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored Mar 13, 2020
1 parent 8803026 commit 94d7994
Show file tree
Hide file tree
Showing 123 changed files with 3,790 additions and 2,677 deletions.
8 changes: 6 additions & 2 deletions zipkin-lens/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
* the License.
*/
module.exports = {
extends: 'airbnb-typescript',
extends: [
'airbnb-typescript',
'plugin:prettier/recommended',
'prettier/@typescript-eslint',
'prettier/react',
],
rules: {
'import/prefer-default-export': 'off',
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.tsx'] }],
Expand All @@ -23,7 +28,6 @@ module.exports = {
'react/no-unescaped-entities': 'off',
'max-classes-per-file': 'off',
'no-console': 0,
'no-mixed-operators': ['error', { allowSamePrecedence: true }],
'no-underscore-dangle': ['off'],
'no-continue': ['off'],
'prefer-destructuring': ['error', {
Expand Down
18 changes: 18 additions & 0 deletions zipkin-lens/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2015-2020 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
module.exports = {
arrowParens: 'always',
singleQuote: true,
trailingComma: 'all',
};
39 changes: 39 additions & 0 deletions zipkin-lens/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions zipkin-lens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.7.0",
"eslint-config-airbnb-typescript": "^7.0.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.3.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.6.1",
"fetch-mock": "^7.3.0",
Expand All @@ -52,6 +54,7 @@
"moment": "^2.24.0",
"mvy": "0.2.1",
"node-fetch": "^2.3.0",
"prettier": "^1.19.1",
"prop-types": "^15.6.2",
"query-string": "^6.1.0",
"rc-slider": "^8.6.9",
Expand Down
4 changes: 3 additions & 1 deletion zipkin-lens/src/actions/autocomplete-values-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export const fetchAutocompleteValuesFailure = () => ({
type: types.FETCH_AUTOCOMPLETE_VALUES_FAILURE,
});

export const fetchAutocompleteValues = (autocompleteKey) => async (dispatch) => {
export const fetchAutocompleteValues = (autocompleteKey) => async (
dispatch,
) => {
dispatch(fetchAutocompleteValuesRequest());
try {
const query = queryString.stringify({ key: autocompleteKey });
Expand Down
10 changes: 6 additions & 4 deletions zipkin-lens/src/actions/autocomplete-values-action.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 The OpenZipkin Authors
* Copyright 2015-2020 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -44,8 +44,10 @@ describe('autocomplete-values async actions', () => {
];
const store = mockStore();

return store.dispatch(actions.fetchAutocompleteValues('environment')).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store
.dispatch(actions.fetchAutocompleteValues('environment'))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
});
12 changes: 9 additions & 3 deletions zipkin-lens/src/actions/global-search-action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ describe('global search actions', () => {
type: types.GLOBAL_SEARCH_SET_LOOKBACK_CONDITION,
lookbackCondition,
};
expect(actions.setLookbackCondition(lookbackCondition)).toEqual(expectedAction);
expect(actions.setLookbackCondition(lookbackCondition)).toEqual(
expectedAction,
);
});

it('should create an action to set the limit condition', () => {
Expand Down Expand Up @@ -67,7 +69,9 @@ describe('global search actions', () => {
index,
conditionKey,
};
expect(actions.changeConditionKey(index, conditionKey)).toEqual(expectedAction);
expect(actions.changeConditionKey(index, conditionKey)).toEqual(
expectedAction,
);
});

it('should create an action to change the value of conditions', () => {
Expand All @@ -78,6 +82,8 @@ describe('global search actions', () => {
index,
conditionValue,
};
expect(actions.changeConditionValue(index, conditionValue)).toEqual(expectedAction);
expect(actions.changeConditionValue(index, conditionValue)).toEqual(
expectedAction,
);
});
});
16 changes: 10 additions & 6 deletions zipkin-lens/src/actions/trace-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ export const loadTraceFailure = () => ({
type: types.TRACE_LOAD_FAILURE,
});

const calculateCorrectedTrace = async (trace) => treeCorrectedForClockSkew(trace);
const calculateCorrectedTrace = async (trace) =>
treeCorrectedForClockSkew(trace);

const calculateDetailedTraceSummary = async (correctedTrace) => buildDetailedTraceSummary(
correctedTrace,
);
const calculateDetailedTraceSummary = async (correctedTrace) =>
buildDetailedTraceSummary(correctedTrace);

export const loadTrace = (traceId, correctedTraceMap) => async (dispatch) => {
dispatch(loadTraceRequest());

if (correctedTraceMap[traceId]) {
const detailedTraceSummary = await calculateDetailedTraceSummary(correctedTraceMap[traceId]);
const detailedTraceSummary = await calculateDetailedTraceSummary(
correctedTraceMap[traceId],
);
dispatch(loadTraceSuccess(detailedTraceSummary));
} else {
try {
Expand All @@ -52,7 +54,9 @@ export const loadTrace = (traceId, correctedTraceMap) => async (dispatch) => {
}
const trace = await res.json();
const correctedTrace = await calculateCorrectedTrace(trace);
const detailedTraceSummary = await calculateDetailedTraceSummary(correctedTrace);
const detailedTraceSummary = await calculateDetailedTraceSummary(
correctedTrace,
);

dispatch(loadTraceSuccess(detailedTraceSummary));
} catch (err) {
Expand Down
22 changes: 14 additions & 8 deletions zipkin-lens/src/actions/trace-action.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 The OpenZipkin Authors
* Copyright 2015-2020 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -74,9 +74,11 @@ describe('trace async actions', () => {
];
const store = mockStore({});

return store.dispatch(actions.loadTrace('d050e0d52326cf81', {})).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store
.dispatch(actions.loadTrace('d050e0d52326cf81', {}))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});

it('create TRACE_LOAD_SUCCESS when calculating summary has been done', () => {
Expand All @@ -91,13 +93,17 @@ describe('trace async actions', () => {
},
{
type: types.TRACE_LOAD_SUCCESS,
traceSummary: buildDetailedTraceSummary(correctedTraceMap.d050e0d52326cf81),
traceSummary: buildDetailedTraceSummary(
correctedTraceMap.d050e0d52326cf81,
),
},
];
const store = mockStore({});

return store.dispatch(actions.loadTrace('d050e0d52326cf81', correctedTraceMap)).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store
.dispatch(actions.loadTrace('d050e0d52326cf81', correctedTraceMap))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
});
8 changes: 4 additions & 4 deletions zipkin-lens/src/actions/trace-viewer.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 The OpenZipkin Authors
* Copyright 2015-2020 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -29,8 +29,8 @@ describe('trace viewer actions', () => {
type: types.TRACE_VIEWER__LOAD_TRACE_FAILURE,
message: 'This is an error message',
};
expect(
actions.loadTraceFailure('This is an error message'),
).toEqual(expectedAction);
expect(actions.loadTraceFailure('This is an error message')).toEqual(
expectedAction,
);
});
});
17 changes: 11 additions & 6 deletions zipkin-lens/src/actions/traces-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ const calculateTraceSummaries = async (traces, serviceName) => {
correctedTraceMap[traceId] = trace;
});

const traceSummaries = buildTraceSummaries(serviceName, correctedTraces.map(buildTraceSummary));
const traceSummaries = buildTraceSummaries(
serviceName,
correctedTraces.map(buildTraceSummary),
);

return {
traceSummaries,
Expand All @@ -75,12 +78,14 @@ export const loadTraces = (params) => async (dispatch) => {
}
const traces = await res.json();

const {
traceSummaries,
correctedTraceMap,
} = await calculateTraceSummaries(traces, query.serviceName);
const { traceSummaries, correctedTraceMap } = await calculateTraceSummaries(
traces,
query.serviceName,
);

dispatch(loadTracesSuccess(traces, traceSummaries, correctedTraceMap, params));
dispatch(
loadTracesSuccess(traces, traceSummaries, correctedTraceMap, params),
);
} catch (err) {
dispatch(loadTracesFailure());
}
Expand Down
27 changes: 19 additions & 8 deletions zipkin-lens/src/actions/traces-action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import fetchMock from 'fetch-mock';
import * as actions from './traces-action';
import * as types from '../constants/action-types';
import * as api from '../constants/api';
import { traceSummary as buildTraceSummary, traceSummaries as buildTraceSummaries, treeCorrectedForClockSkew } from '../zipkin';
import {
traceSummary as buildTraceSummary,
traceSummaries as buildTraceSummaries,
treeCorrectedForClockSkew,
} from '../zipkin';

const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
Expand Down Expand Up @@ -65,7 +69,10 @@ describe('traces async actions', () => {
const [{ traceId }] = rawTraces[index];
correctedTraceMap[traceId] = trace;
});
const traceSummaries = buildTraceSummaries(null, correctedTraces.map(buildTraceSummary));
const traceSummaries = buildTraceSummaries(
null,
correctedTraces.map(buildTraceSummary),
);

const expectedActions = [
{
Expand All @@ -84,12 +91,16 @@ describe('traces async actions', () => {
];
const store = mockStore({});

return store.dispatch(actions.loadTraces({
serviceName: 'serviceA',
spanName: 'span1',
})).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store
.dispatch(
actions.loadTraces({
serviceName: 'serviceA',
spanName: 'span1',
}),
)
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});

it('clearTraces dispatches action', () => {
Expand Down
Loading

0 comments on commit 94d7994

Please sign in to comment.