diff --git a/generators/app/__snapshots__/generator.spec.mjs.snap b/generators/app/__snapshots__/generator.spec.mjs.snap index 9c019f961..26b7dc914 100644 --- a/generators/app/__snapshots__/generator.spec.mjs.snap +++ b/generators/app/__snapshots__/generator.spec.mjs.snap @@ -8,9 +8,6 @@ exports[`SubGenerator app of ionic JHipster blueprint > run > should succeed 1`] "../ionic4j/.editorconfig": { "stateCleared": "modified", }, - "../ionic4j/.eslintrc.json": { - "stateCleared": "modified", - }, "../ionic4j/.gitattributes": { "stateCleared": "modified", }, @@ -77,6 +74,9 @@ exports[`SubGenerator app of ionic JHipster blueprint > run > should succeed 1`] "../ionic4j/cypress/tsconfig.json": { "stateCleared": "modified", }, + "../ionic4j/eslint.config.mjs": { + "stateCleared": "modified", + }, "../ionic4j/ionic.config.json": { "stateCleared": "modified", }, @@ -473,9 +473,6 @@ exports[`SubGenerator app of ionic JHipster blueprint > run > should succeed 1`] "../ionic4j/tsconfig.spec.json": { "stateCleared": "modified", }, - "../ionic4j/tslint.json": { - "stateCleared": "modified", - }, ".editorconfig": { "stateCleared": "modified", }, @@ -520,9 +517,6 @@ exports[`SubGenerator app of ionic JHipster blueprint > with custom ionic path > "../ionic-app/.editorconfig": { "stateCleared": "modified", }, - "../ionic-app/.eslintrc.json": { - "stateCleared": "modified", - }, "../ionic-app/.gitattributes": { "stateCleared": "modified", }, @@ -589,6 +583,9 @@ exports[`SubGenerator app of ionic JHipster blueprint > with custom ionic path > "../ionic-app/cypress/tsconfig.json": { "stateCleared": "modified", }, + "../ionic-app/eslint.config.mjs": { + "stateCleared": "modified", + }, "../ionic-app/ionic.config.json": { "stateCleared": "modified", }, @@ -985,9 +982,6 @@ exports[`SubGenerator app of ionic JHipster blueprint > with custom ionic path > "../ionic-app/tsconfig.spec.json": { "stateCleared": "modified", }, - "../ionic-app/tslint.json": { - "stateCleared": "modified", - }, ".editorconfig": { "stateCleared": "modified", }, diff --git a/generators/ionic/__snapshots__/generator.spec.mjs.snap b/generators/ionic/__snapshots__/generator.spec.mjs.snap index 7765ebf00..552052535 100644 --- a/generators/ionic/__snapshots__/generator.spec.mjs.snap +++ b/generators/ionic/__snapshots__/generator.spec.mjs.snap @@ -8,9 +8,6 @@ exports[`SubGenerator ionic of ionic JHipster blueprint > with jwt authenticatio ".editorconfig": { "stateCleared": "modified", }, - ".eslintrc.json": { - "stateCleared": "modified", - }, ".gitattributes": { "stateCleared": "modified", }, @@ -77,6 +74,9 @@ exports[`SubGenerator ionic of ionic JHipster blueprint > with jwt authenticatio "cypress/tsconfig.json": { "stateCleared": "modified", }, + "eslint.config.mjs": { + "stateCleared": "modified", + }, "ionic.config.json": { "stateCleared": "modified", }, @@ -473,9 +473,6 @@ exports[`SubGenerator ionic of ionic JHipster blueprint > with jwt authenticatio "tsconfig.spec.json": { "stateCleared": "modified", }, - "tslint.json": { - "stateCleared": "modified", - }, } `; @@ -487,9 +484,6 @@ exports[`SubGenerator ionic of ionic JHipster blueprint > with oauth2 authentica ".editorconfig": { "stateCleared": "modified", }, - ".eslintrc.json": { - "stateCleared": "modified", - }, ".gitattributes": { "stateCleared": "modified", }, @@ -559,6 +553,9 @@ exports[`SubGenerator ionic of ionic JHipster blueprint > with oauth2 authentica "cypress/tsconfig.json": { "stateCleared": "modified", }, + "eslint.config.mjs": { + "stateCleared": "modified", + }, "ionic.config.json": { "stateCleared": "modified", }, @@ -979,8 +976,5 @@ exports[`SubGenerator ionic of ionic JHipster blueprint > with oauth2 authentica "tsconfig.spec.json": { "stateCleared": "modified", }, - "tslint.json": { - "stateCleared": "modified", - }, } `; diff --git a/generators/ionic/files.mjs b/generators/ionic/files.mjs index 27c498244..02ad07b8d 100644 --- a/generators/ionic/files.mjs +++ b/generators/ionic/files.mjs @@ -20,11 +20,17 @@ const PAGES_DIR = 'src/app/pages/'; const E2E_ENTITY_DIR = 'cypress/support/pages/'; const E2E_TEST_DIR = 'cypress/e2e/'; +const eslintConfigTemplate = sourceFile => ({ + sourceFile, + destinationFile: ctx => sourceFile.replace('eslint.config.js', ctx.eslintConfigFile), +}); + export const files = { client: [ { templates: [ 'capacitor.config.ts', + eslintConfigTemplate('eslint.config.js.jhi.ionic'), 'ionic.config.json', 'src/app/interceptors/auth.interceptor.ts', 'src/app/pages/home/home.page.scss', diff --git a/generators/ionic/generator.mjs b/generators/ionic/generator.mjs index 70143db2e..eb1e3adcc 100644 --- a/generators/ionic/generator.mjs +++ b/generators/ionic/generator.mjs @@ -134,6 +134,14 @@ export default class extends BaseApplicationGenerator { }); } + get [BaseApplicationGenerator.LOADING]() { + return this.asLoadingTaskGroup({ + loading({ application }) { + application.typescriptEslint = true; + }, + }); + } + get [BaseApplicationGenerator.WRITING]() { return this.asWritingTaskGroup({ async writingTemplateTask({ application }) { @@ -196,11 +204,10 @@ export default class extends BaseApplicationGenerator { get [BaseApplicationGenerator.POST_WRITING]() { return this.asPostWritingTaskGroup({ - ignoreEslint9ConfigFile({ application }) { - const eslintConfigFile = this.env.sharedFs.get(this.destinationPath(application.eslintConfigFile)); - if (eslintConfigFile) { - delete eslintConfigFile.state; - } + addPrettierConfig({ source }) { + source.mergePrettierConfig({ + overrides: [{ files: '*.html', options: { parser: 'angular' } }], + }); }, customizePackageJson({ application }) { const { baseName } = this.jhipsterConfig; diff --git a/generators/ionic/resources/base/.eslintrc.json b/generators/ionic/resources/base/.eslintrc.json deleted file mode 100644 index 207008d0b..000000000 --- a/generators/ionic/resources/base/.eslintrc.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "root": true, - "ignorePatterns": ["projects/**/*"], - "overrides": [ - { - "files": ["*.ts"], - "parserOptions": { - "project": ["tsconfig.json", "e2e/tsconfig.json"], - "createDefaultProgram": true - }, - "extends": ["plugin:@angular-eslint/recommended", "plugin:@angular-eslint/template/process-inline-templates"], - "rules": { - "@angular-eslint/component-class-suffix": [ - "error", - { - "suffixes": ["Page", "Component"] - } - ], - "@angular-eslint/component-selector": [ - "error", - { - "type": "element", - "prefix": "app", - "style": "kebab-case" - } - ], - "@angular-eslint/directive-selector": [ - "error", - { - "type": "attribute", - "prefix": "app", - "style": "camelCase" - } - ] - } - }, - { - "files": ["*.html"], - "extends": ["plugin:@angular-eslint/template/recommended"], - "rules": {} - } - ] -} diff --git a/generators/ionic/resources/base/package.json b/generators/ionic/resources/base/package.json index 6d5d53149..9f10b5309 100644 --- a/generators/ionic/resources/base/package.json +++ b/generators/ionic/resources/base/package.json @@ -15,6 +15,7 @@ "ng": "ng", "prettier": "prettier --write \"{,e2e/**/,src/**/}*.{js,json,html,md,ts,css,scss,yml}\" --loglevel silent", "start": "ionic serve", + "pretest": "npm run lint", "test": "ng test --coverage", "test:watch": "ng test --watch" }, @@ -54,10 +55,6 @@ "devDependencies": { "@angular-builders/jest": "~18.0.0-beta.3", "@angular-devkit/build-angular": "~18.2.0", - "@angular-eslint/builder": "~18.4.0", - "@angular-eslint/eslint-plugin": "~18.4.0", - "@angular-eslint/eslint-plugin-template": "~18.4.0", - "@angular-eslint/template-parser": "~18.4.0", "@angular/cli": "~18.2.0", "@angular/compiler": "~18.2.0", "@angular/compiler-cli": "~18.2.0", @@ -68,18 +65,20 @@ "@ionic/cli": "^7.2.0", "@types/jest": "29.5.14", "@types/node": "^22.1.0", - "@typescript-eslint/eslint-plugin": "8.12.2", - "@typescript-eslint/parser": "8.12.2", + "angular-eslint": "18.4.0", "cypress": "13.15.1", "eslint": "^9.12.0", + "eslint-plugin-cypress": "4.0.0", "eslint-plugin-import": "2.31.0", "eslint-plugin-jsdoc": "50.4.3", "eslint-plugin-prefer-arrow": "1.2.3", + "globals": "15.11.0", "ionic-mocks-jest": "1.3.3", "jest": "29.7.0", "jest-localstorage-mock": "2.4.26", "jest-preset-angular": "14.2.4", "prettier": "3.3.3", - "typescript": "~5.5.3" + "typescript": "~5.5.3", + "typescript-eslint": "8.12.2" } } diff --git a/generators/ionic/resources/base/src/app/pages/entities/entities.page.ts b/generators/ionic/resources/base/src/app/pages/entities/entities.page.ts index f40b7807f..2d03ea415 100644 --- a/generators/ionic/resources/base/src/app/pages/entities/entities.page.ts +++ b/generators/ionic/resources/base/src/app/pages/entities/entities.page.ts @@ -7,7 +7,7 @@ import { NavController } from '@ionic/angular'; styleUrls: ['entities.page.scss'], }) export class EntitiesPage { - entities: Array = [ + entities: any[] = [ /* jhipster-needle-add-entity-page - JHipster will add entity pages here */ ]; diff --git a/generators/ionic/resources/base/src/app/pages/tabs/tabs.page.spec.ts b/generators/ionic/resources/base/src/app/pages/tabs/tabs.page.spec.ts index ec079a20d..c20782ecc 100644 --- a/generators/ionic/resources/base/src/app/pages/tabs/tabs.page.spec.ts +++ b/generators/ionic/resources/base/src/app/pages/tabs/tabs.page.spec.ts @@ -1,9 +1,10 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { TranslateModule, TranslateStore } from '@ngx-translate/core'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; +import { provideHttpClient } from '@angular/common/http'; import { TabsPage } from './tabs.page'; -import { TranslateModule, TranslateStore } from '@ngx-translate/core'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('TabsPage', () => { let component: TabsPage; @@ -13,8 +14,8 @@ describe('TabsPage', () => { TestBed.configureTestingModule({ declarations: [TabsPage], schemas: [CUSTOM_ELEMENTS_SCHEMA], - imports: [HttpClientTestingModule, TranslateModule.forChild()], - providers: [TranslateStore], + imports: [TranslateModule.forChild()], + providers: [TranslateStore, provideHttpClient(), provideHttpClientTesting()], }).compileComponents(); })); diff --git a/generators/ionic/resources/base/src/app/services/api/api.service.spec.ts b/generators/ionic/resources/base/src/app/services/api/api.service.spec.ts index a16da68b0..0e0ff71d2 100644 --- a/generators/ionic/resources/base/src/app/services/api/api.service.spec.ts +++ b/generators/ionic/resources/base/src/app/services/api/api.service.spec.ts @@ -1,11 +1,13 @@ import { TestBed } from '@angular/core/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; +import { provideHttpClient } from '@angular/common/http'; + import { ApiService } from './api.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ApiService', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + providers: [provideHttpClient(), provideHttpClientTesting()], }), ); diff --git a/generators/ionic/resources/base/src/app/services/api/api.service.ts b/generators/ionic/resources/base/src/app/services/api/api.service.ts index 643880ae4..d412091c4 100644 --- a/generators/ionic/resources/base/src/app/services/api/api.service.ts +++ b/generators/ionic/resources/base/src/app/services/api/api.service.ts @@ -20,7 +20,7 @@ export class ApiService { // Support easy query params for GET requests if (params) { reqOpts.params = new HttpParams(); - for (let k in params) { + for (const k in params) { reqOpts.params.set(k, params[k]); } } diff --git a/generators/ionic/resources/base/src/app/services/auth/account.service.spec.ts b/generators/ionic/resources/base/src/app/services/auth/account.service.spec.ts index 24b9d051d..e7e8ef529 100644 --- a/generators/ionic/resources/base/src/app/services/auth/account.service.spec.ts +++ b/generators/ionic/resources/base/src/app/services/auth/account.service.spec.ts @@ -1,11 +1,13 @@ import { TestBed } from '@angular/core/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; +import { provideHttpClient } from '@angular/common/http'; + import { AccountService } from './account.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AccountService', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + providers: [provideHttpClient(), provideHttpClientTesting()], }), ); diff --git a/generators/ionic/resources/base/src/app/services/auth/account.service.ts b/generators/ionic/resources/base/src/app/services/auth/account.service.ts index 418ee4f65..ffdb70e57 100644 --- a/generators/ionic/resources/base/src/app/services/auth/account.service.ts +++ b/generators/ionic/resources/base/src/app/services/auth/account.service.ts @@ -62,7 +62,7 @@ export class AccountService { } identity(force?: boolean): Promise { - if (force === true) { + if (force) { this.userIdentity = undefined; } diff --git a/generators/ionic/resources/base/src/app/services/auth/user-route-access.service.spec.ts b/generators/ionic/resources/base/src/app/services/auth/user-route-access.service.spec.ts index df45e25b1..df211820b 100644 --- a/generators/ionic/resources/base/src/app/services/auth/user-route-access.service.spec.ts +++ b/generators/ionic/resources/base/src/app/services/auth/user-route-access.service.spec.ts @@ -1,12 +1,15 @@ import { TestBed } from '@angular/core/testing'; -import { UserRouteAccessService } from './user-route-access.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; +import { provideHttpClient } from '@angular/common/http'; + +import { UserRouteAccessService } from './user-route-access.service'; describe('UserRouteAccessService', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientTestingModule, RouterTestingModule], + imports: [RouterTestingModule], + providers: [provideHttpClient(), provideHttpClientTesting()], }), ); diff --git a/generators/ionic/resources/base/src/app/services/utils/data-util.service.ts b/generators/ionic/resources/base/src/app/services/utils/data-util.service.ts index d2524b13a..816780d79 100644 --- a/generators/ionic/resources/base/src/app/services/utils/data-util.service.ts +++ b/generators/ionic/resources/base/src/app/services/utils/data-util.service.ts @@ -35,8 +35,6 @@ export interface JhiFileLoadError { providedIn: 'root', }) export class JhiDataUtils { - constructor() {} - /** * Method to abbreviate the text given */ @@ -85,7 +83,7 @@ export class JhiDataUtils { /** * Method to convert the file to base64 */ - toBase64(file: File, cb: Function): void { + toBase64(file: File, cb: (data: string) => void): void { const fileReader: FileReader = new FileReader(); fileReader.onload = function (e: any) { const base64Data: string = e.target.result.substr(e.target.result.indexOf('base64,') + 'base64,'.length); diff --git a/generators/ionic/resources/base/src/zone-flags.ts b/generators/ionic/resources/base/src/zone-flags.ts index c84245fd3..e999ae9d1 100644 --- a/generators/ionic/resources/base/src/zone-flags.ts +++ b/generators/ionic/resources/base/src/zone-flags.ts @@ -2,5 +2,4 @@ * Prevents Angular change detection from * running with certain Web Component callbacks */ -// eslint-disable-next-line no-underscore-dangle (window as any).__Zone_disable_customElements = true; diff --git a/generators/ionic/resources/base/tsconfig.json b/generators/ionic/resources/base/tsconfig.json index 6de6855f7..8b6dc8145 100644 --- a/generators/ionic/resources/base/tsconfig.json +++ b/generators/ionic/resources/base/tsconfig.json @@ -8,6 +8,7 @@ "declaration": false, "downlevelIteration": true, "experimentalDecorators": true, + // "strict": true, "moduleResolution": "node", "importHelpers": true, "target": "es2022", diff --git a/generators/ionic/resources/base/tslint.json b/generators/ionic/resources/base/tslint.json deleted file mode 100644 index 192d112c3..000000000 --- a/generators/ionic/resources/base/tslint.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "extends": "tslint:recommended", - "rulesDirectory": ["codelyzer"], - "rules": { - "array-type": false, - "arrow-parens": false, - "deprecation": { - "severity": "warn" - }, - "import-blacklist": [true, "rxjs/Rx"], - "interface-name": false, - "max-classes-per-file": false, - "max-line-length": [true, 140], - "member-access": false, - "member-ordering": [ - true, - { - "order": ["static-field", "instance-field", "static-method", "instance-method"] - } - ], - "no-consecutive-blank-lines": false, - "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], - "no-empty": false, - "no-inferrable-types": [true, "ignore-params"], - "no-non-null-assertion": true, - "no-redundant-jsdoc": true, - "no-switch-case-fall-through": true, - "no-use-before-declare": true, - "no-var-requires": false, - "object-literal-key-quotes": [true, "as-needed"], - "object-literal-sort-keys": false, - "ordered-imports": false, - "quotemark": [true, "single"], - "trailing-comma": false, - "no-output-on-prefix": true, - "no-inputs-metadata-property": true, - "no-host-metadata-property": true, - "no-input-rename": true, - "no-output-rename": true, - "use-lifecycle-interface": true, - "use-pipe-transform-interface": true, - "one-variable-per-declaration": false, - "component-class-suffix": [true, "Page", "Component"], - "directive-class-suffix": true, - "directive-selector": [true, "attribute", "app", "camelCase"], - "component-selector": [true, "element", "app", "page", "kebab-case"] - } -} diff --git a/generators/ionic/resources/jwt/src/app/interceptors/auth-expired.interceptor.ts b/generators/ionic/resources/jwt/src/app/interceptors/auth-expired.interceptor.ts index 607a25e46..3c3ab3d8d 100644 --- a/generators/ionic/resources/jwt/src/app/interceptors/auth-expired.interceptor.ts +++ b/generators/ionic/resources/jwt/src/app/interceptors/auth-expired.interceptor.ts @@ -11,7 +11,9 @@ export class AuthExpiredInterceptor implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler): Observable> { return next.handle(request).pipe( tap( - (event: HttpEvent) => {}, + (_event: HttpEvent) => { + // Do nothing + }, (err: any) => { if (err instanceof HttpErrorResponse) { if (err.status === 401) { diff --git a/generators/ionic/resources/jwt/src/app/interceptors/auth.interceptor.ts b/generators/ionic/resources/jwt/src/app/interceptors/auth.interceptor.ts index ed7484b2a..ad7bfc1b0 100644 --- a/generators/ionic/resources/jwt/src/app/interceptors/auth.interceptor.ts +++ b/generators/ionic/resources/jwt/src/app/interceptors/auth.interceptor.ts @@ -9,8 +9,6 @@ const AUTHENTICATION_TOKEN = 'jhi-authenticationtoken'; export class AuthInterceptor implements HttpInterceptor { private servicesEndpoint = ApiService.API_URL.replace('api', 'services'); - constructor() {} - intercept(request: HttpRequest, next: HttpHandler): Observable> { if ( !request || @@ -21,7 +19,7 @@ export class AuthInterceptor implements HttpInterceptor { } const token = JSON.parse(localStorage.getItem(AUTHENTICATION_TOKEN) ?? sessionStorage.getItem(AUTHENTICATION_TOKEN)); - if (!!token) { + if (token) { request = request.clone({ setHeaders: { Authorization: 'Bearer ' + token, diff --git a/generators/ionic/resources/jwt/src/app/pages/signup/signup.page.ts b/generators/ionic/resources/jwt/src/app/pages/signup/signup.page.ts index 68761f0f3..b7b2dce50 100644 --- a/generators/ionic/resources/jwt/src/app/pages/signup/signup.page.ts +++ b/generators/ionic/resources/jwt/src/app/pages/signup/signup.page.ts @@ -8,7 +8,7 @@ import { UserService } from '../../services/user/user.service'; templateUrl: './signup.page.html', styleUrls: ['./signup.page.scss'], }) -export class SignupPage implements OnInit { +export class SignupPage { // The account fields for the signup form account: { login: string; @@ -27,10 +27,10 @@ export class SignupPage implements OnInit { }; // Our translated text strings - private signupErrorString: string; - private signupSuccessString: string; - private existingUserError: string; - private invalidPasswordError: string; + private signupErrorString!: string; + private signupSuccessString!: string; + private existingUserError!: string; + private invalidPasswordError!: string; constructor( public navController: NavController, @@ -46,8 +46,6 @@ export class SignupPage implements OnInit { }); } - ngOnInit() {} - doSignup() { // set login to same as email this.account.login = this.account.email; diff --git a/generators/ionic/resources/jwt/src/app/services/auth/auth-jwt.service.spec.ts b/generators/ionic/resources/jwt/src/app/services/auth/auth-jwt.service.spec.ts index 8fc80990b..8e8f4b4cf 100644 --- a/generators/ionic/resources/jwt/src/app/services/auth/auth-jwt.service.spec.ts +++ b/generators/ionic/resources/jwt/src/app/services/auth/auth-jwt.service.spec.ts @@ -1,11 +1,13 @@ import { TestBed } from '@angular/core/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; +import { provideHttpClient } from '@angular/common/http'; + import { AuthServerProvider } from './auth-jwt.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AuthServerProvider', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + providers: [provideHttpClient(), provideHttpClientTesting()], }), ); diff --git a/generators/ionic/resources/jwt/src/app/services/login/login.service.ts b/generators/ionic/resources/jwt/src/app/services/login/login.service.ts index a8fbc915b..d25cf583f 100644 --- a/generators/ionic/resources/jwt/src/app/services/login/login.service.ts +++ b/generators/ionic/resources/jwt/src/app/services/login/login.service.ts @@ -14,8 +14,6 @@ export class LoginService { ) {} login(credentials, callback?) { - const cb = callback || function () {}; - return new Promise((resolve, reject) => { this.authServerProvider.login(credentials).subscribe( data => { @@ -27,12 +25,12 @@ export class LoginService { } resolve(data); }); - return cb(); + return callback?.(); }, err => { this.logout(); reject(err); - return cb(err); + return callback?.(err); }, ); }); diff --git a/generators/ionic/resources/jwt/src/app/services/user/user.model.ts b/generators/ionic/resources/jwt/src/app/services/user/user.model.ts index 57f84fc5a..21b2b8afe 100644 --- a/generators/ionic/resources/jwt/src/app/services/user/user.model.ts +++ b/generators/ionic/resources/jwt/src/app/services/user/user.model.ts @@ -4,7 +4,7 @@ export class User { public firstName?: string; public lastName?: string; public email?: string; - public activated?: Boolean; + public activated?: boolean; public langKey?: string; public authorities?: any[]; public createdBy?: string; @@ -19,7 +19,7 @@ export class User { firstName?: string, lastName?: string, email?: string, - activated?: Boolean, + activated?: boolean, langKey?: string, authorities?: any[], createdBy?: string, diff --git a/generators/ionic/resources/jwt/src/app/services/user/user.service.ts b/generators/ionic/resources/jwt/src/app/services/user/user.service.ts index 0013877ab..31ee14929 100644 --- a/generators/ionic/resources/jwt/src/app/services/user/user.service.ts +++ b/generators/ionic/resources/jwt/src/app/services/user/user.service.ts @@ -41,7 +41,7 @@ export class UserService { * the user entered on the form. */ signup(accountInfo: any) { - return this.apiService.post('register', accountInfo, { responseType: 'text' as 'text' }).pipe(share()); + return this.apiService.post('register', accountInfo, { responseType: 'text' as const }).pipe(share()); } /** diff --git a/generators/ionic/resources/oauth2/src/app/interceptors/auth.interceptor.ts b/generators/ionic/resources/oauth2/src/app/interceptors/auth.interceptor.ts index 0f5f49e2c..37e3fa877 100644 --- a/generators/ionic/resources/oauth2/src/app/interceptors/auth.interceptor.ts +++ b/generators/ionic/resources/oauth2/src/app/interceptors/auth.interceptor.ts @@ -23,7 +23,7 @@ export class AuthInterceptor implements HttpInterceptor { try { const token = await this.authService.getValidToken(); - if (!!token) { + if (token) { request = request.clone({ setHeaders: { Authorization: `Bearer ${token.accessToken}`, diff --git a/generators/ionic/resources/oauth2/src/app/services/auth/account.service.spec.ts b/generators/ionic/resources/oauth2/src/app/services/auth/account.service.spec.ts index 24b9d051d..e7e8ef529 100644 --- a/generators/ionic/resources/oauth2/src/app/services/auth/account.service.spec.ts +++ b/generators/ionic/resources/oauth2/src/app/services/auth/account.service.spec.ts @@ -1,11 +1,13 @@ import { TestBed } from '@angular/core/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; +import { provideHttpClient } from '@angular/common/http'; + import { AccountService } from './account.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AccountService', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + providers: [provideHttpClient(), provideHttpClientTesting()], }), ); diff --git a/generators/ionic/resources/oauth2/src/app/services/auth/account.service.ts b/generators/ionic/resources/oauth2/src/app/services/auth/account.service.ts index 418ee4f65..ffdb70e57 100644 --- a/generators/ionic/resources/oauth2/src/app/services/auth/account.service.ts +++ b/generators/ionic/resources/oauth2/src/app/services/auth/account.service.ts @@ -62,7 +62,7 @@ export class AccountService { } identity(force?: boolean): Promise { - if (force === true) { + if (force) { this.userIdentity = undefined; } diff --git a/generators/ionic/resources/oauth2/src/app/services/auth/user-route-access.service.spec.ts b/generators/ionic/resources/oauth2/src/app/services/auth/user-route-access.service.spec.ts index 44cc6f39d..3d31313b5 100644 --- a/generators/ionic/resources/oauth2/src/app/services/auth/user-route-access.service.spec.ts +++ b/generators/ionic/resources/oauth2/src/app/services/auth/user-route-access.service.spec.ts @@ -1,13 +1,16 @@ import { TestBed } from '@angular/core/testing'; -import { UserRouteAccessService } from './user-route-access.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { IonicStorageModule } from '@ionic/storage-angular'; +import { provideHttpClient } from '@angular/common/http'; + +import { UserRouteAccessService } from './user-route-access.service'; describe('UserRouteAccessService', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientTestingModule, RouterTestingModule, IonicStorageModule.forRoot()], + imports: [RouterTestingModule, IonicStorageModule.forRoot()], + providers: [provideHttpClient(), provideHttpClientTesting()], }), ); diff --git a/generators/ionic/resources/oauth2/src/app/services/user/user.model.ts b/generators/ionic/resources/oauth2/src/app/services/user/user.model.ts index 57f84fc5a..21b2b8afe 100644 --- a/generators/ionic/resources/oauth2/src/app/services/user/user.model.ts +++ b/generators/ionic/resources/oauth2/src/app/services/user/user.model.ts @@ -4,7 +4,7 @@ export class User { public firstName?: string; public lastName?: string; public email?: string; - public activated?: Boolean; + public activated?: boolean; public langKey?: string; public authorities?: any[]; public createdBy?: string; @@ -19,7 +19,7 @@ export class User { firstName?: string, lastName?: string, email?: string, - activated?: Boolean, + activated?: boolean, langKey?: string, authorities?: any[], createdBy?: string, diff --git a/generators/ionic/resources/oauth2/src/app/services/user/user.service.spec.ts b/generators/ionic/resources/oauth2/src/app/services/user/user.service.spec.ts index 38c612d9b..3cc61c33a 100644 --- a/generators/ionic/resources/oauth2/src/app/services/user/user.service.spec.ts +++ b/generators/ionic/resources/oauth2/src/app/services/user/user.service.spec.ts @@ -1,12 +1,13 @@ import { TestBed } from '@angular/core/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; +import { provideHttpClient } from '@angular/common/http'; + import { UserService } from './user.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { TranslateModule } from '@ngx-translate/core'; describe('UserService', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + providers: [provideHttpClient(), provideHttpClientTesting()], }), ); diff --git a/generators/ionic/resources/oauth2/src/environments/environment.ts b/generators/ionic/resources/oauth2/src/environments/environment.ts index e3b6e407a..e9931535c 100644 --- a/generators/ionic/resources/oauth2/src/environments/environment.ts +++ b/generators/ionic/resources/oauth2/src/environments/environment.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. diff --git a/generators/ionic/templates/eslint.config.js.jhi.ionic.ejs b/generators/ionic/templates/eslint.config.js.jhi.ionic.ejs new file mode 100644 index 000000000..ac316dfe3 --- /dev/null +++ b/generators/ionic/templates/eslint.config.js.jhi.ionic.ejs @@ -0,0 +1,113 @@ +<%# + Copyright 2013-2024 the original author or authors from the JHipster project. + + This file is part of the JHipster project, see https://www.jhipster.tech/ + for more information. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-%> +<&_ if (fragment.importsSection) { -&> +import eslint from '@eslint/js'; +// For a detailed explanation, visit: https://github.com/angular-eslint/angular-eslint/blob/main/docs/CONFIGURING_FLAT_CONFIG.md +import angular from 'angular-eslint'; +import cypress from 'eslint-plugin-cypress/flat'; +<&_ } -&> +<&_ if (fragment.configSection) { -&> + { ignores: ['www', 'projects'] }, + eslint.configs.recommended, + { + files: ['**/*.{js,cjs,mjs}'], + rules: { + 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + }, + }, + { + files: ['src/**/*.ts'], + extends: [...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylistic, ...angular.configs.tsRecommended], + languageOptions: { + globals: { + ...globals.browser, + }, + parserOptions: { + project: ['./tsconfig.app.json', './tsconfig.spec.json'], + }, + }, + processor: angular.processInlineTemplates, + rules: { + '@angular-eslint/component-class-suffix': [ + 'error', + { 'suffixes': ['Page', 'Component'] } + ], + '@angular-eslint/component-selector': [ + 'error', + { + 'type': 'element', + 'prefix': ['app', 'page'], + 'style': 'kebab-case' + } + ], + '@angular-eslint/directive-selector': [ + 'error', + { + 'type': 'attribute', + 'prefix': 'app', + 'style': 'camelCase' + } + ], + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + // Module Class + '@typescript-eslint/no-extraneous-class': 'off', + '@typescript-eslint/no-floating-promises': 'off', + + '@typescript-eslint/consistent-indexed-object-style': 'off', + '@typescript-eslint/no-confusing-void-expression': 'off', + '@typescript-eslint/no-deprecated': 'off', + '@typescript-eslint/no-misused-promises': 'off', + '@typescript-eslint/no-unnecessary-condition': 'off', + '@typescript-eslint/no-unnecessary-type-arguments': 'off', + '@typescript-eslint/no-unsafe-enum-comparison': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/prefer-promise-reject-errors': 'off', + '@typescript-eslint/prefer-for-of': 'off', + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/restrict-plus-operands': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/use-unknown-in-catch-callback-variable': 'off', + '@typescript-eslint/return-await': 'off', + }, + }, + { + files: ['**/*.html'], + extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility], + rules: { + '@angular-eslint/template/click-events-have-key-events': 'off', + '@angular-eslint/template/interactive-supports-focus': 'off', + '@angular-eslint/template/alt-text': 'off', + }, + }, + { + files: ['cypress/**/*.ts'], + extends: [...tseslint.configs.recommendedTypeChecked, cypress.configs.recommended], + languageOptions: { + parserOptions: { + "project": ["cypress/tsconfig.json"], + }, + }, + }, +<&_ } -&> diff --git a/generators/ionic/templates/src/app/pages/entities/_entity.module.ts.ejs b/generators/ionic/templates/src/app/pages/entities/_entity.module.ts.ejs index 282d4abd3..1a144416b 100644 --- a/generators/ionic/templates/src/app/pages/entities/_entity.module.ts.ejs +++ b/generators/ionic/templates/src/app/pages/entities/_entity.module.ts.ejs @@ -20,7 +20,7 @@ import { NgModule, Injectable } from '@angular/core'; import { TranslateModule } from '@ngx-translate/core'; import { IonicModule } from '@ionic/angular'; import { CommonModule } from '@angular/common'; -import { Routes, RouterModule, Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { Routes, RouterModule, Resolve, ActivatedRouteSnapshot } from '@angular/router'; import { UserRouteAccessService } from '../../../services/auth/user-route-access.service'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { Observable, of } from 'rxjs'; @@ -35,7 +35,7 @@ import { <%= entityAngularName %>, <%= entityAngularName %>Service, <%= entityAn export class <%= entityAngularName %>Resolve implements Resolve<<%= entityAngularName %>> { constructor(private service: <%= entityAngularName %>Service) {} - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<<%= entityAngularName %>> { + resolve(route: ActivatedRouteSnapshot): Observable<<%= entityAngularName %>> { const id = route.params.id ? route.params.id : null; if (id) { return this.service.find(id).pipe(