Skip to content

Commit

Permalink
fix: fix lint issues in _server, client, and _settingsViewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 9, 2020
1 parent d9a050a commit bc4fb44
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/_server/src/codeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function onCodeActionHandler(
return action;
}

async function genCodeActionsForSuggestions(dictionary: SpellingDictionary) {
async function genCodeActionsForSuggestions(_dictionary: SpellingDictionary) {
const spellCheckerDiags = diagnostics.filter(diag => diag.source === Validator.diagSource);
let diagWord: string | undefined;
for (const diag of spellCheckerDiags) {
Expand Down
12 changes: 6 additions & 6 deletions packages/_settingsViewer/package-lock.json

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

7 changes: 5 additions & 2 deletions packages/_settingsViewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "tsc -p . && webpack --env.production --config webpack.prod.js",
"clean": "rimraf ../client/settingsViewer ./out",
"coverage": "jest --coverage src",
"lint": "eslint 'src/**/*.ts'",
"start:dev": "webpack-dev-server --config webpack.dev.js",
"test": "jest src"
},
Expand Down Expand Up @@ -36,6 +37,7 @@
"@material/select": "^1.1.1",
"@material/tab": "^1.1.1",
"@material/tab-bar": "^1.1.1",
"@types/clone-deep": "^4.0.1",
"@types/jest": "^24.9.0",
"@types/node": "^11.15.4",
"@types/react": "16.7.22",
Expand All @@ -46,8 +48,8 @@
"@typescript-eslint/parser": "^2.19.0",
"awesome-typescript-loader": "^5.2.1",
"clean-webpack-plugin": "^3.0.0",
"clone-deep": "^4.0.1",
"css-loader": "^3.4.2",
"deep-copy": "^1.4.2",
"eslint": "^6.8.0",
"extract-loader": "^3.1.0",
"file-loader": "^4.3.0",
Expand Down Expand Up @@ -85,5 +87,6 @@
"!**/*.map",
"!**/*.test.*",
"!**/*.spec.*"
]
],
"dependencies": {}
}
10 changes: 5 additions & 5 deletions packages/_settingsViewer/src/api/MessageBus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { sampleSettings } from '../test/samples/sampleSettings';
describe('Validate MessageBus', () => {
test('constructor', () => {
const webviewApi: WebviewApi = {
postMessage: (msg: any) => webviewApi,
postMessage: (_msg: any) => webviewApi,
onmessage: undefined,
}

Expand All @@ -30,8 +30,8 @@ describe('Validate MessageBus', () => {
postMessage: (msg: any) => loopBack(webviewApi, msg),
onmessage: undefined,
}
const onRequestConfigurationMessage = jest.fn((msg: RequestConfigurationMessage) => {});
const onConfigurationChangeMessage = jest.fn((msg: ConfigurationChangeMessage) => {});
const onRequestConfigurationMessage = jest.fn((_msg: RequestConfigurationMessage) => {});
const onConfigurationChangeMessage = jest.fn((_msg: ConfigurationChangeMessage) => {});
const bus = new MessageBus(webviewApi);
const listenerA = bus.listenFor("RequestConfigurationMessage", onRequestConfigurationMessage);
const listenerB = bus.listenFor('ConfigurationChangeMessage', onConfigurationChangeMessage);
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('Validate MessageBus', () => {
postMessage: (msg: any) => loopBack(webviewApi, msg),
onmessage: undefined,
}
const bus = new MessageBus(webviewApi);
new MessageBus(webviewApi);
expect(() => webviewApi.onmessage!({ data: {} })).not.toThrow();
});
});
Expand All @@ -77,4 +77,4 @@ function loopBack(webviewApi: WebviewApi, msg: any): WebviewApi {
webviewApi.onmessage({ data: msg });
}
return webviewApi;
}
}
12 changes: 11 additions & 1 deletion packages/_settingsViewer/src/api/message.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { isConfigurationChangeMessage, ConfigurationChangeMessage, isMessage, SelectFileMessage, isSelectFileMessage, SelectFolderMessage, isSelectFolderMessage, isEnableLanguageIdMessage, EnableLanguageIdMessage, EnableLocalMessage, isEnableLocalMessage } from './message';
import {
isConfigurationChangeMessage,
ConfigurationChangeMessage,
isMessage,
SelectFileMessage,
isSelectFileMessage,
SelectFolderMessage,
isSelectFolderMessage,
EnableLocalMessage,
isEnableLocalMessage,
} from './message';
import { sampleSettings } from '../test/samples/sampleSettings';


Expand Down
2 changes: 1 addition & 1 deletion packages/_settingsViewer/src/api/utils/Comparable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Validate Comparable', () => {
});

