Skip to content

Commit 69816a2

Browse files
author
Kartik Raj
authored
Fix ESlint errors with data science (#15024)
* Fix ESlint errors with data science * Fix prettier errors
1 parent 888020b commit 69816a2

File tree

5 files changed

+14
-54
lines changed

5 files changed

+14
-54
lines changed

src/client/tensorBoard/tensorBoardCodeActionProvider.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,7 @@
22
// Licensed under the MIT License.
33

44
import { inject, injectable } from 'inversify';
5-
import {
6-
CancellationToken,
7-
CodeAction,
8-
CodeActionContext,
9-
CodeActionKind,
10-
CodeActionProvider,
11-
languages,
12-
Selection,
13-
TextDocument
14-
} from 'vscode';
5+
import { CodeAction, CodeActionKind, CodeActionProvider, languages, Selection, TextDocument } from 'vscode';
156
import { IExtensionSingleActivationService } from '../activation/types';
167
import { Commands, PYTHON } from '../common/constants';
178
import { NativeTensorBoard, NativeTensorBoardEntrypoints } from '../common/experiments/groups';
@@ -32,12 +23,7 @@ export class TensorBoardCodeActionProvider implements CodeActionProvider, IExten
3223
}
3324

3425
// eslint-disable-next-line class-methods-use-this
35-
public provideCodeActions(
36-
document: TextDocument,
37-
range: Selection,
38-
_context: CodeActionContext,
39-
_token: CancellationToken
40-
): CodeAction[] {
26+
public provideCodeActions(document: TextDocument, range: Selection): CodeAction[] {
4127
const cursorPosition = range.active;
4228
const { text } = document.lineAt(cursorPosition);
4329
if (containsTensorBoardImport([text])) {

src/client/tensorBoard/tensorBoardCodeLensProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
import { inject, injectable } from 'inversify';
5-
import { CancellationToken, CodeLens, Command, languages, Position, Range, TextDocument } from 'vscode';
5+
import { CodeLens, Command, languages, Position, Range, TextDocument } from 'vscode';
66
import { IExtensionSingleActivationService } from '../activation/types';
77
import { Commands, PYTHON } from '../common/constants';
88
import { NativeTensorBoard, NativeTensorBoardEntrypoints } from '../common/experiments/groups';
@@ -22,7 +22,7 @@ export class TensorBoardCodeLensProvider implements IExtensionSingleActivationSe
2222
}
2323

2424
// eslint-disable-next-line class-methods-use-this
25-
public provideCodeLenses(document: TextDocument, _token: CancellationToken): CodeLens[] {
25+
public provideCodeLenses(document: TextDocument): CodeLens[] {
2626
const command: Command = {
2727
title: TensorBoard.launchNativeTensorBoardSessionCodeLens(),
2828
command: Commands.LaunchTensorBoard

src/client/tensorBoard/tensorBoardSession.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export class TensorBoardSession {
9191
return response === InstallerResponse.Installed;
9292
}
9393

94+
// eslint-disable-next-line class-methods-use-this
9495
private async showFilePicker(): Promise<string | undefined> {
9596
const selection = await window.showOpenDialog({
9697
canSelectFiles: false,
@@ -105,6 +106,7 @@ export class TensorBoardSession {
105106
return undefined;
106107
}
107108

109+
// eslint-disable-next-line class-methods-use-this
108110
private getQuickPickItems(logDir: string | undefined) {
109111
if (logDir) {
110112
const useCwd = {

src/test/tensorBoard/tensorBoardCodeActionProvider.unit.test.ts

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { assert } from 'chai';
55
import { mock } from 'ts-mockito';
66
import * as TypeMoq from 'typemoq';
7-
import { CancellationToken, CodeActionContext, Position, Selection } from 'vscode';
7+
import { Position, Selection } from 'vscode';
88
import { ExperimentService } from '../../client/common/experiments/service';
99
import { IExperimentService } from '../../client/common/types';
1010
import { TensorBoardCodeActionProvider } from '../../client/tensorBoard/tensorBoardCodeActionProvider';
@@ -14,27 +14,18 @@ suite('TensorBoard code action provider', () => {
1414
let experimentService: IExperimentService;
1515
let codeActionProvider: TensorBoardCodeActionProvider;
1616
let selection: TypeMoq.IMock<Selection>;
17-
let context: TypeMoq.IMock<CodeActionContext>;
18-
let token: TypeMoq.IMock<CancellationToken>;
1917

2018
setup(() => {
2119
experimentService = mock(ExperimentService);
2220
codeActionProvider = new TensorBoardCodeActionProvider(experimentService, []);
23-
context = TypeMoq.Mock.ofType<CodeActionContext>();
24-
token = TypeMoq.Mock.ofType<CancellationToken>();
2521
});
2622

2723
test('Provides code action for Python files', () => {
2824
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2925
const document = new MockDocument('import foo\nimport tensorboard', 'foo.py', async (_doc) => true);
3026
selection = TypeMoq.Mock.ofType<Selection>();
3127
selection.setup((s) => s.active).returns(() => new Position(1, 0));
32-
const codeActions = codeActionProvider.provideCodeActions(
33-
document,
34-
selection.object,
35-
context.object,
36-
token.object
37-
);
28+
const codeActions = codeActionProvider.provideCodeActions(document, selection.object);
3829
assert.ok(
3930
codeActions.length > 0,
4031
'Failed to provide code action for Python file containing tensorboard import'
@@ -44,12 +35,7 @@ suite('TensorBoard code action provider', () => {
4435
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4536
const document = new MockDocument('import tensorboard', 'foo.ipynb', async (_doc) => true);
4637
selection.setup((s) => s.active).returns(() => new Position(0, 0));
47-
const codeActions = codeActionProvider.provideCodeActions(
48-
document,
49-
selection.object,
50-
context.object,
51-
token.object
52-
);
38+
const codeActions = codeActionProvider.provideCodeActions(document, selection.object);
5339
assert.ok(
5440
codeActions.length > 0,
5541
'Failed to provide code action for Python ipynb containing tensorboard import'
@@ -59,24 +45,14 @@ suite('TensorBoard code action provider', () => {
5945
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6046
const document = new MockDocument('import foo', 'foo.ipynb', async (_doc) => true);
6147
selection.setup((s) => s.active).returns(() => new Position(0, 0));
62-
const codeActions = codeActionProvider.provideCodeActions(
63-
document,
64-
selection.object,
65-
context.object,
66-
token.object
67-
);
48+
const codeActions = codeActionProvider.provideCodeActions(document, selection.object);
6849
assert.ok(codeActions.length === 0, 'Provided code action for file without tensorboard import');
6950
});
7051
test('Does not provide code action if cursor is not on line containing tensorboard import', () => {
7152
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7253
const document = new MockDocument('import foo\nimport tensorboard', 'foo.py', async (_doc) => true);
7354
selection.setup((s) => s.active).returns(() => new Position(0, 0));
74-
const codeActions = codeActionProvider.provideCodeActions(
75-
document,
76-
selection.object,
77-
context.object,
78-
token.object
79-
);
55+
const codeActions = codeActionProvider.provideCodeActions(document, selection.object);
8056
assert.ok(
8157
codeActions.length === 0,
8258
'Provided code action for file even though cursor was not on line containing import'

src/test/tensorBoard/tensorBoardCodeLensProvider.unit.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import { assert } from 'chai';
55
import { mock } from 'ts-mockito';
6-
import * as TypeMoq from 'typemoq';
7-
import { CancellationToken } from 'vscode';
86
import { ExperimentService } from '../../client/common/experiments/service';
97
import { IExperimentService } from '../../client/common/types';
108
import { TensorBoardCodeLensProvider } from '../../client/tensorBoard/tensorBoardCodeLensProvider';
@@ -13,30 +11,28 @@ import { MockDocument } from '../startPage/mockDocument';
1311
suite('TensorBoard code lens provider', () => {
1412
let experimentService: IExperimentService;
1513
let codeLensProvider: TensorBoardCodeLensProvider;
16-
let token: TypeMoq.IMock<CancellationToken>;
1714

1815
setup(() => {
1916
experimentService = mock(ExperimentService);
2017
codeLensProvider = new TensorBoardCodeLensProvider(experimentService, []);
21-
token = TypeMoq.Mock.ofType<CancellationToken>();
2218
});
2319

2420
test('Provides code lens for Python files', () => {
2521
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2622
const document = new MockDocument('import tensorboard', 'foo.py', async (_doc) => true);
27-
const codeActions = codeLensProvider.provideCodeLenses(document, token.object);
23+
const codeActions = codeLensProvider.provideCodeLenses(document);
2824
assert.ok(codeActions.length > 0, 'Failed to provide code lens for file containing tensorboard import');
2925
});
3026
test('Provides code lens for Python ipynbs', () => {
3127
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3228
const document = new MockDocument('import tensorboard', 'foo.ipynb', async (_doc) => true);
33-
const codeActions = codeLensProvider.provideCodeLenses(document, token.object);
29+
const codeActions = codeLensProvider.provideCodeLenses(document);
3430
assert.ok(codeActions.length > 0, 'Failed to provide code lens for ipynb containing tensorboard import');
3531
});
3632
test('Does not provide code lens if no matching import', () => {
3733
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3834
const document = new MockDocument('import foo', 'foo.ipynb', async (_doc) => true);
39-
const codeActions = codeLensProvider.provideCodeLenses(document, token.object);
35+
const codeActions = codeLensProvider.provideCodeLenses(document);
4036
assert.ok(codeActions.length === 0, 'Provided code lens for file without tensorboard import');
4137
});
4238
});

0 commit comments

Comments
 (0)