Skip to content

Commit 0b006dd

Browse files
Copilottolauwae
andauthored
Fix auto-fixable and easy ESLint errors (#56)
* Initial plan * Initial plan for fixing ESLint errors Co-authored-by: tolauwae <31000331+tolauwae@users.noreply.github.com> * Fix all 137 ESLint errors: auto-fix indentation, fix unused vars, refactor async promises, convert this aliases, suppress intentional any usage, disable namespace rule Co-authored-by: tolauwae <31000331+tolauwae@users.noreply.github.com> * Remove accidentally committed test build artifacts and add to .gitignore Co-authored-by: tolauwae <31000331+tolauwae@users.noreply.github.com> * Revert medium and should-not-fix changes, keep only auto-fixable and easy ESLint fixes Co-authored-by: tolauwae <31000331+tolauwae@users.noreply.github.com> * Revert .gitignore change - the test[A-Za-z0-9]*/ pattern was only added to clean up accidentally committed build artifacts Co-authored-by: tolauwae <31000331+tolauwae@users.noreply.github.com> * Restore original names for SimpleScheduler and levels in Scheduler.ts Co-authored-by: tolauwae <31000331+tolauwae@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tolauwae <31000331+tolauwae@users.noreply.github.com>
1 parent 6fc2a05 commit 0b006dd

File tree

18 files changed

+109
-108
lines changed

18 files changed

+109
-108
lines changed

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export default [
1212
'@stylistic/js': stylisticJs
1313
}, rules: {
1414
'@stylistic/js/indent': ['error', 4, { "SwitchCase": 1 }],
15-
'@typescript-eslint/no-wrapper-object-types': 'off'
15+
'@typescript-eslint/no-wrapper-object-types': 'off',
16+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }]
1617
}
1718
},
1819
{files: ["**/*.{js,mjs,cjs,ts}"]},

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/framework/Archiver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class Archiver {
1414
}
1515

