Skip to content

Commit 6115cc1

Browse files
Merge pull request #2087 from damienbod/fg/updating-eslint-rules
Updating es lint rules
2 parents 04ee7df + 7f87ef6 commit 6115cc1

File tree

52 files changed

+16264
-16882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+16264
-16882
lines changed

.eslintrc.json

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,29 @@
2323
}
2424
],
2525
"max-len": "off",
26-
"no-useless-constructor": "off",
27-
"lines-between-class-members": ["error", "always"],
28-
"newline-after-var": ["error", "always"],
26+
"lines-between-class-members": [
27+
"error",
28+
{
29+
"enforce": [
30+
{
31+
"blankLine": "always",
32+
"prev": "method",
33+
"next": "method"
34+
},
35+
{
36+
"blankLine": "always",
37+
"prev": "field",
38+
"next": "method"
39+
}
40+
]
41+
}
42+
],
43+
"padding-line-between-statements": [
44+
"error",
45+
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
46+
{ "blankLine": "never", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] },
47+
{ "blankLine": "always", "prev": "*", "next": "return" }
48+
],
2949
"one-var": ["error", "never"],
3050
"@typescript-eslint/no-useless-constructor": ["error"],
3151
"@typescript-eslint/prefer-readonly": ["error"],
@@ -35,15 +55,13 @@
3555
"no-case-declarations": ["error"],
3656
"no-empty": ["error"],
3757
"@typescript-eslint/no-empty-function": ["error"],
38-
"no-unused-vars": "off",
3958
"@typescript-eslint/ban-types": ["error"],
4059
"no-useless-escape": ["error"],
4160
"no-prototype-builtins": ["error"],
4261
"prefer-spread": ["error"],
4362
"@typescript-eslint/no-explicit-any": "off",
4463
"@typescript-eslint/typedef": ["error"],
4564
"@typescript-eslint/explicit-function-return-type": ["error"],
46-
"newline-before-return": ["error"],
4765
"@typescript-eslint/no-unused-vars": [
4866
"error",
4967
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"build-lib-prod": "ng build angular-auth-oidc-client --configuration production && npm run schematics-build && npm run copy-files",
1919
"test-lib": "ng test angular-auth-oidc-client --code-coverage",
2020
"test-lib-ci": "ng test angular-auth-oidc-client --watch=false --browsers=ChromeHeadlessNoSandbox --code-coverage",
21+
"lint-lib-fix": "ng lint angular-auth-oidc-client --fix",
2122
"lint-lib": "ng lint angular-auth-oidc-client",
2223
"pack-lib": "npm run build-lib-prod && npm pack ./dist/angular-auth-oidc-client",
2324
"publish-lib": "npm run build-lib-prod && npm publish ./dist/angular-auth-oidc-client",

projects/angular-auth-oidc-client/src/lib/api/data.service.ts

Lines changed: 63 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,63 @@
1-
import { HttpHeaders, HttpParams } from '@angular/common/http';
2-
import { Injectable, inject } from '@angular/core';
3-
import { Observable } from 'rxjs';
4-
import { OpenIdConfiguration } from '../config/openid-configuration';
5-
import { HttpBaseService } from './http-base.service';
6-
7-
const NGSW_CUSTOM_PARAM = 'ngsw-bypass';
8-
9-
@Injectable({ providedIn: 'root' })
10-
export class DataService {
11-
private readonly httpClient = inject(HttpBaseService);
12-
13-
get<T>(
14-
url: string,
15-
config: OpenIdConfiguration,
16-
token?: string
17-
): Observable<T> {
18-
const headers = this.prepareHeaders(token);
19-
const params = this.prepareParams(config);
20-
21-
return this.httpClient.get<T>(url, {
22-
headers,
23-
params,
24-
});
25-
}
26-
27-
post<T>(
28-
url: string | null,
29-
body: unknown,
30-
config: OpenIdConfiguration,
31-
headersParams?: HttpHeaders
32-
): Observable<T> {
33-
const headers = headersParams || this.prepareHeaders();
34-
const params = this.prepareParams(config);
35-
36-
return this.httpClient.post<T>(url ?? '', body, { headers, params });
37-
}
38-
39-
private prepareHeaders(token?: string): HttpHeaders {
40-
let headers = new HttpHeaders();
41-
42-
headers = headers.set('Accept', 'application/json');
43-
44-
if (!!token) {
45-
headers = headers.set(
46-
'Authorization',
47-
'Bearer ' + decodeURIComponent(token)
48-
);
49-
}
50-
51-
return headers;
52-
}
53-
54-
private prepareParams(config: OpenIdConfiguration): HttpParams {
55-
let params = new HttpParams();
56-
57-
const { ngswBypass } = config;
58-
59-
if (ngswBypass) {
60-
params = params.set(NGSW_CUSTOM_PARAM, '');
61-
}
62-
63-
return params;
64-
}
65-
}
1+
import { HttpHeaders, HttpParams } from '@angular/common/http';
2+
import { Injectable, inject } from '@angular/core';
3+
import { Observable } from 'rxjs';
4+
import { OpenIdConfiguration } from '../config/openid-configuration';
5+
import { HttpBaseService } from './http-base.service';
6+
7+
const NGSW_CUSTOM_PARAM = 'ngsw-bypass';
8+
9+
@Injectable({ providedIn: 'root' })
10+
export class DataService {
11+
private readonly httpClient = inject(HttpBaseService);
12+
13+
get<T>(
14+
url: string,
15+
config: OpenIdConfiguration,
16+
token?: string
17+
): Observable<T> {
18+
const headers = this.prepareHeaders(token);
19+
const params = this.prepareParams(config);
20+
21+
return this.httpClient.get<T>(url, {
22+
headers,
23+
params,
24+
});
25+
}
26+
27+
post<T>(
28+
url: string | null,
29+
body: unknown,
30+
config: OpenIdConfiguration,
31+
headersParams?: HttpHeaders
32+
): Observable<T> {
33+
const headers = headersParams || this.prepareHeaders();
34+
const params = this.prepareParams(config);
35+
36+
return this.httpClient.post<T>(url ?? '', body, { headers, params });
37+
}
38+
39+
private prepareHeaders(token?: string): HttpHeaders {
40+
let headers = new HttpHeaders();
41+
42+
headers = headers.set('Accept', 'application/json');
43+
44+
if (!!token) {
45+
headers = headers.set(
46+
'Authorization',
47+
'Bearer ' + decodeURIComponent(token)
48+
);
49+
}
50+
51+
return headers;
52+
}
53+
54+
private prepareParams(config: OpenIdConfiguration): HttpParams {
55+
let params = new HttpParams(); const { ngswBypass } = config;
56+
57+
if (ngswBypass) {
58+
params = params.set(NGSW_CUSTOM_PARAM, '');
59+
}
60+
61+
return params;
62+
}
63+
}

projects/angular-auth-oidc-client/src/lib/auth-state/auth-state.service.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, inject } from '@angular/core';
1+
import { inject, Injectable } from '@angular/core';
22
import { BehaviorSubject, Observable, throwError } from 'rxjs';
33
import { distinctUntilChanged } from 'rxjs/operators';
44
import { OpenIdConfiguration } from '../config/openid-configuration';
@@ -190,7 +190,6 @@ export class AuthStateService {
190190
}
191191
const tokenToCheck =
192192
this.storagePersistenceService.getIdToken(configuration);
193-
194193
const idTokenExpired = this.tokenValidationService.hasIdTokenExpired(
195194
tokenToCheck,
196195
configuration,
@@ -221,7 +220,6 @@ export class AuthStateService {
221220
configuration,
222221
renewTimeBeforeTokenExpiresInSeconds
223222
);
224-
225223
const hasExpired = !accessTokenHasNotExpired;
226224

227225
if (hasExpired) {
@@ -320,9 +318,8 @@ export class AuthStateService {
320318
configId: config.configId ?? '',
321319
isAuthenticated: this.isAuthenticated(config),
322320
}));
323-
324321
const isAuthenticated = allConfigsAuthenticated.every(
325-
(x) => !!x.isAuthenticated
322+
(x) => x.isAuthenticated
326323
);
327324

328325
return { allConfigsAuthenticated, isAuthenticated };

0 commit comments

Comments
 (0)