Skip to content
This repository was archived by the owner on Dec 22, 2024. It is now read-only.

Commit 4d5126b

Browse files
Fixed linting
1 parent 715d99f commit 4d5126b

File tree

7 files changed

+41
-44
lines changed

7 files changed

+41
-44
lines changed

src/arduino/arduino.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class ArduinoApp {
7474
constructor(private _settings: IArduinoSettings) {
7575
const analysisDelayMs = 1000 * 3;
7676
this._analysisManager = new AnalysisManager(
77-
() => { return this._building; },
77+
() => this._building,
7878
async () => { await this.build(BuildMode.Analyze); },
7979
analysisDelayMs);
8080
}
@@ -633,7 +633,7 @@ Please make sure the folder is not occupied by other procedures .`);
633633
* @returns True if successful, false on error.
634634
*/
635635
protected async runPreBuildCommand(dc: DeviceContext): Promise<boolean> {
636-
const prebuildcmdline = dc.prebuild;
636+
const prebuildcmdline = dc.prebuild;
637637
if (prebuildcmdline) {
638638
arduinoChannel.info(`Running pre-build command: ${prebuildcmdline}`);
639639
const args = prebuildcmdline.split(/\s+/);
@@ -679,14 +679,14 @@ Please make sure the folder is not occupied by other procedures .`);
679679
}
680680

681681
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
682-
if (mode == BuildMode.Analyze) {
682+
if (mode === BuildMode.Analyze) {
683683
// Analyze runs non interactively
684684
return false;
685685
}
686686
if (!await dc.resolveMainSketch()) {
687687
vscode.window.showErrorMessage("No sketch file was found. Please specify the sketch in the arduino.json file");
688688
return false;
689-
}
689+
}
690690
}
691691

