Skip to content

Commit

Permalink
fix new lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMBarr committed Apr 25, 2024
1 parent 9858f8a commit bf85845
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 27 deletions.
24 changes: 24 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')`;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 6 additions & 5 deletions src/app/convert/inputs/input-type-chordpro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(':')) {
Expand Down Expand Up @@ -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,
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/convert/inputs/input-type-openlyrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 });
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/convert/inputs/input-type-propresenter5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/convert/inputs/input-type-propresenter6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/convert/outputs/output-type-chordpro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}}`;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/convert/outputs/output-type-plain-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/convert/outputs/output-type-songpro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export class OutputTypeSongPro implements IOutputConverter {
const customAttributes: Array<string> = [];
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`);
}
}

Expand Down
29 changes: 18 additions & 11 deletions src/app/convert/slide-display/slide-display.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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);
});
Expand All @@ -62,32 +64,37 @@ 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
f.songData.slides.forEach((slide, idx) => {
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);
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { AppModule } from './app/app.module';

platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch((err) => {
.catch((err: unknown) => {
console.error(err);
});

0 comments on commit bf85845

Please sign in to comment.