From bf8584514f4a6bb180b9a1be344bbf6a8507f10b Mon Sep 17 00:00:00 2001 From: FiniteLooper Date: Wed, 24 Apr 2024 22:06:52 -0400 Subject: [PATCH] fix new lint issues --- .vscode/tasks.json | 24 +++++++++++++++ src/app/app.component.ts | 2 +- .../download-display.component.ts | 5 +++- src/app/convert/inputs/input-type-chordpro.ts | 11 +++---- .../convert/inputs/input-type-openlyrics.ts | 4 +-- .../inputs/input-type-propresenter5.ts | 2 +- .../inputs/input-type-propresenter6.ts | 2 +- .../convert/outputs/output-type-chordpro.ts | 2 +- .../convert/outputs/output-type-plain-text.ts | 2 +- .../convert/outputs/output-type-songpro.ts | 4 +-- .../slide-display.component.spec.ts | 29 ++++++++++++------- src/main.ts | 2 +- 12 files changed, 62 insertions(+), 27 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a298b5b..f3380cd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,9 +3,11 @@ "version": "2.0.0", "tasks": [ { + "label": "Start", "type": "npm", "script": "start", "isBackground": true, + "icon": {"color": "terminal.ansiGreen", "id": "play"}, "problemMatcher": { "owner": "typescript", "pattern": "$tsc", @@ -21,9 +23,31 @@ } }, { + "label": "Unit Tests", "type": "npm", "script": "test", "isBackground": true, + "icon": { "color": "terminal.ansiCyan", "id": "symbol-unit" }, + "problemMatcher": { + "owner": "typescript", + "pattern": "$tsc", + "background": { + "activeOnStart": true, + "beginsPattern": { + "regexp": "(.*?)" + }, + "endsPattern": { + "regexp": "bundle generation complete" + } + } + } + }, + { + "label": "Lint", + "type": "npm", + "script": "lint", + "isBackground": true, + "icon": { "color": "terminal.ansiYellow", "id": "check-all" }, "problemMatcher": { "owner": "typescript", "pattern": "$tsc", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1acaaab..3ab28d1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -20,7 +20,7 @@ export class AppComponent implements OnInit { //don't set a random BG image when generating the pre-rendered routes if (!isPlatformServer(this.platformId)) { const randomNum = Math.floor(Math.random() * this.backgroundImagesCount + 1); - this.document.body.style.backgroundImage = `url('/assets/background/bg${randomNum}.jpg')`; + this.document.body.style.backgroundImage = `url('/assets/background/bg${randomNum.toString()}.jpg')`; } } } diff --git a/src/app/convert/download-display/download-display.component.ts b/src/app/convert/download-display/download-display.component.ts index 2c1f7cf..d6dc8f6 100644 --- a/src/app/convert/download-display/download-display.component.ts +++ b/src/app/convert/download-display/download-display.component.ts @@ -48,7 +48,10 @@ export class DownloadDisplayComponent { type: 'blob', }) .then((zipContent: Blob) => { - fileSaver.saveAs(zipContent, `LyricConverter (${this.outputFileList.length} files).zip`); + fileSaver.saveAs( + zipContent, + `LyricConverter (${this.outputFileList.length.toString()} files).zip`, + ); this.$gaService.event( 'file_download', diff --git a/src/app/convert/inputs/input-type-chordpro.ts b/src/app/convert/inputs/input-type-chordpro.ts index c312bf1..bf4c4a6 100644 --- a/src/app/convert/inputs/input-type-chordpro.ts +++ b/src/app/convert/inputs/input-type-chordpro.ts @@ -87,7 +87,7 @@ export class InputTypeChordPro implements IInputConverter { for (const match of directiveMatches) { const directiveContent = match[1]; if (directiveContent != null) { - const pos = match.index ?? /* istanbul ignore next */ 0; + const pos = match.index; //Anything with a colon we treat as info, EXCEPT FOR labeled directive start markers if (directiveContent.includes(':')) { @@ -155,18 +155,19 @@ export class InputTypeChordPro implements IInputConverter { for (const dir of singleDirectives) { const foundStart = this.patternDirectiveStartMarkers.exec(dir.name); if (foundStart) { + const directiveType = foundStart[2] ?? ''; let matchingEnd; if (foundStart[1] === 'so') { - matchingEnd = singleDirectives.find((d) => d.name === 'eo' + foundStart[2]); + matchingEnd = singleDirectives.find((d) => d.name === 'eo' + directiveType); } else if (foundStart[1] === 'start_of_') { - matchingEnd = singleDirectives.find((d) => d.name === 'end_of_' + foundStart[2]); + matchingEnd = singleDirectives.find((d) => d.name === 'end_of_' + directiveType); } - if (foundStart[2] != null && matchingEnd) { + if (directiveType !== '' && matchingEnd) { pairs.push({ begin: dir, end: matchingEnd, - type: foundStart[2], + type: directiveType, }); } } diff --git a/src/app/convert/inputs/input-type-openlyrics.ts b/src/app/convert/inputs/input-type-openlyrics.ts index 449e0fa..807a1fe 100644 --- a/src/app/convert/inputs/input-type-openlyrics.ts +++ b/src/app/convert/inputs/input-type-openlyrics.ts @@ -121,7 +121,7 @@ export class InputTypeOpenLyrics implements IInputConverter { //of course we know the value here! //eslint-disable-next-line @typescript-eslint/no-non-null-assertion const comment = comments[i]!; - commentsArr.push({ name: `${key} ${i + 1}`, value: comment }); + commentsArr.push({ name: `${key} ${(i + 1).toString()}`, value: comment }); } } return commentsArr; @@ -146,7 +146,7 @@ export class InputTypeOpenLyrics implements IInputConverter { if (sb.entry !== '') { sbVal += ` (entry ${sb.entry})`; } - songBookInfoArr.push({ name: `${name} ${i + 1}`, value: sbVal }); + songBookInfoArr.push({ name: `${name} ${(i + 1).toString()}`, value: sbVal }); } } diff --git a/src/app/convert/inputs/input-type-propresenter5.ts b/src/app/convert/inputs/input-type-propresenter5.ts index 34ab224..9789540 100644 --- a/src/app/convert/inputs/input-type-propresenter5.ts +++ b/src/app/convert/inputs/input-type-propresenter5.ts @@ -69,7 +69,7 @@ export class InputTypeProPresenter5 implements IInputConverter { let title = group.groupLabel; if (group.slides.length > 1) { //Add number suffix to every slide in the group if that group has more than one slide - title += ` (${i + 1})`; + title += ` (${(i + 1).toString()})`; } //combine text of multiple text elements on a single slide diff --git a/src/app/convert/inputs/input-type-propresenter6.ts b/src/app/convert/inputs/input-type-propresenter6.ts index d8279c0..a3330b8 100644 --- a/src/app/convert/inputs/input-type-propresenter6.ts +++ b/src/app/convert/inputs/input-type-propresenter6.ts @@ -66,7 +66,7 @@ export class InputTypeProPresenter6 implements IInputConverter { let title = group.groupLabel; if (group.slides.length > 1) { //Add number suffix to every slide in the group if that group has more than one slide - title += ` (${i + 1})`; + title += ` (${(i + 1).toString()})`; } //combine text of multiple text elements on a single slide diff --git a/src/app/convert/outputs/output-type-chordpro.ts b/src/app/convert/outputs/output-type-chordpro.ts index 6c8b566..2c98c37 100644 --- a/src/app/convert/outputs/output-type-chordpro.ts +++ b/src/app/convert/outputs/output-type-chordpro.ts @@ -17,7 +17,7 @@ export class OutputTypeChordpro implements IOutputConverter { for (const info of song.info) { if (info.value.toString().trim().length > 0) { fileContent += newLine; - fileContent += `{${info.name}: ${info.value}}`; + fileContent += `{${info.name}: ${info.value.toString()}}`; } } diff --git a/src/app/convert/outputs/output-type-plain-text.ts b/src/app/convert/outputs/output-type-plain-text.ts index 5ff5960..1867f7b 100644 --- a/src/app/convert/outputs/output-type-plain-text.ts +++ b/src/app/convert/outputs/output-type-plain-text.ts @@ -16,7 +16,7 @@ export class OutputTypePlainText implements IOutputConverter { for (const info of song.info) { if (info.value.toString().trim().length > 0) { fileContent += newLine; - fileContent += info.name + ': ' + info.value; + fileContent += info.name + ': ' + info.value.toString(); } } diff --git a/src/app/convert/outputs/output-type-songpro.ts b/src/app/convert/outputs/output-type-songpro.ts index 3c81d3f..a0c0dae 100644 --- a/src/app/convert/outputs/output-type-songpro.ts +++ b/src/app/convert/outputs/output-type-songpro.ts @@ -33,9 +33,9 @@ export class OutputTypeSongPro implements IOutputConverter { const customAttributes: Array = []; for (const info of infoArr) { if (standardAttributeNames.includes(info.name.toLowerCase())) { - standardAttributes.push(`@${info.name.toLowerCase()}=${info.value}\n`); + standardAttributes.push(`@${info.name.toLowerCase()}=${info.value.toString()}\n`); } else { - customAttributes.push(`!${info.name}=${info.value}\n`); + customAttributes.push(`!${info.name}=${info.value.toString()}\n`); } } diff --git a/src/app/convert/slide-display/slide-display.component.spec.ts b/src/app/convert/slide-display/slide-display.component.spec.ts index 01e274b..251968c 100644 --- a/src/app/convert/slide-display/slide-display.component.spec.ts +++ b/src/app/convert/slide-display/slide-display.component.spec.ts @@ -32,8 +32,8 @@ describe('SlideDisplayComponent', () => { //Song Info mockFilesCopy.songData.info.forEach((info, idx) => { - const a = `${info.name} ${info.value}`; - const b = (fixture.debugElement.query(By.css(`ul li:nth-of-type(${idx + 1})`)).nativeElement as HTMLElement).textContent!.trim(); + const a = `${info.name} ${info.value.toString()}`; + const b = (fixture.debugElement.query(By.css(`ul li:nth-of-type(${(idx + 1).toString()})`)).nativeElement as HTMLElement).textContent!.trim(); expect(a).toEqual(b); }); @@ -42,12 +42,14 @@ describe('SlideDisplayComponent', () => { mockFilesCopy.songData.slides.forEach((slide, idx) => { expect( ( - fixture.debugElement.query(By.css(`[data-test='song-slides-container'] > div:nth-of-type(${idx + 1}) p`)).nativeElement as HTMLElement + fixture.debugElement.query(By.css(`[data-test='song-slides-container'] > div:nth-of-type(${(idx + 1).toString()}) p`)) + .nativeElement as HTMLElement ).textContent!.trim(), ).toEqual(slide.lyrics); expect( ( - fixture.debugElement.query(By.css(`[data-test='song-slides-container'] > div:nth-of-type(${idx + 1}) footer`)).nativeElement as HTMLElement + fixture.debugElement.query(By.css(`[data-test='song-slides-container'] > div:nth-of-type(${(idx + 1).toString()}) footer`)) + .nativeElement as HTMLElement ).textContent!.trim(), ).toEqual(slide.title); }); @@ -62,17 +64,18 @@ describe('SlideDisplayComponent', () => { expect(fixture.debugElement.queryAll(By.css('.card')).length).toEqual(2); mockFiles.forEach((f, fileIdx) => { - expect((fixture.debugElement.query(By.css(`.card:nth-of-type(${fileIdx + 1}) h3`)).nativeElement as HTMLElement).textContent).toEqual( - f.songData.title, - ); + expect( + (fixture.debugElement.query(By.css(`.card:nth-of-type(${(fileIdx + 1).toString()}) h3`)).nativeElement as HTMLElement).textContent, + ).toEqual(f.songData.title); //Song Info f.songData.info.forEach((info, idx) => { expect( ( - fixture.debugElement.query(By.css(`.card:nth-of-type(${fileIdx + 1}) ul li:nth-of-type(${idx + 1})`)).nativeElement as HTMLElement + fixture.debugElement.query(By.css(`.card:nth-of-type(${(fileIdx + 1).toString()}) ul li:nth-of-type(${(idx + 1).toString()})`)) + .nativeElement as HTMLElement ).textContent!.trim(), - ).toEqual(`${info.name} ${info.value}`); + ).toEqual(`${info.name} ${info.value.toString()}`); }); //Song Lyrics/Slides @@ -80,14 +83,18 @@ describe('SlideDisplayComponent', () => { expect( ( fixture.debugElement.query( - By.css(`.card:nth-of-type(${fileIdx + 1}) [data-test='song-slides-container'] > div:nth-of-type(${idx + 1}) p`), + By.css( + `.card:nth-of-type(${(fileIdx + 1).toString()}) [data-test='song-slides-container'] > div:nth-of-type(${(idx + 1).toString()}) p`, + ), ).nativeElement as HTMLElement ).textContent!.trim(), ).toEqual(slide.lyrics); expect( ( fixture.debugElement.query( - By.css(`.card:nth-of-type(${fileIdx + 1}) [data-test='song-slides-container'] > div:nth-of-type(${idx + 1}) footer`), + By.css( + `.card:nth-of-type(${(fileIdx + 1).toString()}) [data-test='song-slides-container'] > div:nth-of-type(${(idx + 1).toString()}) footer`, + ), ).nativeElement as HTMLElement ).textContent!.trim(), ).toEqual(slide.title); diff --git a/src/main.ts b/src/main.ts index 82a1580..ba44a7e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,6 @@ import { AppModule } from './app/app.module'; platformBrowserDynamic() .bootstrapModule(AppModule) - .catch((err) => { + .catch((err: unknown) => { console.error(err); });