interface Sample {
id: number,
id: number;
name: string;
value: number;
maybe: number | undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/_settingsViewer/src/test/fixtures/AppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { AppState } from '../../viewer/AppState';
import { MessageBus, Message, isMessage } from '../../api';
import { WebviewApi } from '../../api/WebviewApi';
import { sampleSettings } from '../samples/sampleSettings';
// import dcopy from 'deep-copy'; // Does not work because there isn't really a default.
const dcopy: <T>(v: T)=>T = require('deep-copy');
import dcopy = require('clone-deep');


export class AppStateFixture extends AppState {
_webviewApi: WebviewApi;
Expand Down
4 changes: 2 additions & 2 deletions packages/_settingsViewer/src/viewer/AppState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Validate AppState', () => {

test('actionSelectFolder', () => {
const appState = getSampleAppState(sampleSettings);
const uri = 'file:///Users/cspell/projects/clones/ripgrep';
// const uri = 'file:///Users/cspell/projects/clones/ripgrep';
const folderName = 'ripgrep';
appState.actionSelectFolder(folderName);
expect(appState.activeWorkspaceFolder).toBe(folderName);
Expand All @@ -63,7 +63,7 @@ describe('Validate AppState', () => {

function getSampleAppState(settings: Settings): AppState {
const webviewApi: WebviewApi = {
postMessage: (msg: any) => webviewApi,
postMessage: (_msg: any) => webviewApi,
onmessage: undefined,
};
const msgBus = new MessageBus(webviewApi);
Expand Down
14 changes: 6 additions & 8 deletions packages/_settingsViewer/src/viewer/AppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export interface State {
}

export interface FoundInConfig<T> {
value: Exclude<T, undefined>,
source: ConfigSource
value: Exclude<T, undefined>;
source: ConfigSource;
}

type InheritedFromSource<T> = {
value: Exclude<T, undefined>,
value: Exclude<T, undefined>;
source: ConfigSource;
}

Expand Down Expand Up @@ -166,7 +166,7 @@ export class AppState implements State {
return workspace && workspace.textDocuments || [];
}

@computed get documentSelection(): { label: string, value: string }[] {
@computed get documentSelection(): { label: string; value: string }[] {
return this.documents.map(doc => ({ label: doc.fileName, value: doc.uri }));
}

Expand All @@ -190,7 +190,7 @@ export class AppState implements State {
this.debugMode = isEnabled;
}

private isLocalEnabledEx(field: ConfigTarget, code: LocalId):InheritedFromSource<boolean> {
private isLocalEnabledEx(field: ConfigTarget, code: LocalId): InheritedFromSource<boolean> {
const config = this.settings.configs[field];
const source = config.inherited.locals || field;
const locals = config.locals;
Expand Down Expand Up @@ -236,8 +236,6 @@ export class AppState implements State {
}
}

function notUndefined<T>(a : T): a is Exclude<T, undefined> {
function notUndefined<T>(a: T): a is Exclude<T, undefined> {
return a !== undefined;
}


2 changes: 2 additions & 0 deletions packages/client/src/util/pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function extract<T, K extends keyof T, K2 extends NestedKey<T, K>, K3 ext
export function extract<T, K extends keyof T, K2 extends NestedKey<T, K>, K3 extends NestedKey<Nested<T, K>, K2>, K4 extends NestedKey<Nested<Nested<T, K>, K2>, K3>>(key: K, k2: K2, k3: K3, k4: K4): (t: T | undefined) => Nested<Nested<Nested<T, K>, K2>, K3>[K4] | undefined;
export function extract<T, K extends keyof T>(key: K): (t: T | undefined) => T[K] | undefined {
if (arguments.length > 1) {
// eslint-disable-next-line prefer-rest-params
const args = [...arguments];
return (t: T | undefined) => {
let v = t as any;
Expand All @@ -36,6 +37,7 @@ export function pipe<T, R, S, A, B>(t: T, fn: (t: T) => R, fn2: (t: R) => S, fn3
export function pipe<T, R, S, A, B, C>(t: T, fn: (t: T) => R, fn2: (t: R) => S, fn3: (t: S) => A, fn4: (t: A) => B, fn5: (t: B) => C): C;
export function pipe<T>(t: T): T {
if (arguments.length > 1) {
// eslint-disable-next-line prefer-rest-params
const fns = [...arguments].slice(1) as ((v: any) => any)[];
let v = t as any;
for (const fn of fns) {
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/util/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const watch = require('node-watch');

export type Events = 'update' | 'remove' | 'error';
Expand Down

0 comments on commit bc4fb44

Please sign in to comment.