Skip to content

Commit

Permalink
[REFACTOR] tslint -> eslint (#336)
Browse files Browse the repository at this point in the history
* [REFACTOR] tslint -> eslint

* "version": "1.1.8"
  • Loading branch information
tomer-epstein authored Aug 3, 2020
1 parent f392831 commit 170c1a7
Show file tree
Hide file tree
Showing 27 changed files with 146 additions and 171 deletions.
6 changes: 6 additions & 0 deletions backend/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
out
coverage
test/resources
*.d.ts
43 changes: 43 additions & 0 deletions backend/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"root": true,
"plugins": ["@typescript-eslint"],
"env": {
"browser": true,
"node": true
},
// Based on https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#recommended-configs
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
// prettier must be last because it turns off previous rules
"prettier"
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6,
"project": ["./tsconfig.json"],
"tsconfigRootDir": "."
},
"rules": {
"semi": "error",
"no-extra-semi": "error",
"no-eval": "error",
"@typescript-eslint/prefer-readonly": "error",
// TODO review each exclusion and fix issues if needed
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off",
"no-async-promise-executor": "off",
"no-irregular-whitespace": "off",
"prefer-rest-params": "off",
"prefer-spread": "off"
}
}
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
dummy
LICENSE

# Optional eslint cache
.eslintcache
19 changes: 11 additions & 8 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yeoman-ui",
"version": "1.1.7",
"version": "1.1.8",
"displayName": "Application Wizard",
"publisher": "SAPOS",
"author": {
Expand Down Expand Up @@ -142,7 +142,8 @@
"test": "nyc mocha -p tsconfig.json --opts ./mocha.opts",
"ws:run": "node ./out/src/webSocketServer/index.js",
"ws:egRun": "node ./out/src/webSocketServer/exploreGensIndex.js",
"lint": "tslint '*/*.{ts,tsx}' -c ./tslint.yml"
"lint": "eslint . --ext .ts,.tsx --cache",
"lint:fix": "eslint . --ext .ts,.tsx --cache --fix"
},
"dependencies": {
"@sap-devx/webview-rpc": "^0.2.2",
Expand All @@ -153,12 +154,12 @@
"fs-extra": "^8.1.0",
"humanize-string": "^1.0.2",
"lodash": "^4.17.16",
"npm-registry-fetch": "8.1.1",
"object-hash": "^2.0.3",
"strip-ansi": "^6.0.0",
"titleize": "^1.0.1",
"ws": "^7.2.5",
"yeoman-environment": "2.8.0",
"npm-registry-fetch": "8.1.1"
"yeoman-environment": "2.8.0"
},
"devDependencies": {
"@types/npm-registry-fetch": "8.0.0",
Expand All @@ -172,6 +173,12 @@
"@types/sinon": "^7.5.0",
"@types/ws": "^6.0.3",
"@types/yeoman-environment": "2.3.3",
"@typescript-eslint/parser": "^2.30.0",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"prettier": "^2.0.5",
"typescript": "^3.9.7",
"bufferutil": "^4.0.1",
"chai": "^4.2.0",
"copy-webpack-plugin": "^5.0.5",
Expand All @@ -180,10 +187,6 @@
"sinon": "^7.5.0",
"ts-loader": "^6.2.1",
"ts-node": "^8.9.1",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^3.8.2",
"utf-8-validate": "^5.0.2",
"string-replace-loader": "^2.1.1",
"vsce": "^1.73.0",
Expand Down
12 changes: 6 additions & 6 deletions backend/src/exploregens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export enum GenState {
installing = "installing",
notInstalled = "notInstalled",
installed = "installed"
};
}

