Skip to content

Commit c8b4492

Browse files
committed
Prettier formatting
1 parent 96142cb commit c8b4492

10 files changed

+73
-56
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public/
88
# Do not ignore the following files
99
!.github/
1010
!src/
11+
!src/**
12+
!src/**/*
1113
!README.md
1214

1315
# Re-ignore sub-directories from the above exempt directories:

src/app/public/ngx-gist-file-filter.pipe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { NgxGist } from './ngx-gist.model';
21
import { Pipe, PipeTransform } from '@angular/core';
2+
3+
import { NgxGist } from './ngx-gist.model';
34
import { isNonEmptyString, isStringArray } from './ngx-gist.utilities';
45

56
@Pipe({ name: 'gistFileFilter' })

src/app/public/ngx-gist-line-numbers.service.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1+
import hljs, { HLJSApi } from 'highlight.js';
2+
import {
3+
Observable,
4+
defaultIfEmpty,
5+
filter,
6+
firstValueFrom,
7+
from,
8+
map,
9+
} from 'rxjs';
110

2-
import { Injectable, inject } from '@angular/core';
311
import { DOCUMENT } from '@angular/common';
4-
import hljs, { HLJSApi } from 'highlight.js';
5-
import { defaultIfEmpty, filter, map, Observable, firstValueFrom, from } from 'rxjs';
12+
import { Injectable, inject } from '@angular/core';
613

714
@Injectable({ providedIn: 'root' }) // Must be a singleton
815
export class NgxGistLineNumbersService {
916
private readonly document: Document = inject(DOCUMENT);
10-
17+
1118
private isLoaded = false;
1219

1320
public async load(): Promise<void> {
1421
if (
1522
this.isLoaded ||
16-
typeof this.document.defaultView?.hljs?.initLineNumbersOnLoad === 'function'
23+
typeof this.document.defaultView?.hljs?.initLineNumbersOnLoad ===
24+
'function'
1725
) {
1826
return;
1927
}
@@ -23,7 +31,9 @@ export class NgxGistLineNumbersService {
2331
// Ensure hljs is available before we load the dependent library
2432
this.document.defaultView.hljs = hljs;
2533
} else {
26-
throw new Error(`Unable to access default view to apply "highlight.js" package.`);
34+
throw new Error(
35+
`Unable to access default view to apply "highlight.js" package.`,
36+
);
2737
}
2838

2939
const result = await firstValueFrom(this.loadHljsLineNumbersLibrary());
@@ -41,7 +51,7 @@ export class NgxGistLineNumbersService {
4151
return from(import('highlightjs-line-numbers.js' as const)).pipe(
4252
map((module) => module?.default), // Optional chaining makes it cleaner
4353
filter(Boolean), // `Boolean` acts as a filter to remove falsy values
44-
defaultIfEmpty(null)
54+
defaultIfEmpty(null),
4555
);
4656
}
4757
}
@@ -55,8 +65,14 @@ declare global {
5565
interface Window {
5666
hljs?: HLJSApi & {
5767
initLineNumbersOnLoad?: (options?: HljsLineNumbersOptions) => void;
58-
lineNumbersBlock?: (value: Element, options?: HljsLineNumbersOptions) => void;
59-
lineNumbersValue?: (value: string, options?: HljsLineNumbersOptions) => string;
68+
lineNumbersBlock?: (
69+
value: Element,
70+
options?: HljsLineNumbersOptions,
71+
) => void;
72+
lineNumbersValue?: (
73+
value: string,
74+
options?: HljsLineNumbersOptions,
75+
) => string;
6076
};
6177
}
6278
}

src/app/public/ngx-gist-theme.service.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Injectable, inject } from '@angular/core';
21
import { DOCUMENT } from '@angular/common';
2+
import { Injectable, inject } from '@angular/core';
33