692692
const selectSerial = async () => {
@@ -805,8 +805,8 @@ Please make sure the folder is not occupied by other procedures .`);
805805
stdoutCallback,
806806
).then(async () => {
807807
await cleanup();
808-
if (mode != BuildMode.Analyze) {
809-
const cmd = os.platform() == "darwin"
808+
if (mode !== BuildMode.Analyze) {
809+
const cmd = os.platform() === "darwin"
810810
? "Cmd + Alt + I"
811811
: "Ctrl + Alt + I";
812812
arduinoChannel.info(`To rebuild your IntelliSense configuration run "${cmd}"`);

src/arduino/arduinoContentProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import ArduinoActivator from "../arduinoActivator";
88
import ArduinoContext from "../arduinoContext";
99
import * as Constants from "../common/constants";
1010
import * as JSONHelper from "../common/cycle";
11+
import { DeviceContext } from "../deviceContext";
1112
import * as Logger from "../logger/logger";
1213
import LocalWebServer from "./localWebServer";
13-
import { VscodeSettings } from "./vscodeSettings";
14-
import { DeviceContext } from "../deviceContext";
1514

1615
export class ArduinoContentProvider implements vscode.TextDocumentContentProvider {
1716
private _webserver: LocalWebServer;

src/arduino/board.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
import { IBoard, IBoardConfigItem, IPlatform, BoardConfigResult } from "./package";
4+
import { BoardConfigResult, IBoard, IBoardConfigItem, IPlatform } from "./package";
55

66
export function parseBoardDescriptor(boardDescriptor: string, plat: IPlatform): Map<string, IBoard> {
77
const boardLineRegex = /([^\.]+)\.(\S+)=(.+)/;
@@ -142,7 +142,7 @@ export class Board implements IBoard {
142142
for (const o of targetConfig.options) {
143143
// Make sure that we only set valid options, e.g. when loading
144144
// from config files.
145-
if (o.id == optionId) {
145+
if (o.id === optionId) {
146146
if (targetConfig.selectedOption !== optionId) {
147147
targetConfig.selectedOption = optionId;
148148
return BoardConfigResult.Success;

src/arduino/boardManager.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export class BoardManager {
291291
// setting partially valid configurations can lead to nasty
292292
// surprises. When setting a new board this is acceptable
293293
const r = this._currentBoard.loadConfig(dc.configuration);
294-
if (r != BoardConfigResult.Success && r != BoardConfigResult.SuccessNoChange) {
294+
if (r !== BoardConfigResult.Success && r !== BoardConfigResult.SuccessNoChange) {
295295
this._currentBoard.resetConfig();
296296
// we don't reset dc.configuration to give the user a
297297
// chance to fix her/his configuration
@@ -317,7 +317,7 @@ export class BoardManager {
317317
const dc = DeviceContext.getInstance();
318318
if (this._currentBoard) {
319319
const r = this._currentBoard.loadConfig(dc.configuration);
320-
if (r != BoardConfigResult.Success && r != BoardConfigResult.SuccessNoChange) {
320+
if (r !== BoardConfigResult.Success && r !== BoardConfigResult.SuccessNoChange) {
321321
this._currentBoard.resetConfig();
322322
// We reset the configuration here but do not write it back
323323
// to the configuration file - this can be annoying when
@@ -328,17 +328,17 @@ export class BoardManager {
328328
}
329329
}
330330

331-
public invalidConfigWarning(result: BoardConfigResult) {
331+
private invalidConfigWarning(result: BoardConfigResult) {
332332
let what = "";
333333
switch (result) {
334334
case BoardConfigResult.InvalidFormat:
335-
what = ': Invalid format must be of the form "key1=value2,key1=value2,..."';
335+
what = ": Invalid format must be of the form \"key1=value2,key1=value2,...\"";
336336
break;
337337
case BoardConfigResult.InvalidConfigID:
338-
what = ': Invalid configuration key';
338+
what = ": Invalid configuration key";
339339
break;
340340
case BoardConfigResult.InvalidOptionID:
341-
what = ': Invalid configuration value';
341+
what = ": Invalid configuration value";
342342
break;
343343
}
344344
vscode.window.showWarningMessage(`Invalid board configuration detected in configuration file${what}. Falling back to defaults.`);

src/arduino/intellisense.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function makeCompilerParserContext(dc: DeviceContext): ICoCoPaContext {
121121
*/
122122
function makeCompilerParserEngines(dc: DeviceContext) {
123123

124-
let sketch = path.basename(dc.sketch);
124+
const sketch = path.basename(dc.sketch);
125125
const trigger = ccp.getTriggerForArduinoGcc(sketch);
126126
const gccParserEngine = new ccp.ParserGcc(trigger);
127127
return [gccParserEngine];
@@ -136,11 +136,10 @@ function makeCompilerParserEngines(dc: DeviceContext) {
136136
async function findDirContaining(dir: string, what: string): Promise<string | undefined> {
137137
const readdir = tp.promisify(fs.readdir);
138138
const fsstat = tp.promisify(fs.stat);
139-
139+
140140
for (const entry of await readdir(dir)) {
141141
const p = path.join(dir, entry);
142142
const s = await fsstat(p);
143-
console.log(p);
144143
if (s.isDirectory()) {
145144
const result = await findDirContaining(p, what);
146145
if (result) {
@@ -217,7 +216,7 @@ enum AnalysisEvent {
217216
/**
218217
* This class manages analysis builds for the automatic IntelliSense
219218
* configuration synthesis. Its primary purposes are:
220-
*
219+
*
221220
* * delaying analysis requests caused by DeviceContext setting change
222221
* events such that multiple subsequent requests don't cause
223222
* multiple analysis builds
@@ -257,7 +256,7 @@ export class AnalysisManager {
257256
* analysis request. This delay is used as polling interval as well when
258257
* checking for ongoing builds.
259258
*/
260-
constructor(isBuilding:() => boolean,
259+
constructor(isBuilding: () => boolean,
261260
doBuild: () => Promise<void>,
262261
waitPeriodMs: number = 1000) {
263262
this._isBuilding = isBuilding;
@@ -271,33 +270,32 @@ export class AnalysisManager {
271270
* within a wait period or until any build in progress has terminated.
272271
*/
273272
public async requestAnalysis() {
274-
console.log("requesting analysis");
275273
await this.update(AnalysisEvent.AnalysisRequest);
276274
}
277275

278276
/**
279277
* Update the manager's state machine.
280278
* @param event The event which will cause the state transition.
281-
*
279+
*
282280
* Implementation note: asynchronous edge actions must be called after
283-
* setting the new state since they don't return immediately.
281+
* setting the new state since they don't return immediately.
284282
*/
285283
private async update(event: AnalysisEvent) {
286284

287285
switch (this._state) {
288286

289287
case AnalysisState.Idle:
290-
if (event == AnalysisEvent.AnalysisRequest) {
288+
if (event === AnalysisEvent.AnalysisRequest) {
291289
this._state = AnalysisState.Waiting;
292290
this.startWaitTimeout();
293291
}
294292
break;
295293

296294
case AnalysisState.Waiting:
297-
if (event == AnalysisEvent.AnalysisRequest) {
295+
if (event === AnalysisEvent.AnalysisRequest) {
298296
// every new request restarts timer
299297
this.startWaitTimeout();
300-
} else if (event == AnalysisEvent.WaitTimeout) {
298+
} else if (event === AnalysisEvent.WaitTimeout) {
301299
if (this._isBuilding()) {
302300
// another build in progress, continue waiting
303301
this.startWaitTimeout();
@@ -310,15 +308,15 @@ export class AnalysisManager {
310308
break;
311309

312310
case AnalysisState.Analyzing:
313-
if (event == AnalysisEvent.AnalysisBuildDone) {
311+
if (event === AnalysisEvent.AnalysisBuildDone) {
314312
this._state = AnalysisState.Idle;
315-
} else if (event == AnalysisEvent.AnalysisRequest) {
313+
} else if (event === AnalysisEvent.AnalysisRequest) {
316314
this._state = AnalysisState.AnalyzingWaiting;
317315
}
318316
break;
319317

320318
case AnalysisState.AnalyzingWaiting:
321-
if (event == AnalysisEvent.AnalysisBuildDone) {
319+
if (event === AnalysisEvent.AnalysisBuildDone) {
322320
// emulate the transition from idle to waiting
323321
// (we don't care if this adds an additional
324322
// timeout - event driven analysis is not time-

src/deviceContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
296296
/* TODO (EW, 2020-02-18):
297297
* is 'c' actually allowed? Also found on within other files.
298298
* And the regular expression doesn't need the intenal groups.
299-
* The outer group can be an anonymous group.
299+
* The outer group can be an anonymous group.
300300
* And \w doesn't match dashes - so any sketch containing dashes
301301
* will not be found.
302302
* The correct expression therefore would be something like this:
303-
*
303+
*
304304
* /^[\w\-]+\.(?:ino|cpp)$/
305305
*
306306
* I'd recommend to define such regular expressions (including)

src/deviceSettings.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import * as logger from "./logger/logger";
1717
* to prevent invalid or badly formatted values to enter your settings.
1818
*/
1919
class Setting<T> {
20+
/** The setting's default value. */
21+
public readonly default: T;
2022
/** The actual value of the setting. */
2123
private _value: T | undefined;
22-
/** The setting's default value. */
23-
readonly default: T;
2424
/** Indicates if the value was changed since the last call to this.commit(). */
2525
private _modified: boolean;
2626
/** Event emitter which fires when the value is changed. */
@@ -51,7 +51,7 @@ class Setting<T> {
5151
* To clear the modified flag call commit().
5252
*/
5353
public get modified() {
54-
return this._modified;
54+
return this._modified;
5555
}
5656
/** Returns the modified-event emitter. */
5757
public get emitter() {
@@ -104,15 +104,15 @@ class StrSetting extends Setting<string> {
104104
* provides common operations on them.
105105
*/
106106
export class DeviceSettings {
107-
port: StrSetting = new StrSetting();
108-
board: StrSetting = new StrSetting();
109-
sketch: StrSetting = new StrSetting();
110-
output: StrSetting = new StrSetting();
111-
debugger: StrSetting = new StrSetting();
112-
intelliSenseGen: StrSetting = new StrSetting();
113-
configuration: StrSetting = new StrSetting();
114-
prebuild: StrSetting = new StrSetting();
115-
programmer: StrSetting = new StrSetting();
107+
public port: StrSetting = new StrSetting();
108+
public board: StrSetting = new StrSetting();
109+
public sketch: StrSetting = new StrSetting();
110+
public output: StrSetting = new StrSetting();
111+
public debugger: StrSetting = new StrSetting();
112+
public intelliSenseGen: StrSetting = new StrSetting();
113+
public configuration: StrSetting = new StrSetting();
114+
public prebuild: StrSetting = new StrSetting();
115+
public programmer: StrSetting = new StrSetting();
116116

117117
/**
118118
* @returns true if any of the settings values has its modified flag

0 commit comments

Comments
 (0)