export class ExploreGens {
public static getInstallationLocation(wsConfig: any) {
Expand All @@ -23,14 +23,14 @@ export class ExploreGens {

private static readonly INSTALLATION_LOCATION = "ApplicationWizard.installationLocation";

private logger: IChildLogger;
private readonly logger: IChildLogger;
private rpc: IRpc;
private gensBeingHandled: any[];
private gensBeingHandled: any[]; // eslint-disable-line @typescript-eslint/prefer-readonly
private cachedInstalledGeneratorsPromise: Promise<string[]>;
private context: any;
private vscode: any;
private readonly context: any;
private readonly vscode: any;
private isInTheiaCached: boolean;
private npmGlobalPathPromise: Promise<string>;
private npmGlobalPathPromise: Promise<string>; // eslint-disable-line @typescript-eslint/prefer-readonly

private readonly theiaCommands: string[] = ["theia.open", "preferences:open", "keymaps:open", "workspace:openRecent"];
private readonly GLOBAL_ACCEPT_LEGAL_NOTE = "global.exploreGens.acceptlegalNote";
Expand Down
2 changes: 1 addition & 1 deletion backend/src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class GeneratorFilter {
}

public static hasIntersection(array1: string[], array2: string[]) {
return (_.isEmpty(array1) || !_.isEmpty(_.intersection(array1, array2)))
return (_.isEmpty(array1) || !_.isEmpty(_.intersection(array1, array2)));
}

private constructor(public readonly types: string[], public readonly categories: string[]) {}
Expand Down
10 changes: 5 additions & 5 deletions backend/src/logger/logger-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ERROR_LOGGER_NOT_INITIALIZED = 'Logger has not yet been initialized
*/
let logger: any;

function isInitialized() :boolean {
function isInitialized(): boolean {
return (logger !== undefined ) ? true : false;
}

Expand All @@ -30,22 +30,22 @@ function isInitialized() :boolean {
*
* @returns { IVSCodeExtLogger }
*/
export function getLogger() : IVSCodeExtLogger {
export function getLogger(): IVSCodeExtLogger {
if (isInitialized() === false) {
throw Error(ERROR_LOGGER_NOT_INITIALIZED);
}
return logger;
}

export function getClassLogger(className: string) : IChildLogger {
export function getClassLogger(className: string): IChildLogger {
return getLogger().getChildLogger({label:className});
}

export function getYeomanUILibraryLogger() : IChildLogger {
export function getYeomanUILibraryLogger(): IChildLogger {
return getLibraryLogger(YEOMAN_UI_LOGGER_NAME);
}

function getLibraryLogger(libraryName: string) : IChildLogger {
function getLibraryLogger(libraryName: string): IChildLogger {
return getLogger().getChildLogger({label:libraryName});
}

Expand Down
6 changes: 3 additions & 3 deletions backend/src/output-channel-log.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { YouiLog } from "./youi-log";
import { YeomanUIPanel } from "./panels/YeomanUIPanel";
const stripAnsi = require("strip-ansi");
import stripAnsi = require("strip-ansi");

export class OutputChannelLog implements YouiLog {
public constructor(private channelName: string) {}
public constructor(private readonly channelName: string) {}

public log(value: string): void {
this.appendLine(value);
Expand Down Expand Up @@ -32,7 +32,7 @@ export class OutputChannelLog implements YouiLog {
public skip(value: string): void {
this.appendLine(value);
}
public showOutput():boolean {
public showOutput(): boolean {
YeomanUIPanel.getOutputChannel(this.channelName).show();
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/panels/AbstractWebviewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export abstract class AbstractWebviewPanel {
protected constructor(context: vscode.ExtensionContext) {
this.extensionPath = context.extensionPath;
this.mediaPath = path.join(context.extensionPath, "dist", "media");
this.htmlFileName = "index.html"
this.htmlFileName = "index.html";
this.logger = getLogger();
this.disposables = [];
this.context = context;
Expand All @@ -42,7 +42,7 @@ export abstract class AbstractWebviewPanel {
public setWebviewPanel(webviewPanel: vscode.WebviewPanel, state?: any) {
this.webViewPanel = webviewPanel;
this.state = state;
};
}

protected createWebviewPanel(): vscode.WebviewPanel {
return vscode.window.createWebviewPanel(
Expand Down
2 changes: 1 addition & 1 deletion backend/src/panels/ExploreGensPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ExploreGensPanel extends AbstractWebviewPanel {
this.initWebviewPanel();
}

private exploreGens: ExploreGens;
private readonly exploreGens: ExploreGens;
public constructor(context: vscode.ExtensionContext) {
super(context);
this.viewType = "exploreGens";
Expand Down
2 changes: 1 addition & 1 deletion backend/src/panels/YeomanUIPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class YeomanUIPanel extends AbstractWebviewPanel {
}

private async showOpenDialog(currentPath: string, canSelectFiles: boolean): Promise<string> {
const canSelectFolders: boolean = !canSelectFiles;
const canSelectFolders = !canSelectFiles;

let uri;
try {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/replayUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ReplayUtils {
}

public isReplaying: boolean;
private answersCache: Map<string, Environment.Adapter.Answers>;
private readonly answersCache: Map<string, Environment.Adapter.Answers>;
private replayStack: Environment.Adapter.Answers[];
private replayQueue: Environment.Adapter.Answers[];
private numOfSteps: number;
Expand Down
8 changes: 4 additions & 4 deletions backend/src/vscode-youi-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { GeneratorFilter, GeneratorType } from './filter';

export class VSCodeYouiEvents implements YouiEvents {
private webviewPanel: vscode.WebviewPanel;
private genFilter: GeneratorFilter;
private messages: any;
private readonly genFilter: GeneratorFilter;
private readonly messages: any;
private resolveFunc: any;

constructor(rpc : IRpc, webviewPanel: vscode.WebviewPanel, genFilter: GeneratorFilter, messages: any) {
constructor(rpc: IRpc, webviewPanel: vscode.WebviewPanel, genFilter: GeneratorFilter, messages: any) {
this.webviewPanel = webviewPanel;
this.genFilter = genFilter;
this.messages = messages;
Expand Down Expand Up @@ -55,7 +55,7 @@ export class VSCodeYouiEvents implements YouiEvents {
this.resolveInstallingProgress();

if (success) {
const addToWorkspace: string = "Add to Workspace";
const addToWorkspace = "Add to Workspace";
const openInNewWorkspace: any = "Open in New Workspace";
const items: string[] = [];

Expand Down
4 changes: 2 additions & 2 deletions backend/src/webSocketServer/exploreGensIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ExploreGensWebSocketServer {

this.rpc = new RpcExtensionWebSockets(ws);
//TODO: Use RPC to send it to the browser log (as a collapsed pannel in Vue)
const childLogger = { debug: () => { }, error: () => { }, fatal: () => { }, warn: () => { }, info: () => { }, trace: () => { }, getChildLogger: () => { return {} as IChildLogger; } };
const childLogger = { debug: () => {/* do nothing */}, error: () => {/* do nothing */}, fatal: () => {/* do nothing */}, warn: () => {/* do nothing */}, info: () => {/* do nothing */}, trace: () => {/* do nothing */}, getChildLogger: () => { return {} as IChildLogger; } };
const context = {
globalState: {
get: () => true,
Expand All @@ -41,7 +41,7 @@ class ExploreGensWebSocketServer {
setStatusBarMessage: () => {
return {
dispose: () => true
}
};
}
},
workspace: {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/webSocketServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class YeomanUIWebSocketServer {
this.rpc = new RpcExtensionWebSockets(ws);
//TODO: Use RPC to send it to the browser log (as a collapsed pannel in Vue)
const logger: YouiLog = new ServerLog(this.rpc);
const childLogger = {debug: () => {}, error: () => {}, fatal: () => {}, warn: () => {}, info: () => {}, trace: () => {}, getChildLogger: () => {return {} as IChildLogger;}};
const childLogger = {debug: () => {/* do nothing */}, error: () => {/* do nothing */}, fatal: () => {/* do nothing */}, warn: () => {/* do nothing */}, info: () => {/* do nothing */}, trace: () => {/* do nothing */}, getChildLogger: () => {return {} as IChildLogger;}};
const youiEvents: YouiEvents = new ServerYouiEvents(this.rpc);
this.yeomanui = new YeomanUI(this.rpc, youiEvents, logger, childLogger as IChildLogger, {genFilter: GeneratorFilter.create(), messages: backendMessages});
this.yeomanui.registerCustomQuestionEventHandler("folder-browser", "getPath", this.mockFolderDialog.bind(this));
Expand Down
8 changes: 4 additions & 4 deletions backend/src/webSocketServer/server-log.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { YouiLog } from "../youi-log";
import { RpcCommon } from "@sap-devx/webview-rpc/out.ext/rpc-common";
const stripAnsi = require("strip-ansi");
import stripAnsi = require("strip-ansi");

export class ServerLog implements YouiLog {
private rpc: RpcCommon;
private isOutputVisible: boolean = false;
private readonly rpc: RpcCommon;
private isOutputVisible = false;
/**
*
*/
constructor(rpc : RpcCommon) {
constructor(rpc: RpcCommon) {
this.rpc = rpc;
}
public log(str: string): void {
Expand Down
6 changes: 3 additions & 3 deletions backend/src/webSocketServer/server-youi-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { YouiEvents } from "../youi-events";
import { RpcCommon } from "@sap-devx/webview-rpc/out.ext/rpc-common";

export class ServerYouiEvents implements YouiEvents {
private rpc: RpcCommon;
private readonly rpc: RpcCommon;

constructor(rpc : RpcCommon) {
constructor(rpc: RpcCommon) {
this.rpc = rpc;
}

selectFolder(): void {
this.rpc.invoke("selectOutputFolder");
}

doGeneratorDone(suceeded: boolean, message: string, targetPath: string = ""): void {
doGeneratorDone(suceeded: boolean, message: string, targetPath = ""): void {
this.rpc.invoke("generatorDone", [suceeded, message, targetPath]);
}

Expand Down
Loading

0 comments on commit 170c1a7

Please sign in to comment.