44
@Injectable({ providedIn: 'root' }) // Must be a singleton
55
export class NgxGistThemeService {
@@ -14,10 +14,7 @@ export class NgxGistThemeService {
1414
if (hljsThemeLinkEl && hilightJsTheme === 'default') {
1515
// Default theme already in use, return.
1616
return;
17-
} else if (
18-
hljsThemeLinkEl &&
19-
hilightJsTheme !== 'default'
20-
) {
17+
} else if (hljsThemeLinkEl && hilightJsTheme !== 'default') {
2118
// Override previously used theme, but remove it first.
2219
this.document.head.removeChild(hljsThemeLinkEl);
2320
}

src/app/public/ngx-gist.component.html

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
@if (gistChanges | async; as gist) {
33
<mat-tab-group>
44
@for (
5-
file of gist.highlightedFiles
6-
| gistFileFilter: displayOnlyFileNames
7-
; track
8-
file) {
9-
<mat-tab
10-
[label]="file.filename"
11-
>
5+
file of gist.highlightedFiles | gistFileFilter: displayOnlyFileNames;
6+
track file
7+
) {
8+
<mat-tab [label]="file.filename">
129
<pre>
1310
@if (applyLineNumbers(file.highlightedContent); as content) {
1411
<code
@@ -28,10 +25,7 @@
2825
@if (gistIdChanges | async; as gid) {
2926
<mat-card-footer>
3027
@if (!hideGistLink) {
31-
<a
32-
target="_blank"
33-
[href]="'https://gist.github.com/' + gid"
34-
>
28+
<a target="_blank" [href]="'https://gist.github.com/' + gid">
3529
🔗 Open Gist on GitHub
3630
</a>
3731
}

src/app/public/ngx-gist.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Remove this if this is already in your project.
2-
@import "https://fonts.googleapis.com/icon?family=Material+Icons";
2+
@import 'https://fonts.googleapis.com/icon?family=Material+Icons';
33

44
pre {
55
display: flex;

src/app/public/ngx-gist.component.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
import { BehaviorSubject, filter, firstValueFrom, ReplaySubject } from 'rxjs';
2-
import { ChangeDetectionStrategy, Component, Input, OnInit, inject } from '@angular/core';
1+
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
2+
import { BehaviorSubject, ReplaySubject, filter, firstValueFrom } from 'rxjs';
3+
34
import { CommonModule, DOCUMENT } from '@angular/common';
4-
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
5-
import { GistFileFilterPipe } from './ngx-gist-file-filter.pipe';
6-
import { HighlightJsTheme, NgxGistThemeService } from './ngx-gist-theme.service';
5+
import {
6+
ChangeDetectionStrategy,
7+
Component,
8+
Input,
9+
OnInit,
10+
inject,
11+
} from '@angular/core';
712
import { MatCardModule } from '@angular/material/card';
813
import { MatTabsModule } from '@angular/material/tabs';
9-
import { NgxGist } from './ngx-gist.model';
14+
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
15+
16+
import { GistFileFilterPipe } from './ngx-gist-file-filter.pipe';
1017
import { NgxGistLineNumbersService } from './ngx-gist-line-numbers.service';
18+
import {
19+
HighlightJsTheme,
20+
NgxGistThemeService,
21+
} from './ngx-gist-theme.service';
22+
import { NgxGist } from './ngx-gist.model';
1123
import { NgxGistService } from './ngx-gist.service';
12-
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
1324
import { isNonEmptyValue } from './ngx-gist.utilities';
1425

1526
@UntilDestroy()
@@ -18,23 +29,16 @@ import { isNonEmptyValue } from './ngx-gist.utilities';
1829
templateUrl: './ngx-gist.component.html',
1930
styleUrl: './ngx-gist.component.scss',
2031
standalone: true,
21-
imports: [
22-
CommonModule,
23-
GistFileFilterPipe,
24-
MatCardModule,
25-
MatTabsModule,
26-
],
27-
providers: [
28-
NgxGistLineNumbersService,
29-
NgxGistService,
30-
NgxGistThemeService,
31-
],
32+
imports: [CommonModule, GistFileFilterPipe, MatCardModule, MatTabsModule],
33+
providers: [NgxGistLineNumbersService, NgxGistService, NgxGistThemeService],
3234
changeDetection: ChangeDetectionStrategy.OnPush,
3335
})
3436
export class NgxGistComponent implements OnInit {
3537
private readonly document: Document = inject(DOCUMENT);
3638
private readonly domSanitizer = inject(DomSanitizer);
37-
private readonly ngxGistLineNumbersService = inject(NgxGistLineNumbersService);
39+
private readonly ngxGistLineNumbersService = inject(
40+
NgxGistLineNumbersService,
41+
);
3842
private readonly ngxGistService = inject(NgxGistService);
3943
private readonly ngxGistThemeService = inject(NgxGistThemeService);
4044

src/app/public/ngx-gist.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import hljs from 'highlight.js';
12
import * as io from 'io-ts';
23
import * as iot from 'io-ts-types';
4+
35
import {
46
decodeValueElseNull,
57
isNonEmptyString,
68
parsedJsonFromStringCodec,
79
} from './ngx-gist.utilities';
8-
import hljs from 'highlight.js';
910

1011
export class NgxGist implements Gist {
1112
public constructor(args: Gist & Pick<NgxGist, 'languageOverride'>) {

src/app/public/ngx-gist.service.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { gistCodec, NgxGist } from './ngx-gist.model';
2-
import { inject, Injectable } from '@angular/core';
1+
import * as io from 'io-ts';
2+
import { Observable, catchError, map, of } from 'rxjs';
3+
34
import { HttpClient } from '@angular/common/http';
4-
import { catchError, map, Observable, of } from 'rxjs';
5+
import { Injectable, inject } from '@angular/core';
6+
7+
import { NgxGist, gistCodec } from './ngx-gist.model';
58
import {
69
decodeValueElseNull,
710
isNonEmptyString,
811
parsedJsonFromStringCodec,
912
} from './ngx-gist.utilities';
10-
import * as io from 'io-ts';
1113

1214
@Injectable()
1315
export class NgxGistService {
@@ -23,9 +25,9 @@ export class NgxGistService {
2325
*/
2426
public get(gistId: string): Observable<NgxGist | null | undefined> {
2527
return this.httpClient
26-
.get<NgxGist | string | null | undefined>(
27-
`https://api.github.com/gists/${gistId}`,
28-
)
28+
.get<
29+
NgxGist | string | null | undefined
30+
>(`https://api.github.com/gists/${gistId}`)
2931
.pipe(
3032
catchError((error: unknown) => {
3133
console.error(error);

src/app/public/ngx-gist.utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as io from 'io-ts';
2-
import { pipe } from 'fp-ts/es6/function';
31
import { getOrElse } from 'fp-ts/es6/Either';
2+
import { pipe } from 'fp-ts/es6/function';
3+
import * as io from 'io-ts';
44

55
/**
66
* Validate that the value is a string.

0 commit comments

Comments
 (0)