Skip to content
This repository was archived by the owner on May 11, 2022. It is now read-only.

Commit 6ad1d3e

Browse files
committed
FUSETOOLS2-1342 - fix eslint errors
- Unnecessary escape character: \" - Don't use `String` as a type. Use string instead - XXX is never reassigned. Use 'const' instead - Mixed spaces and tabs - Type boolean trivially inferred from a boolean literal, remove type annotation Signed-off-by: Aurélien Pupier <[email protected]>
1 parent feedb5e commit 6ad1d3e

File tree

9 files changed

+23
-24
lines changed

9 files changed

+23
-24
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
142142
.use(taskLists, {enabled: true, label: true})
143143
.use(markdownItAttrs, {});
144144
}
145-
};
145+
};
146146
}
147147

148148
function createIntegrationsView(): void {

src/extensionFunctions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ export function collectElements(tagname: string, html? : string | undefined) : a
601601
if (html) {
602602
const document = parse(html);
603603
const links = document.querySelectorAll(tagname);
604-
for (let element of links.values()) {
604+
for (const element of links.values()) {
605605
elements.push(element);
606606
}
607607
}
@@ -612,7 +612,7 @@ export function gatherAllRequirementsLinks() : any[] {
612612
const requirements = [];
613613
if (didactManager.active()?.getCurrentHTML()) {
614614
const links = collectElements("a", didactManager.active()?.getCurrentHTML());
615-
for (let element of links.values()) {
615+
for (const element of links.values()) {
616616
if (element.getAttribute('href')) {
617617
const href = element.getAttribute('href');
618618
for(const check of requirementCommandLinks) {
@@ -631,7 +631,7 @@ export function gatherAllCommandsLinks(): any[] {
631631
const commandLinks = [];
632632
if (didactManager.active()?.getCurrentHTML()) {
633633
const links = collectElements("a", didactManager.active()?.getCurrentHTML());
634-
for (let element of links.values()) {
634+
for (const element of links.values()) {
635635
if (element.getAttribute('href')) {
636636
const href = element.getAttribute('href');
637637
if (href.startsWith(commandPrefix)) {
@@ -986,7 +986,7 @@ export async function pasteClipboardToActiveEditorOrPreviouslyUsedOne() : Promis
986986
}
987987

988988
export async function findOpenEditorForFileURI(uri: vscode.Uri) : Promise<vscode.TextEditor | undefined> {
989-
for (let editor of vscode.window.visibleTextEditors.values()) {
989+
for (const editor of vscode.window.visibleTextEditors.values()) {
990990
if (editor.document.uri === uri) {
991991
return editor;
992992
}
@@ -1025,7 +1025,7 @@ function getTimeElementsForAdoc(content : string) : any[] {
10251025

10261026
function processTimeTotalForMD(content : string) : number {
10271027
let total = 0;
1028-
let elements : any[] = getTimeElementsForMD(content);
1028+
const elements : any[] = getTimeElementsForMD(content);
10291029
if (elements && elements.length > 0) {
10301030
elements.forEach(element => {
10311031
const timeAttr = element.getAttribute("time");
@@ -1042,7 +1042,7 @@ function processTimeTotalForMD(content : string) : number {
10421042

10431043
function processTimeTotalForAdoc(content : string) : number {
10441044
let total = 0;
1045-
let elements : any[] = getTimeElementsForAdoc(content);
1045+
const elements : any[] = getTimeElementsForAdoc(content);
10461046
if (elements && elements.length > 0) {
10471047
elements.forEach(element => {
10481048
const classAttr : string = element.getAttribute("class");

src/nodeProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ export class DidactNodeProvider implements vscode.TreeDataProvider<SimpleNode> {
173173
const classAttr : string | undefined = divElement.getAttribute("class");
174174
if (classAttr) {
175175
const splitArray : string[] = classAttr.split(' ');
176-
for (let chunk of splitArray) {
176+
for (const chunk of splitArray) {
177177
if (chunk.startsWith('time=')) {
178178
const splitTime = chunk.split('=')[1];
179179
const timeValue = Number(splitTime);
180180
if (divElement.childNodes.length > 0) {
181181
const children = divElement.childNodes;
182-
for (let rawChild of children) {
182+
for (const rawChild of children) {
183183
if (rawChild instanceof HTMLElement) {
184184
const child: HTMLElement = rawChild;
185185
if (child.tagName.startsWith('H')) {
@@ -263,7 +263,7 @@ export class DidactNodeProvider implements vscode.TreeDataProvider<SimpleNode> {
263263
if (catNode) {
264264
const treeItems : SimpleNode[] = await this.getChildren(catNode);
265265
let foundNode : SimpleNode | null = null;
266-
for (let element of treeItems) {
266+
for (const element of treeItems) {
267267
if (element.uri === uri && element.category === category) {
268268
foundNode = element;
269269
break;

src/test/suite/Utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export async function validateCommands(testUri : vscode.Uri) : Promise<boolean>
6767
return false;
6868
}
6969

70-
export async function getFailedCommands(commands : any[]) : Promise<String[]> {
71-
let failedCommandList : String[] = [];
70+
export async function getFailedCommands(commands : any[]) : Promise<string[]> {
71+
const failedCommandList : string[] = [];
7272
if (commands && commands.length > 0) {
7373
const vsCommands : string[] = await vscode.commands.getCommands(true);
7474
for(const command of commands) {

src/test/suite/commandHandler.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ suite("Command Handler tests", function () {
5151
await processInputs(didactUri);
5252
expect(didactManager.active()).to.not.equal(undefined);
5353

54-
let changed = false;
5554
const panel = didactManager.active();
5655
expect(panel).to.not.equal(null);
5756
expect(panel).to.not.equal(undefined);

src/test/suite/completions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ async function testWeGetExpectedResult(textToInsert : string, expectedResult: st
7676
async function initializeTextEditor(textEditor: TextEditor, initializeWith = "") {
7777
const doc = textEditor.document;
7878
await textEditor.edit((editBuilder) => {
79-
editBuilder.delete(new Range(new Position(0, 0), doc.positionAt(doc.getText().length)));
79+
editBuilder.delete(new Range(new Position(0, 0), doc.positionAt(doc.getText().length)));
8080
});
8181
await textEditor.edit((editBuilder) => {
82-
editBuilder.insert(new Position(0, 0), initializeWith);
82+
editBuilder.insert(new Position(0, 0), initializeWith);
8383
});
8484
expect(doc.getText()).to.be.equal(initializeWith);
8585
}

src/test/suite/registry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ suite('Didact registry test suite', () => {
139139
});
140140

141141
test('append registry from environment variable', async() => {
142-
const tutsToAppend : String = '[{"name":"AppendMe2","category":"AppendedCat2","sourceUri":"https%3A%2F%2Fraw.githubusercontent.com%2Fredhat-developer%2Fvscode-didact%2Fmain%2Fexamples%2Fregistry.example.didact.md"}]';
142+
const tutsToAppend = '[{"name":"AppendMe2","category":"AppendedCat2","sourceUri":"https%3A%2F%2Fraw.githubusercontent.com%2Fredhat-developer%2Fvscode-didact%2Fmain%2Fexamples%2Fregistry.example.didact.md"}]';
143143
process.env[DIDACT_APPEND_REGISTERED_SETTING] = tutsToAppend.toString();
144144

145145
const envVarJson = getAppendRegisteredSettingFromEnv();

src/test/suite/stubDemoTutorial.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ suite('stub out a tutorial', () => {
3636

3737
test('that we can send an echo command to the terminal and get the response', async () => {
3838
const name = 'echoTerminal';
39-
const text = `echo \"Hello World ${name}\"`;
39+
const text = `echo "Hello World ${name}"`;
4040
const result = `Hello World echoTerminal`;
4141
await validateTerminalResponse(name, text, result);
4242
});
@@ -52,7 +52,7 @@ suite('stub out a tutorial', () => {
5252
const testUri = new DidactUri(href, ctxt);
5353
const textToParse = testUri.getText();
5454
const userToParse = testUri.getUser();
55-
let outputs : string[] = [];
55+
const outputs : string[] = [];
5656
if (textToParse) {
5757
handleText(textToParse, outputs);
5858
} else if (userToParse) {

src/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export async function getCurrentFileSelectionPath(): Promise<Uri> {
290290
await commands.executeCommand('copyFilePath');
291291
const copyPath = await env.clipboard.readText();
292292
if (fs.existsSync(`"${copyPath}"`) && fs.lstatSync(`"${copyPath}"`).isFile() ) {
293-
return Uri.file(`"${copyPath}"`);
293+
return Uri.file(`"${copyPath}"`);
294294
}
295295
}
296296
throw new Error("Can not determine current file selection");
@@ -395,17 +395,17 @@ function validateTutorialNameInput(value: string, tutorialsForValidation : strin
395395
}
396396
return null;
397397
}
398-
return `${value} is invalid`;
398+
return `${value} is invalid`;
399399
}
400400

401401
async function quickPickCategory(
402402
categories: string[],
403-
canSelectMany: boolean = false,
404-
acceptInput: boolean = true): Promise<string[]> {
405-
let options = categories.map(tag => ({ label: tag }));
403+
canSelectMany = false,
404+
acceptInput = true): Promise<string[]> {
405+
const options = categories.map(tag => ({ label: tag }));
406406

407407
return new Promise((resolve, _) => {
408-
let quickPick = window.createQuickPick();
408+
const quickPick = window.createQuickPick();
409409
let placeholder = "Select a Tutorial Category.";
410410

411411
if (acceptInput) {

0 commit comments

Comments
 (0)