1616
public extend(key: string, value: string | number) {
17-
if (!this.information.hasOwnProperty(key)) {
17+
if (!Object.prototype.hasOwnProperty.call(this.information, key)) {
1818
this.information[key] = [];
1919
}
2020
this.information[key].push(value);

src/framework/Framework.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@ import {TestScenario} from './scenario/TestScenario';
44

55
import {TestbedSpecification} from '../testbeds/TestbedSpecification';
66

7-
import {StyleType} from '../reporter';
8-
import {styling} from '../reporter/Style';
97
import {SuiteResult} from '../reporter/Results';
108
import {Reporter} from '../reporter/Reporter';
119
import {Outcome} from "../reporter/describers/Describer";
1210

13-
interface DependenceTree {
14-
test: TestScenario;
15-
children: DependenceTree[];
16-
}
17-
1811
export interface TesteeOptions {
1912
disabled?: boolean;
2013
timeout?: number;

src/framework/Scheduler.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Suite} from './Framework';
22
import {TestScenario} from './scenario/TestScenario';
3-
import {Test} from 'mocha';
43

54
export abstract class Scheduler {
65
public abstract readonly identifier: string;
@@ -24,7 +23,7 @@ export class NoScheduler implements Scheduler {
2423
}
2524
}
2625

27-
class SimpleScheduler implements Scheduler {
26+
export class SimpleScheduler implements Scheduler {
2827
identifier = 'sort on program';
2928

3029
public sequential(suite: Suite): TestScenario[] {
@@ -54,7 +53,7 @@ export class HybridScheduler implements Scheduler {
5453
return flatVertical(forest).flat().reverse(); //.flatMap((tree) => flatVertical(tree));
5554
}
5655

57-
public parallel(suite: Suite, cores: number): TestScenario[][] {
56+
public parallel(suite: Suite, _cores: number): TestScenario[][] {
5857
const forest: TestScenario[][][] = trees(suite.scenarios);
5958
return flatVertical(forest)
6059
}

src/framework/Testee.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class Testee { // TODO unified with testbed interface
172172
try {
173173
await timeout<object | void>(`uploading module`, testee.timeout, testee.bed()!.sendRequest(new SourceMap.Mapping(), Message.updateModule(compiled.file))).catch((e) => Promise.reject(e));
174174
testee.current = description.program;
175-
} catch (e) {
175+
} catch {
176176
await testee.initialize(description.program, description.args ?? []).catch((o) => Promise.reject(o));
177177
}
178178
}).catch((e: Error | string) => {

src/framework/Verifier.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,34 +89,34 @@ export class Verifier {
8989
private expectBehaviour(actual: any, previous: any, behaviour: Behaviour): StepOutcome {
9090
const result: StepOutcome = new StepOutcome(this.step);
9191
switch (behaviour) {
92-
case Behaviour.unchanged:
93-
if (deepEqual(actual, previous)) {
94-
result.update(Outcome.succeeded);
95-
} else {
96-
result.update(Outcome.failed, `Expected ${actual} to equal ${previous}`);
97-
}
98-
break;
99-
case Behaviour.changed:
100-
if (!deepEqual(actual, previous)) {
101-
result.update(Outcome.succeeded);
102-
} else {
103-
result.update(Outcome.failed, `Expected ${actual} to be different from ${previous}`);
104-
}
105-
break;
106-
case Behaviour.increased:
107-
if (actual > previous) {
108-
result.update(Outcome.succeeded);
109-
} else {
110-
result.update(Outcome.failed, `Expected ${actual} to be greater than ${previous}`);
111-
}
112-
break;
113-
case Behaviour.decreased:
114-
if (actual < previous) {
115-
result.update(Outcome.succeeded);
116-
} else {
117-
result.update(Outcome.failed, `Expected ${actual} to be less than ${previous}`);
118-
}
119-
break;
92+
case Behaviour.unchanged:
93+
if (deepEqual(actual, previous)) {
94+
result.update(Outcome.succeeded);
95+
} else {
96+
result.update(Outcome.failed, `Expected ${actual} to equal ${previous}`);
97+
}
98+
break;
99+
case Behaviour.changed:
100+
if (!deepEqual(actual, previous)) {
101+
result.update(Outcome.succeeded);
102+
} else {
103+
result.update(Outcome.failed, `Expected ${actual} to be different from ${previous}`);
104+
}
105+
break;
106+
case Behaviour.increased:
107+
if (actual > previous) {
108+
result.update(Outcome.succeeded);
109+
} else {
110+
result.update(Outcome.failed, `Expected ${actual} to be greater than ${previous}`);
111+
}
112+
break;
113+
case Behaviour.decreased:
114+
if (actual < previous) {
115+
result.update(Outcome.succeeded);
116+
} else {
117+
result.update(Outcome.failed, `Expected ${actual} to be less than ${previous}`);
118+
}
119+
break;
120120
}
121121
return result;
122122
}

src/framework/scenario/Actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface Dictionary {
88
[index: string]: any;
99
}
1010

11-
//export type Assertable<T> = T extends Object ? {[index: string]: any} : void;
11+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1212
export type Assertable<T extends Object | void> = {[index: string]: any};
1313

1414
export function assertable(obj: Object): Assertable<Object> {
@@ -38,8 +38,8 @@ export function awaitBreakpoint(): Action<Breakpoint> {
3838
// on success: remove listener + resolve
3939
testee.bed()?.removeListener(TestbedEvents.OnMessage, breakpointListener);
4040
resolve(assertable(breakpoint));
41-
} catch (e) {
42-
41+
} catch {
42+
// breakpoint not hit yet
4343
}
4444
}
4545

src/manage/Compiler.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export class CompilerFactory {
3535
public pickCompiler(file: string): Compiler {
3636
const fileType = getFileExtension(file);
3737
switch (fileType) {
38-
case 'wast' :
39-
case 'wat' :
40-
return this.wat;
41-
case 'ts' :
42-
return this.asc;
38+
case 'wast' :
39+
case 'wat' :
40+
return this.wat;
41+
case 'ts' :
42+
return this.asc;
4343
}
4444
throw new Error('Unsupported file type');
4545
}
@@ -195,7 +195,7 @@ export class AsScriptCompiler extends Compiler {
195195
}
196196
});
197197

198-
return new Promise((resolve, reject) => {
198+
return new Promise((resolve, _reject) => {
199199
reader.on('close', () => {
200200
resolve(mapping);
201201
});
@@ -208,8 +208,6 @@ export class AsScriptCompiler extends Compiler {
208208
// return Promise.resolve(this.compiled.get(program)!);
209209
// }
210210

211-
const wat = new WatCompiler(this.wabt);
212-
213211
// compile AS to Wasm and WAT
214212
return new Promise<CompileOutput>(async (resolve, reject) => {
215213
const file = `${dir}/upload.wasm`;
@@ -323,7 +321,8 @@ function parseLines(context: CompileOutput): SourceMap.SourceLine[] {
323321
columnEnd: -1,
324322
instructions: [{address: parseInt(addr, 16)}]
325323
});
326-
} catch (e) {
324+
} catch {
325+
// address not found in line, skip
327326
}
328327

329328
}

src/manage/Uploader.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export class UploaderFactory {
3535

3636
public pickUploader(specification: TestbedSpecification, args: string[] = []): Uploader {
3737
switch (specification.type) {
38-
case PlatformType.arduino:
39-
return new ArduinoUploader(this.arduino, args, specification.options as SerialOptions);
40-
case PlatformType.emulator:
41-
case PlatformType.emu2emu:
42-
case PlatformType.emuproxy:
43-
return new EmulatorUploader(this.emulator, args, specification.options as SubprocessOptions);
44-
case PlatformType.debug:
45-
return new EmulatorConnector(specification.options as SubprocessOptions)
38+
case PlatformType.arduino:
39+
return new ArduinoUploader(this.arduino, args, specification.options as SerialOptions);
40+
case PlatformType.emulator:
41+
case PlatformType.emu2emu:
42+
case PlatformType.emuproxy:
43+
return new EmulatorUploader(this.emulator, args, specification.options as SubprocessOptions);
44+
case PlatformType.debug:
45+
return new EmulatorConnector(specification.options as SubprocessOptions)
4646
}
4747
throw new Error('Unsupported platform type');
4848
}
@@ -84,7 +84,7 @@ export class EmulatorConnector extends Uploader {
8484
private connectSocket(program: string, listener?: (chunk: any) => void): Promise<SubProcess> {
8585
const that = this;
8686

87-
return new Promise(function (resolve, reject) {
87+
return new Promise(function (resolve, _reject) {
8888
const client = new net.Socket();
8989
client.connect(that.port, () => {
9090
that.emit(UploaderEvents.connected);
@@ -130,6 +130,7 @@ export class EmulatorUploader extends Uploader {
130130
that.emit(UploaderEvents.started);
131131

132132
while (process.stdout === undefined) {
133+
// wait for stdout to become available
133134
}
134135

135136
if (isReadable(process.stdout)) {
@@ -180,7 +181,7 @@ export class ArduinoUploader extends Uploader {
180181
private readonly fqbn: string;
181182
private readonly options: SerialPortOpenOptions<any>;
182183

183-
constructor(sdkpath: string, args: string[] = [], options: SerialOptions) {
184+
constructor(sdkpath: string, _args: string[] = [], options: SerialOptions) {
184185
super();
185186
this.sdkpath = sdkpath;
186187
this.fqbn = options.fqbn;

0 commit comments

Comments
 (0)