From 5b57dbd68cd227408b27b020e4327ff6c2ffdc07 Mon Sep 17 00:00:00 2001 From: gigitux Date: Mon, 11 Jan 2021 11:28:35 +0100 Subject: [PATCH] fix(lint): fix lint process Fix linting error and add lint step to CI --- .github/workflows/main.yml | 60 +++++++++++-------- .../core/interceptors/cache-interceptor.ts | 18 +++--- .../command-documentation.component.ts | 2 +- .../shared/models/github-content.interface.ts | 2 +- src/app/shared/pipes/search-filter.pipe.ts | 10 ++-- src/environments/environment.ts | 7 ++- 6 files changed, 54 insertions(+), 45 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a7104ab..f7ba549 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,34 +1,42 @@ name: Deploy to GitHub Pages -on: - push: - branches: - - master +on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly. - with: - persist-credentials: false - - name: Use Node.js 10.x - uses: actions/setup-node@v1 - with: - node-version: '10.x' - - name: Build - run: | - npm install -g @angular/cli - npm install - node ./.github/workflows/ng-env-replace.js - ng build --prod --base-href="/redis-patterns-console/" - env: + - name: Checkout + uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly. + with: + persist-credentials: false + - name: Use Node.js 10.x + uses: actions/setup-node@v1 + with: + node-version: "10.x" + + - name: Install Deps + run: | + npm install -g @angular/cli + npm install + + - name: Lint + run: npm run lint + + - name: Build + run: | + npm install -g @angular/cli + npm install + node ./.github/workflows/ng-env-replace.js + ng build --prod --base-href="/redis-patterns-console/" + env: REDIS_SERVER_API_WS: ${{ secrets.REDIS_SERVER_API_WS }} - - name: Deploy - uses: JamesIves/github-pages-deploy-action@releases/v2 - env: - ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} - BASE_BRANCH: master - BRANCH: gh-pages - FOLDER: dist + + - name: Deploy + if: github.ref == 'refs/heads/master' + uses: JamesIves/github-pages-deploy-action@releases/v2 + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + BASE_BRANCH: master + BRANCH: gh-pages + FOLDER: dist diff --git a/src/app/core/interceptors/cache-interceptor.ts b/src/app/core/interceptors/cache-interceptor.ts index a21073d..bee0d78 100644 --- a/src/app/core/interceptors/cache-interceptor.ts +++ b/src/app/core/interceptors/cache-interceptor.ts @@ -8,24 +8,24 @@ import { } from '@angular/common/http'; import { Observable, of } from 'rxjs'; import { tap } from 'rxjs/operators'; -​ + import { environment } from '@app/../environments/environment'; import { CachingService } from '@app/core/services/caching.service'; import { GithubDataService } from '@app/core/services/github-data.service'; -​ + @Injectable({ providedIn: 'root' }) export class CacheInterceptor implements HttpInterceptor { -​ + constructor(private cachingService: CachingService, private githubDataService: GithubDataService) { } -​ - intercept(request: HttpRequest, next: HttpHandler ): Observable> { + + intercept(request: HttpRequest, next: HttpHandler): Observable> { if (this.githubDataService.accessToken && this.githubDataService.accessToken.length) { request = request.clone({ setHeaders: { Authorization: `token ${this.githubDataService.accessToken}` } }); } -​ - if (!request.headers.has(environment.cacheableHeaderKey)) { + + if (!request.headers.has(environment.cacheableHeaderKey)) { return next.handle(request); } /** remove cacheable headers form original request */ @@ -33,7 +33,7 @@ export class CacheInterceptor implements HttpInterceptor { const cachedResponse = this.cachingService.get(request.url); return cachedResponse ? of(cachedResponse) : this.sendRequest(request, next); } -​ + sendRequest(req: HttpRequest, next: HttpHandler): Observable> { return next.handle(req).pipe( tap((event) => { @@ -43,4 +43,4 @@ export class CacheInterceptor implements HttpInterceptor { }) ); } -} \ No newline at end of file +} diff --git a/src/app/features/command/command-documentation/command-documentation.component.ts b/src/app/features/command/command-documentation/command-documentation.component.ts index 8fd0214..9e04500 100644 --- a/src/app/features/command/command-documentation/command-documentation.component.ts +++ b/src/app/features/command/command-documentation/command-documentation.component.ts @@ -8,7 +8,7 @@ import { Component, Input, ChangeDetectionStrategy, ViewChild, ElementRef } from export class CommandDocumentationComponent { public documentation = ''; - @ViewChild('scrollBox', {static: true}) scrollBox: ElementRef; + @ViewChild('scrollBox', { static: true }) scrollBox: ElementRef; @Input('documentation') set resetScroll(document: string) { this.documentation = document; this.scrollBox.nativeElement.scrollTop = 0; diff --git a/src/app/shared/models/github-content.interface.ts b/src/app/shared/models/github-content.interface.ts index ac16916..790e029 100644 --- a/src/app/shared/models/github-content.interface.ts +++ b/src/app/shared/models/github-content.interface.ts @@ -16,4 +16,4 @@ export interface ITokenResponse { token_type?: string; scope?: string; }; -} \ No newline at end of file +} diff --git a/src/app/shared/pipes/search-filter.pipe.ts b/src/app/shared/pipes/search-filter.pipe.ts index 57326c1..06f2463 100644 --- a/src/app/shared/pipes/search-filter.pipe.ts +++ b/src/app/shared/pipes/search-filter.pipe.ts @@ -5,15 +5,15 @@ import { Pipe, PipeTransform } from '@angular/core'; }) export class SearchFilterPipe implements PipeTransform { transform(items: any[], field: string, value: string): any[] { - if(!value) { return items; } - if(!items) { return []; } + if (!value) { return items; } + if (!items) { return []; } return items.filter(it => { - if (typeof(it[field]) !== 'boolean') { - return it[field].toLowerCase().includes((value).toLowerCase()); + if (typeof (it[field]) !== 'boolean') { + return it[field].toLowerCase().includes((value as string).toLowerCase()); } else { return (it[field]) === (value === 'true'); } }); } -} \ No newline at end of file +} diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 2881b7b..ddbbef8 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,7 +3,7 @@ // The list of file replacements can be found in `angular.json`. import { version } from 'package.json'; -​ + export const environment = { production: false, redisServer: 'ws://127.0.0.1:8080', @@ -23,7 +23,7 @@ export const environment = { cacheableHeaderKey: 'cacheable-request', version }; -​ + /* * For easier debugging in development mode, you can import the following file * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. @@ -31,4 +31,5 @@ export const environment = { * This import should be commented out in production mode because it will have a negative impact * on performance if an error is thrown. */ -// import 'zone.js/dist/zone-error'; // Included with Angular CLI. \ No newline at end of file +// import 'zone.js/dist/zone-error'; // Included with Angular CLI. +