Skip to content

Commit

Permalink
Revert "Add ESLint and fix problems"
Browse files Browse the repository at this point in the history
This reverts commit 0f9d15f.
  • Loading branch information
mark-wiemer committed Jul 18, 2022
1 parent 8ce8989 commit 0b42723
Show file tree
Hide file tree
Showing 26 changed files with 171 additions and 1,662 deletions.
17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

1,527 changes: 48 additions & 1,479 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@
"format": "npm run format_inner -- --check .",
"format_fix": "npm run format_inner -- --write .",
"format_inner": "prettier",
"lint": "npm run quality && npm run format && npm run packagejson",
"lint": "npm run format && npm run packagejson",
"packagejson": "sort-package-json --check",
"packagejson_fix": "sort-package-json",
"prepare": "husky install",
"quality": "npm run quality_inner -- src && echo ✅ No problems",
"quality_fix": "npm run quality_inner -- --fix src",
"quality_inner": "eslint --ext ts --max-warnings=0",
"pretest": "npm run compile",
"test": "npm run test_unit && npm run test_grammar_inner",
"test_grammar": "npm run compile_grammar && npm run test_grammar_inner",
Expand Down Expand Up @@ -277,7 +274,6 @@
"lint-staged": {
"*": "prettier --check",
"src/*": [
"npm run quality_inner",
"tsc --noEmit"
],
"package.json": "npm run packagejson"
Expand All @@ -293,10 +289,7 @@
"@types/mocha": "^9.1.1",
"@types/node": "^14.14.31",
"@types/vscode": "^1.30.0",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/parser": "^5.29.0",
"@vscode/test-electron": "^1.6.1",
"eslint": "^8.18.0",
"fs-extra": "^9.1.0",
"glob": "^7.1.6",
"husky": "^8.0.1",
Expand All @@ -306,7 +299,7 @@
"prettier": "^2.6.1",
"sort-package-json": "^1.57.0",
"source-map-support": "^0.5.19",
"typescript": "~4.7.4",
"typescript": "^3.4.3",
"vscode-tmgrammar-test": "^0.1.1"
},
"engines": {
Expand Down
8 changes: 3 additions & 5 deletions src/common/codeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ export class CodeUtil {
* @param original Original line of code
*/
public static purify(original: string): string {
if (!original) {
return '';
}
if (!original) return '';
return original
.replace(/;.+/, '')
.replace(/".*?"/g, '""') // replace string literals with empty string literal
Expand All @@ -23,7 +21,7 @@ export class CodeUtil {
* or another array to concat to the end of @see array
*/
public static join(array: unknown[], items: unknown) {
if (!array || !items) {
if (array == undefined || items == undefined) {
return;
}
if (Array.isArray(items)) {
Expand All @@ -42,7 +40,7 @@ export class CodeUtil {

let regs = [];
let temp: RegExpExecArray;
while (!!(temp = regex.exec(text))) {
while ((temp = regex.exec(text)) != null) {
regs.push(temp);
}

Expand Down
10 changes: 4 additions & 6 deletions src/common/fileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export class FileManager {
}

private static check(path: string) {
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
if (!fs.existsSync(path)) fs.mkdirSync(path);
}

public static show(fileName: string) {
Expand Down Expand Up @@ -55,7 +53,7 @@ export class FileManager {
const recordPath = `${this.storagePath}/${fileName}`;
this.check(this.storagePath);
this.check(path.resolve(recordPath, '..'));
if (model === FileModel.write) {
if (model == FileModel.WRITE) {
fs.writeFileSync(recordPath, `${content}`, {
encoding: 'utf8',
});
Expand All @@ -70,6 +68,6 @@ export class FileManager {
}

export enum FileModel {
write,
append,
WRITE,
APPEND,
}
6 changes: 4 additions & 2 deletions src/common/global.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import * as vscode from 'vscode';

export class Global {
public static configPrefix = 'ahk++';
public static CONFIG_PREFIX = 'ahk++';
private static statusBarItem: vscode.StatusBarItem;
/**
* get configuration from vscode setting.
* @param key config key
*/
public static getConfig<T>(key: string): T {
return vscode.workspace.getConfiguration(this.configPrefix).get<T>(key);
return vscode.workspace
.getConfiguration(this.CONFIG_PREFIX)
.get<T>(key);
}

public static updateStatusBarItems(text: string) {
Expand Down
10 changes: 3 additions & 7 deletions src/debugger/debugDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ export class DebugDispatcher extends EventEmitter {
*/
public async start(args: LaunchRequestArguments) {
let { runtime, dbgpSettings = {} } = args;
// names may used by AHK, let's not change them for now
// eslint-disable-next-line @typescript-eslint/naming-convention
const { max_children, max_data } = {
// eslint-disable-next-line @typescript-eslint/naming-convention
max_children: 300,
// eslint-disable-next-line @typescript-eslint/naming-convention
max_data: 131072,
...dbgpSettings,
};
Expand Down Expand Up @@ -201,12 +197,12 @@ export class DebugDispatcher extends EventEmitter {

const variables = await this.getVariable(
frameId,
VarScope.local,
VarScope.LOCAL,
variableName,
);
if (variables.length === 0) {
if (variables.length == 0) {
return null;
} else if (variables.length === 1) {
} else if (variables.length == 1) {
return variables[0].value;
} else {
const ahkVar = this.variableHandler.getVarByName(variableName);
Expand Down
8 changes: 4 additions & 4 deletions src/debugger/debugServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class DebugServer extends EventEmitter {
}

public start(): DebugServer {
const end = 0;
const END = 0;
let tempData: Buffer;
this.proxyServer = new Net.Server()
.listen(this.port)
Expand All @@ -24,7 +24,7 @@ export class DebugServer extends EventEmitter {
tempData = tempData
? Buffer.concat([tempData, chunk])
: chunk;
if (tempData[tempData.length - 1] === end) {
if (tempData[tempData.length - 1] == END) {
this.process(tempData.toString());
tempData = null;
}
Expand Down Expand Up @@ -63,11 +63,11 @@ export class DebugServer extends EventEmitter {
});
public process(data: string) {
data = data.substr(data.indexOf('<?xml'));
if (data.indexOf(this.header) === -1) {
if (data.indexOf(this.header) == -1) {
data = this.header + data;
}
for (const part of data.split(this.header)) {
if (!part?.trim()) {
if (null == part || part.trim() == '') {
continue;
}
const xmlString = this.header + part;
Expand Down
30 changes: 15 additions & 15 deletions src/debugger/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { VscodeScope } from './struct/scope';
* This interface describes the mock-debug specific launch attr
* (which are not part of the Debug Adapter Protocol).
* The schema for these attr lives in the package.json of the mock-debug extension.
* The interface should always match the package.json.
* The interface should always match this schema.
*/
export interface LaunchRequestArguments
extends DebugProtocol.LaunchRequestArguments {
Expand All @@ -26,9 +26,7 @@ export interface LaunchRequestArguments
/** An absolute path to the AutoHotkey.exe. */
runtime: string;
dbgpSettings: {
// eslint-disable-next-line @typescript-eslint/naming-convention
max_children: number;
// eslint-disable-next-line @typescript-eslint/naming-convention
max_data: number;
};
}
Expand All @@ -37,7 +35,7 @@ export interface LaunchRequestArguments
* debug session for vscode.
*/
export class DebugSession extends LoggingDebugSession {
private static threadId = 1;
private static THREAD_ID = 1;
private dispatcher: DebugDispatcher;

public constructor() {
Expand All @@ -50,7 +48,9 @@ export class DebugSession extends LoggingDebugSession {
this.dispatcher = new DebugDispatcher();
this.dispatcher
.on('break', (reason: string) => {
this.sendEvent(new StoppedEvent(reason, DebugSession.threadId));
this.sendEvent(
new StoppedEvent(reason, DebugSession.THREAD_ID),
);
})
.on('breakpointValidated', (bp: DebugProtocol.Breakpoint) => {
this.sendEvent(
Expand Down Expand Up @@ -178,23 +178,23 @@ export class DebugSession extends LoggingDebugSession {
args: DebugProtocol.PauseArguments,
request?: DebugProtocol.Request,
): void {
this.dispatcher.sendComand(Continue.break);
this.dispatcher.sendComand(Continue.BREAK);
this.sendResponse(response);
}

protected continueRequest(
response: DebugProtocol.ContinueResponse,
args: DebugProtocol.ContinueArguments,
): void {
this.dispatcher.sendComand(Continue.run);
this.dispatcher.sendComand(Continue.RUN);
this.sendResponse(response);
}

protected nextRequest(
response: DebugProtocol.NextResponse,
args: DebugProtocol.NextArguments,
): void {
this.dispatcher.sendComand(Continue.stepOver);
this.dispatcher.sendComand(Continue.STEP_OVER);
this.sendResponse(response);
}

Expand All @@ -203,7 +203,7 @@ export class DebugSession extends LoggingDebugSession {
args: DebugProtocol.StepInArguments,
request?: DebugProtocol.Request,
): void {
this.dispatcher.sendComand(Continue.stepInto);
this.dispatcher.sendComand(Continue.STEP_INTO);
this.sendResponse(response);
}

Expand All @@ -212,13 +212,13 @@ export class DebugSession extends LoggingDebugSession {
args: DebugProtocol.StepOutArguments,
request?: DebugProtocol.Request,
): void {
this.dispatcher.sendComand(Continue.stepOut);
this.dispatcher.sendComand(Continue.STEP_OUT);
this.sendResponse(response);
}

protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
response.body = {
threads: [new Thread(DebugSession.threadId, 'main thread')],
threads: [new Thread(DebugSession.THREAD_ID, 'main thread')],
};
this.sendResponse(response);
}
Expand All @@ -230,10 +230,10 @@ export class DebugSession extends LoggingDebugSession {
response.body = {
targets: [
...(await this.dispatcher.listVariables({
variablesReference: VscodeScope.local,
variablesReference: VscodeScope.LOCAL,
})),
...(await this.dispatcher.listVariables({
variablesReference: VscodeScope.global,
variablesReference: VscodeScope.GLOBAL,
})),
].map((variable) => {
return {
Expand All @@ -252,13 +252,13 @@ export class DebugSession extends LoggingDebugSession {
): Promise<void> {
const exp = args.expression.split('=');
let reply: string;
if (exp.length === 1) {
if (exp.length == 1) {
reply = await this.dispatcher.getVariableByEval(args.expression);
} else {
this.dispatcher.setVariable({
name: exp[0],
value: exp[1],
variablesReference: VscodeScope.local,
variablesReference: VscodeScope.LOCAL,
});
reply = `execute: ${args.expression}`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/handler/breakpointHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class BreakPointHandler {
new Source(basename(path), path),
);
const lineText = sourceLines[sourceBreakpoint.line];
if (lineText && lineText.trim().charAt(0) !== ';') {
if (lineText && lineText.trim().charAt(0) != ';') {
breakPoint.verified = true;
}
callback(breakPoint);
Expand Down
4 changes: 1 addition & 3 deletions src/debugger/handler/commandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export class CommandHandler {

public callback(transId: string, response: DbgpResponse) {
const fun = this.commandCallback[transId];
if (fun) {
fun(response);
}
if (fun) fun(response);
this.commandCallback[transId] = null;
}
}
Loading

0 comments on commit 0b42723

Please sign in to comment.