Skip to content

Commit 6ec52b3

Browse files
authored
Merge pull request #3629 from tarlepp/feat/@stylistic/eslint-plugin
Feat - Introduce `@stylistic/eslint-plugin`
2 parents d25207e + 0dc93bd commit 6ec52b3

30 files changed

+165
-101
lines changed

eslint.config.js

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
const eslint = require("@eslint/js");
33
const importPlugin = require('eslint-plugin-import');
44
const tseslint = require("typescript-eslint");
5+
const { defineConfig } = require('eslint/config');
56
const angular = require("angular-eslint");
67
const ngrx = require("@ngrx/eslint-plugin/v9");
8+
const stylistic = require('@stylistic/eslint-plugin');
79

8-
module.exports = tseslint.config(
10+
module.exports = defineConfig(
911
{
1012
files: ["**/*.ts"],
1113
extends: [
1214
eslint.configs.recommended,
15+
stylistic.configs.recommended,
1316
...tseslint.configs.recommended,
1417
...tseslint.configs.recommendedTypeChecked,
1518
...tseslint.configs.stylistic,
@@ -118,6 +121,62 @@ module.exports = tseslint.config(
118121
]
119122
}
120123
],
124+
"@stylistic/semi": ["error", "always"],
125+
"@stylistic/member-delimiter-style": [
126+
"error",
127+
{
128+
"multiline": {
129+
"delimiter": "comma",
130+
"requireLast": true
131+
},
132+
"singleline": {
133+
"delimiter": "comma",
134+
"requireLast": false
135+
},
136+
"overrides": {
137+
"interface": {
138+
"multiline": {
139+
"delimiter": "semi",
140+
"requireLast": true
141+
}
142+
}
143+
}
144+
}
145+
],
146+
"@stylistic/space-infix-ops": [
147+
"error",
148+
{
149+
"ignoreTypes": true,
150+
}
151+
],
152+
"@stylistic/no-multi-spaces": [
153+
"error",
154+
{
155+
"exceptions": {
156+
"TSEnumMember": true
157+
}
158+
}
159+
],
160+
"@stylistic/indent": [
161+
"error",
162+
2,
163+
{
164+
ignoredNodes: ["ObjectExpression"]
165+
}
166+
],
167+
"@stylistic/brace-style": [
168+
"error",
169+
"1tbs"
170+
],
171+
"@stylistic/operator-linebreak": [
172+
"error",
173+
"before",
174+
{
175+
"overrides": {
176+
"=": "after"
177+
}
178+
}
179+
],
121180
"import/no-extraneous-dependencies": [
122181
"error",
123182
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"@angular/language-service": "20.3.2",
8080
"@bartholomej/ngx-translate-extract": "8.0.2",
8181
"@ngrx/eslint-plugin": "20.0.1",
82+
"@stylistic/eslint-plugin": "5.4.0",
8283
"@types/jasmine": "5.1.9",
8384
"@types/jasminewd2": "2.0.13",
8485
"@types/luxon": "3.7.1",

src/app/app.component.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ export class AppComponent implements OnInit, OnDestroy {
9090
this.logout(null);
9191
} else if (userData !== null && !this.loggedIn) {
9292
this.authenticationService
93-
.isAuthenticated()
94-
.pipe(take(1))
95-
.subscribe((loggedIn: boolean): void => loggedIn
96-
? this.store.dispatch(authenticationActions.loginSuccess({ userData }))
97-
: this.logout(marker('messages.authentication.timeout')),
98-
);
93+
.isAuthenticated()
94+
.pipe(take(1))
95+
.subscribe((loggedIn: boolean): void => loggedIn
96+
? this.store.dispatch(authenticationActions.loginSuccess({ userData }))
97+
: this.logout(marker('messages.authentication.timeout')),
98+
);
9999
}
100100
}),
101101
);
@@ -158,11 +158,13 @@ export class AppComponent implements OnInit, OnDestroy {
158158
* store.
159159
*/
160160
private checkToken(): void {
161-
this.authenticationService.isAuthenticated().pipe(
162-
take(1),
163-
filter((authenticated: boolean): boolean => this.loggedIn && !authenticated),
164-
)
165-
.subscribe((): void => this.logout(marker('messages.authentication.timeout')));
161+
this.authenticationService
162+
.isAuthenticated()
163+
.pipe(
164+
take(1),
165+
filter((authenticated: boolean): boolean => this.loggedIn && !authenticated),
166+
)
167+
.subscribe((): void => this.logout(marker('messages.authentication.timeout')));
166168
}
167169

168170
/**

src/app/shared/components/footer/footer.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ export class FooterComponent implements OnInit, OnDestroy, AfterViewInit {
7272
setTimeout((): void => {
7373
const height = parseInt(this.footerContainer.nativeElement.offsetHeight, 10);
7474

75-
this.topOffset = `${ height }px`;
76-
this.topMargin = `-${ height }px`;
75+
this.topOffset = `${height}px`;
76+
this.topMargin = `-${height}px`;
7777
}, 0);
7878
}
7979

src/app/shared/components/header/header.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { authenticationActions, authenticationSelectors, layoutActions, layoutSe
4343
})
4444

4545
export class HeaderComponent implements OnInit, OnDestroy {
46-
4746
@ViewChild('userMenu') private readonly userMenu!: MatMenuTrigger;
4847

4948
public profile: UserProfileInterface|null = null;

src/app/shared/factories/http-loader.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
99
export const httpLoaderFactory = (httpClient: HttpClient): TranslateHttpLoader => {
1010
const ts = Math.round((new Date()).getTime() / 1000);
1111

12-
return new TranslateHttpLoader(httpClient, './assets/i18n/', `.json?t=${ ts }`);
12+
return new TranslateHttpLoader(httpClient, './assets/i18n/', `.json?t=${ts}`);
1313
};

src/app/shared/interceptors/backend-version.interceptor.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@ export class BackendVersionInterceptor implements HttpInterceptor {
4747
* user to reload application OR continue using it with old version.
4848
*/
4949
private handle(httpEvent: Observable<HttpEvent<any>>): void {
50-
const apiUrl = ConfigurationService.configuration.apiUrl;
50+
const apiUrl: string = ConfigurationService.configuration.apiUrl;
5151

52-
httpEvent.pipe(
53-
filter((event: any): boolean => event instanceof HttpResponse),
54-
filter((event: HttpResponse<any>): boolean => new URL(event.url ?? '').host === new URL(apiUrl).host),
55-
filter((event: HttpResponse<any>): boolean => !event.url?.includes('/version')),
56-
filter((event: HttpResponse<any>): boolean => event.headers.has('X-API-VERSION')),
57-
withLatestFrom(this.store.select(versionSelectors.selectBackendVersion)),
58-
filter(([event, version]: [HttpResponse<any>, string]): boolean =>
59-
version !== '0.0.0' && event.headers.get('X-API-VERSION') !== version,
60-
),
61-
map(([event]: [HttpResponse<any>, string]): string => event.headers.get('X-API-VERSION') ?? ''),
62-
)
63-
.subscribe((backendVersion: string): void => this.store.dispatch(versionActions.newBackendVersion({ backendVersion })));
52+
httpEvent
53+
.pipe(
54+
filter((event: any): boolean => event instanceof HttpResponse),
55+
filter((event: HttpResponse<any>): boolean => new URL(event.url ?? '').host === new URL(apiUrl).host),
56+
filter((event: HttpResponse<any>): boolean => !event.url?.includes('/version')),
57+
filter((event: HttpResponse<any>): boolean => event.headers.has('X-API-VERSION')),
58+
withLatestFrom(this.store.select(versionSelectors.selectBackendVersion)),
59+
filter(([event, version]: [HttpResponse<any>, string]): boolean =>
60+
version !== '0.0.0' && event.headers.get('X-API-VERSION') !== version,
61+
),
62+
map(([event]: [HttpResponse<any>, string]): string => event.headers.get('X-API-VERSION') ?? ''),
63+
)
64+
.subscribe((backendVersion: string): void => this.store.dispatch(versionActions.newBackendVersion({ backendVersion })));
6465
}
6566
}

src/app/shared/interfaces/error-message-client.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ErrorMessageServerInterface} from 'src/app/shared/interfaces/error-message-server.interface';
1+
import { ErrorMessageServerInterface } from 'src/app/shared/interfaces/error-message-server.interface';
22

33
/**
44
* Interface definition for client side error messages - server side error

src/app/shared/interfaces/http-cache.interface.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/app/shared/interfaces/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export * from 'src/app/shared/interfaces/environment.interface';
44
export * from 'src/app/shared/interfaces/error-message.interface';
55
export * from 'src/app/shared/interfaces/error-message-client.interface';
66
export * from 'src/app/shared/interfaces/error-message-server.interface';
7-
export * from 'src/app/shared/interfaces/http-cache.interface';
87
export * from 'src/app/shared/interfaces/language-value.interface';
98
export * from 'src/app/shared/interfaces/locale-value.interface';
109
export * from 'src/app/shared/interfaces/localization.interface';

0 commit comments

Comments
 (0)