Skip to content

Commit

Permalink
Fix linting warnings for no-unused-vars, no-var-requires (#1800)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Resolves: #1608

## Description of the changes
- I fixed eslint warnings in our codebase, which we are got after
running yarn lint. This improves code quality, consistency, and reduces
technical debt.

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: priyanshu-kun <priyanshushrama709@gmail.com>
Signed-off-by: Priyanshu Sharma <priyanshushrama709@gmail.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
3 people committed Sep 18, 2023
1 parent 2be7da6 commit 0ba8779
Show file tree
Hide file tree
Showing 25 changed files with 44 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('<MonitorATMServicesView>', () => {
});

describe('<MonitorATMServicesView> on page switch', () => {
// eslint-disable-next-line no-unused-vars
/* eslint-disable @typescript-eslint/no-unused-vars */
let wrapper;
const stateOnPageSwitch = {
services: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe('QualityMetrics', () => {
service: 'test-service',
services: ['foo', 'bar', 'baz'],
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const { service: _s, ...propsWithoutService } = props;
let fetchQualityMetricsSpy;
let promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export default function FileLoader(props: FileLoaderProps) {
return (
<Dragger
accept=".json"
beforeUpload={(file, fileList) => fileList.forEach(file => props.loadJsonTraces({ file }))}
beforeUpload={(file, fileList) =>
fileList.forEach(fileFromList => props.loadJsonTraces({ file: fileFromList }))
}
multiple
>
<p className="ant-upload-drag-icon">
Expand Down
11 changes: 2 additions & 9 deletions packages/jaeger-ui/src/components/SearchTracePage/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,8 @@ describe('mapStateToProps()', () => {
},
};

const {
maxTraceDuration,
traceResults,
traceResultsToDownload,
diffCohort,
numberOfTraceResults,
location,
...rest
} = mapStateToProps(state);
const { maxTraceDuration, traceResults, traceResultsToDownload, diffCohort, ...rest } =
mapStateToProps(state);
expect(traceResults).toHaveLength(stateTrace.search.results.length);
expect(traceResults[0].traceID).toBe(trace.traceID);
expect(traceResultsToDownload[0].traceID).toBe(trace.traceID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ describe('SearchTracePage/url', () => {
expect(isSameQuery(baseQuery)).toBe(false);
});

/* eslint-disable @typescript-eslint/no-unused-vars */
it('returns `false` if a considered key is changed or omitted', () => {
queryKeys.forEach(key => {
// eslint-disable-next-line camelcase
const { [key]: _omitted, ...rest } = baseQuery;
expect(isSameQuery(baseQuery, rest)).toBe(false);
expect(isSameQuery(baseQuery, { ...rest, [key]: 'changed' })).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('TraceDiffGraph', () => {
it('renders an empty div when a or b lack data', () => {
expect(wrapper.children().length).not.toBe(0);

/* eslint-disable @typescript-eslint/no-unused-vars */
const { data: unusedAData, ...aWithoutData } = props.a;
wrapper.setProps({ a: aWithoutData });
expect(wrapper.children().length).toBe(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function criticalPathForTrace(trace: Trace) {
const sanitizedSpanMap = sanitizeOverFlowingChildren(refinedSpanMap);
criticalPath = computeCriticalPath(sanitizedSpanMap, rootSpanId, criticalPath);
} catch (error) {
/* eslint-disable no-console */
console.log('error while computing critical path for a trace', error);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Span B will be dropped. |
span A is on critical path(+++++) |
*/

const trace = require('../../TraceStatistics/tableValuesTestTrace/traceWithSingleChildSpanLongerThanParent.json');
import trace from '../../TraceStatistics/tableValuesTestTrace/traceWithSingleChildSpanLongerThanParent.json';

const transformedTrace = transformTraceData(trace);
const traceStart = 1679437737490189;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { convertJaegerTraceToProfile } from '@pyroscope/flamegraph';

import TraceFlamegraph from './index';

const testTrace = require('./testTrace.json');
import testTrace from './testTrace.json';

const profile = convertJaegerTraceToProfile(testTrace.data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import calculateTraceDagEV from './calculateTraceDagEV';
import TraceGraph, { setOnEdgePath } from './TraceGraph';
import { MODE_SERVICE, MODE_TIME, MODE_SELFTIME } from './OpNode';

const testTrace = require('./testTrace.json');
import testTrace from './testTrace.json';

const transformedTrace = transformTraceData(testTrace);
const ev = calculateTraceDagEV(transformedTrace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import transformTraceData from '../../../model/transform-trace-data';
import calculateTraceDagEV from './calculateTraceDagEV';

const testTrace = require('./testTrace.json');
import testTrace from './testTrace.json';

const transformedTrace = transformTraceData(testTrace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { mount, shallow } from 'enzyme';
import TraceSpanView from './index';
import transformTraceData from '../../../model/transform-trace-data';

const testTrace = require('../TraceStatistics/tableValuesTestTrace/testTrace.json');
import testTrace from '../TraceStatistics/tableValuesTestTrace/testTrace.json';

const transformedTrace = transformTraceData(testTrace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import generateColor from './generateColor';
import transformTraceData from '../../../model/transform-trace-data';
import { getColumnValuesSecondDropdown, getColumnValues } from './tableValues';

const testTrace = require('./tableValuesTestTrace/testTrace.json');
import testTrace from './tableValuesTestTrace/testTrace.json';

const transformedTrace = transformTraceData(testTrace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { generateDropdownValue, generateSecondDropdownValue } from './generateDr
import transformTraceData from '../../../model/transform-trace-data';
import { getColumnValues } from './tableValues';

const testTrace = require('./tableValuesTestTrace/testTrace.json');
import testTrace from './tableValuesTestTrace/testTrace.json';

const transformedTrace = transformTraceData(testTrace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import PopupSql from './PopupSql';
import transformTraceData from '../../../model/transform-trace-data';
import { getColumnValues, getColumnValuesSecondDropdown } from './tableValues';

const testTrace = require('./tableValuesTestTrace/testTrace.json');
import testTrace from './tableValuesTestTrace/testTrace.json';

const transformedTrace = transformTraceData(testTrace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
import transformTraceData from '../../../model/transform-trace-data';
import { getColumnValues, getColumnValuesSecondDropdown } from './tableValues';

const testTraceNormal = require('./tableValuesTestTrace/testTraceNormal.json');
const traceSpanAmongEachOther = require('./tableValuesTestTrace/spansAmongEachOther.json');
const traceSpanAmongEachOtherGrouped = require('./tableValuesTestTrace/spansAmongEachOtherGrouped.json');
const traceSpanAmongEachOtherGroupedAndSpans = require('./tableValuesTestTrace/spanAmongEachOtherGroupedAndSpans.json');
const traceSpanLongerAsParent = require('./tableValuesTestTrace/spanLongerAsParent.json');
const traceWithOverlappingChildrenLongerThanParent = require('./tableValuesTestTrace/traceWithOverlappingChildrenLongerThanParent.json');
const traceWithTwoNonOverlappingChildren = require('./tableValuesTestTrace/traceWithTwoNonOverlappingChildren.json');
const traceWithOverlappingChildren = require('./tableValuesTestTrace/traceWithOverlappingChildren.json');
const traceWithSingleChildSpanLongerThanParent = require('./tableValuesTestTrace/traceWithSingleChildSpanLongerThanParent.json');
const traceWithThreeShortChildren = require('./tableValuesTestTrace/traceWithThreeShortChildren.json');
const traceWithTwoChildrenStartedAtTraceStart = require('./tableValuesTestTrace/traceWithTwoChildrenStartedAtTraceStart.json');
import testTraceNormal from './tableValuesTestTrace/testTraceNormal.json';
import traceSpanAmongEachOther from './tableValuesTestTrace/spansAmongEachOther.json';
import traceSpanAmongEachOtherGrouped from './tableValuesTestTrace/spansAmongEachOtherGrouped.json';
import traceSpanAmongEachOtherGroupedAndSpans from './tableValuesTestTrace/spanAmongEachOtherGroupedAndSpans.json';
import traceSpanLongerAsParent from './tableValuesTestTrace/spanLongerAsParent.json';
import traceWithOverlappingChildrenLongerThanParent from './tableValuesTestTrace/traceWithOverlappingChildrenLongerThanParent.json';
import traceWithTwoNonOverlappingChildren from './tableValuesTestTrace/traceWithTwoNonOverlappingChildren.json';
import traceWithOverlappingChildren from './tableValuesTestTrace/traceWithOverlappingChildren.json';
import traceWithSingleChildSpanLongerThanParent from './tableValuesTestTrace/traceWithSingleChildSpanLongerThanParent.json';
import traceWithThreeShortChildren from './tableValuesTestTrace/traceWithThreeShortChildren.json';
import traceWithTwoChildrenStartedAtTraceStart from './tableValuesTestTrace/traceWithTwoChildrenStartedAtTraceStart.json';

const transformedTrace = transformTraceData(testTraceNormal);
const transformedTraceSpanAmongEachOthe = transformTraceData(traceSpanAmongEachOther);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ function SpanBar(props: TCommonProps) {
const critcalPathViewBounds = getViewedBounds(each.section_start, each.section_end);
const criticalPathViewStart = critcalPathViewBounds.start;
const criticalPathViewEnd = critcalPathViewBounds.end;
const key = `${each.spanId}-${index}`;
return (
<div
key={index}
key={key}
data-testid="SpanBar--criticalPath"
className="SpanBar--criticalPath"
style={{
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/components/TracePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as React from 'react';
import { Input, InputRef } from 'antd';
import { InputRef } from 'antd';
import { Location, History as RouterHistory } from 'history';
import _clamp from 'lodash/clamp';
import _get from 'lodash/get';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import * as React from 'react';
import { shallow } from 'enzyme';
import { Icon, Input } from 'antd';
import { Input } from 'antd';
import { CloseOutlined } from '@ant-design/icons';
import debounceMock from 'lodash/debounce';

Expand Down
2 changes: 2 additions & 0 deletions packages/jaeger-ui/src/reducers/ddg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ describe('deepDependencyGraph reducers', () => {
state: fetchedState.DONE,
viewModifiers: new Map(),
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const { operation: _op, ...emphasizedPayloadWithoutOp } = emphasizedPayload;
const newState = addViewModifier(operationlessDoneState, emphasizedPayloadWithoutOp);
const expected = _cloneDeep(operationlessDoneState);
Expand Down
8 changes: 4 additions & 4 deletions packages/jaeger-ui/src/utils/TreeNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
// 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.
// limitations under the License

export default class TreeNode<TValue> {
value: TValue;
children: Array<TreeNode<TValue>>;

static iterFunction<TValue>(fn: Function, depth = 0) {
static iterFunction<TValue>(fn: (value: TValue, node: TreeNode<TValue>, depth: number) => any, depth = 0) {
return (node: TreeNode<TValue>) => fn(node.value, node, depth);
}

Expand Down Expand Up @@ -89,7 +89,7 @@ export default class TreeNode<TValue> {
return findPath(this, []);
}

walk(fn: Function, startDepth = 0) {
walk(fn: (spanID: TValue, node: TreeNode<TValue>, depth: number) => void, startDepth = 0) {
type StackEntry = {
node: TreeNode<TValue>;
depth: number;
Expand All @@ -111,7 +111,7 @@ export default class TreeNode<TValue> {
}
}

paths(fn: Function) {
paths(fn: (pathIds: TValue[]) => void) {
type StackEntry = {
node: TreeNode<TValue>;
childIndex: number;
Expand Down
1 change: 1 addition & 0 deletions scripts/generateDepcheckrcJaegerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const { babelConfiguration } = require('../packages/jaeger-ui/test/babel-transform');
Expand Down
1 change: 1 addition & 0 deletions scripts/generateDepcheckrcPlexus.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const getBabelConfig = require('../packages/plexus/babel.config');
Expand Down
1 change: 1 addition & 0 deletions scripts/get-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

// This code will generate changelog entries

/* eslint-disable @typescript-eslint/no-var-requires */
const { readFile } = require('fs').promises;
// eslint-disable-next-line import/no-extraneous-dependencies
const jsdom = require('jsdom');
Expand Down
1 change: 1 addition & 0 deletions scripts/get-tracking-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

// See the comment on `getVersion(..)` for details on what this script does.

/* eslint-disable @typescript-eslint/no-var-requires */
const spawnSync = require('child_process').spawnSync;

const version = require('../package.json').version;
Expand Down

0 comments on commit 0ba8779

Please sign in to comment.