Skip to content

Commit f1e6a60

Browse files
chore: update eslint rules and fix related issues (#10)
1 parent 45f5a10 commit f1e6a60

File tree

14 files changed

+49
-30
lines changed

14 files changed

+49
-30
lines changed

.eslintrc.json

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"browser": true,
55
"node": true
66
},
7-
"extends": ["plugin:@angular-eslint/recommended"],
8-
"rules": {},
7+
"extends": ["plugin:@angular-eslint/recommended", "plugin:prettier/recommended"],
8+
"rules": { "prettier/prettier": "error" },
99
// Eslint for HTML files
1010
"overrides": [
1111
{
@@ -20,7 +20,7 @@
2020
],
2121
"rules": {
2222
// Custom rules for HTML by Osmosys
23-
"max-len": "warn"
23+
"max-len": ["warn", { "code": 100 }]
2424
}
2525
},
2626
// Custom rules for TypeScript
@@ -42,6 +42,17 @@
4242
"rules": {
4343
// Custom rules for typescript by Osmosys
4444
"@typescript-eslint/no-explicit-any": "error",
45+
"padding-line-between-statements": [
46+
"error",
47+
{ "blankLine": "always", "prev": "*", "next": "function" },
48+
{ "blankLine": "always", "prev": "function", "next": "*" },
49+
{ "blankLine": "always", "prev": "*", "next": "if" },
50+
{ "blankLine": "always", "prev": "if", "next": "*" },
51+
{ "blankLine": "always", "prev": "*", "next": "for" },
52+
{ "blankLine": "always", "prev": "for", "next": "*" },
53+
{ "blankLine": "always", "prev": "*", "next": "while" },
54+
{ "blankLine": "always", "prev": "while", "next": "*" }
55+
],
4556
"arrow-body-style": [
4657
"error",
4758
"as-needed",
@@ -145,11 +156,10 @@
145156
"no-empty-function": [
146157
"error",
147158
{
148-
"allow": ["arrowFunctions", "functions", "methods"]
159+
"allow": ["arrowFunctions", "functions", "methods", "constructors"]
149160
}
150161
],
151162
"no-bitwise": "error",
152-
"no-console": "warn",
153163
"no-new-wrappers": "error",
154164
"no-debugger": "error",
155165
"constructor-super": "error",
@@ -159,7 +169,8 @@
159169
"@typescript-eslint/no-inferrable-types": "error",
160170
"@typescript-eslint/no-misused-new": "error",
161171
"@typescript-eslint/no-non-null-assertion": "error",
162-
"no-shadow": "error",
172+
"no-shadow": "off",
173+
"@typescript-eslint/no-shadow": ["error"],
163174
"dot-notation": [
164175
"error",
165176
{
@@ -349,7 +360,8 @@
349360
"variables": true
350361
}
351362
],
352-
"no-useless-constructor": "error",
363+
"no-useless-constructor": "off",
364+
"@typescript-eslint/no-useless-constructor": "error",
353365
"semi": ["error", "always"],
354366
"space-before-function-paren": [
355367
"error",
@@ -362,7 +374,8 @@
362374
"require-await": "off",
363375
"no-return-await": "error",
364376
"space-infix-ops": "error",
365-
"object-curly-spacing": ["error", "always"]
377+
"object-curly-spacing": ["error", "always"],
378+
"import/prefer-default-export": "off"
366379
}
367380
},
368381
// Configuration for unit and e2e spec files
@@ -373,18 +386,18 @@
373386
}
374387
},
375388
/**
376-
* This extra piece of configuration is only necessary if you make use of inline
377-
* templates within Component metadata, e.g.:
378-
*/
389+
* This extra piece of configuration is only necessary if you make use of inline
390+
* templates within Component metadata, e.g.:
391+
*/
379392
{
380393
"files": ["*.component.ts"],
381394
"parser": "@typescript-eslint/parser",
382395
"parserOptions": {
383396
"ecmaVersion": 2020,
384397
"sourceType": "module"
385398
},
386-
"plugins": ["@angular-eslint/template"],
399+
"plugins": ["@angular-eslint/template", "prettier"],
387400
"processor": "@angular-eslint/template/extract-inline-html"
388401
}
389402
]
390-
}
403+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
99
"test": "ng test",
10-
"lint": "ng lint",
10+
"lint": "ng lint --max-warnings=0",
1111
"prettier-format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\""
1212
},
1313
"engines": {

src/app/app.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
2+
// eslint-disable-next-line import/no-extraneous-dependencies
23
import { TranslateService } from '@ngx-translate/core';
4+
// eslint-disable-next-line import/no-extraneous-dependencies
35
import { PrimeNGConfig } from 'primeng/api';
46
import LanguageService from './shared/services/language.service';
57
import LANGUAGES from './shared/constants/language.constants';
@@ -10,7 +12,11 @@ import LANGUAGES from './shared/constants/language.constants';
1012
})
1113
export default class AppComponent implements OnInit {
1214
// eslint-disable-next-line no-useless-constructor, no-empty-function
13-
constructor(private primengConfig: PrimeNGConfig, private translateService: TranslateService, private languageService: LanguageService) { }
15+
constructor(
16+
private primengConfig: PrimeNGConfig,
17+
private translateService: TranslateService,
18+
private languageService: LanguageService,
19+
) {}
1420

1521
ngOnInit() {
1622
this.initializePrimeNgConfigs();
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { CanActivateFn } from '@angular/router';
22

3-
const authGuard: CanActivateFn = (route, state) => {
4-
console.log(route, state);
5-
return true;
6-
};
3+
const authGuard: CanActivateFn = () => true;
74

85
export default authGuard;

src/app/core/interceptors/http-config-interceptor/http-config.interceptor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
44

55
@Injectable()
66
export default class HttpConfigInterceptor implements HttpInterceptor {
7+
// eslint-disable-next-line class-methods-use-this
78
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
89
return next.handle(request);
910
}

src/app/features/landing/components/landing-footer/landing-footer.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ <h4 class="footer-logo">{{ 'COMMON.BRAND_NAME' | translate }}</h4>
1515

1616
<div class="col-12 md:col-10 lg:col-7">
1717
<div class="grid">
18-
<!-- Assuming you have a translation service that provides the translation for a given key -->
1918
<div class="col-12 md:col-3">
2019
<h4 class="footer-link-header">{{ 'LANDING_PAGE.FOOTER.COMPANY' | translate }}</h4>
2120
<a class="footer-link">{{ 'LANDING_PAGE.FOOTER.ABOUT_US' | translate }}</a>

src/app/features/landing/components/landing-footer/landing-footer.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import ILanguage from '../../../../shared/models/shared.model';
1111
styleUrls: ['./landing-footer.component.scss'],
1212
})
1313
export default class LandingFooterComponent implements OnInit {
14-
1514
availableLanguages: ILanguage[] | undefined;
1615

1716
selectedLanguage: ILanguage | undefined;
@@ -20,9 +19,8 @@ export default class LandingFooterComponent implements OnInit {
2019
constructor(
2120
public layoutService: LayoutService,
2221
public router: Router,
23-
private languageService: LanguageService,
24-
// eslint-disable-next-line no-empty-function
25-
) { }
22+
private languageService: LanguageService, // eslint-disable-next-line no-empty-function
23+
) {}
2624

2725
ngOnInit() {
2826
this.initializeData();

src/app/features/landing/components/landing-hero/landing-hero.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
<div class="col-md-6 flex-grow-1">
44
<header class="hero-content">
55
<h1 class="hero-content-header">
6-
<span class="font-light block">{{ "LANDING_PAGE.HERO.HEADING_FIRST" | translate}}</span>{{ "LANDING_PAGE.HERO.HEADING_SECOND" | translate}}
6+
<span class="font-light block">{{ 'LANDING_PAGE.HERO.HEADING_FIRST' | translate }}</span
7+
>{{ 'LANDING_PAGE.HERO.HEADING_SECOND' | translate }}
78
</h1>
89
<p class="hero-content-description">
9-
{{ "LANDING_PAGE.HERO.DESCRIPTION" | translate}}
10+
{{ 'LANDING_PAGE.HERO.DESCRIPTION' | translate }}
1011
</p>
1112
<p-button
1213
[label]="'LANDING_PAGE.HERO.CTA' | translate"

src/app/features/landing/components/landing-hero/landing-hero.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Router } from '@angular/router';
88
})
99
export default class LandingHeroComponent {
1010
// eslint-disable-next-line no-useless-constructor, no-empty-function
11-
constructor(public router: Router) { }
11+
constructor(public router: Router) {}
1212

1313
navigateToLogin() {
1414
this.router.navigate(['/auth/login']);

src/app/features/landing/components/navigation-bar/navigation-bar.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Router } from '@angular/router';
88
})
99
export default class NavigationBarComponent {
1010
// eslint-disable-next-line no-useless-constructor, no-empty-function
11-
constructor(private router: Router) { }
11+
constructor(private router: Router) {}
1212

1313
navigateToSection(sectionName: string) {
1414
this.router.navigate(['/'], { fragment: sectionName });

src/app/features/landing/landing.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import { Router } from '@angular/router';
77
})
88
export default class LandingComponent {
99
// eslint-disable-next-line no-useless-constructor, no-empty-function
10-
constructor(public router: Router) { }
10+
constructor(public router: Router) {}
1111
}

src/app/shared/services/language.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export default class LanguageService {
2020
let defaultLanguage = LANGUAGES.AVAILABLE_LANGUAGES[0];
2121
const browserLanguage = navigator.language;
2222
const userLanguageCode = browserLanguage?.split('-')[0];
23-
const existingLanguageForUser = LANGUAGES.AVAILABLE_LANGUAGES.find((lang) => lang.code === userLanguageCode);
23+
const existingLanguageForUser = LANGUAGES.AVAILABLE_LANGUAGES.find(
24+
(lang) => lang.code === userLanguageCode,
25+
);
2426

2527
if (existingLanguageForUser) {
2628
defaultLanguage = existingLanguageForUser;

src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- eslint-disable prettier/prettier -->
12
<!doctype html>
23
<html lang="en">
34
<head>

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ import AppModule from './app/app.module';
66

77
platformBrowserDynamic()
88
.bootstrapModule(AppModule)
9+
// eslint-disable-next-line no-console
910
.catch((err) => console.error(err));

0 commit comments

Comments
 (0)