From c1f817bfd152796b153511ed2b23f74fe6027b0f Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Fri, 21 Jun 2024 11:36:12 -0300 Subject: [PATCH 1/6] apply eslint recommendations --- .../password-strength-bar.component.ts.ejs | 2 +- .../configuration/configuration.model.ts.ejs | 12 +++--------- .../webapp/app/admin/health/health.model.ts.ejs | 2 +- .../main/webapp/app/admin/logs/log.model.ts.ejs | 2 +- .../blocks/jvm-memory/jvm-memory.component.ts.ejs | 2 +- .../metrics-cache/metrics-cache.component.ts.ejs | 2 +- .../webapp/app/admin/metrics/metrics.model.ts.ejs | 15 ++++++++------- .../service/user-management.service.ts.ejs | 2 +- .../src/main/webapp/app/app.config.ts.ejs | 2 +- .../webapp/app/core/util/alert.service.ts.ejs | 12 ++++++------ .../main/webapp/app/core/util/operators.ts.ejs | 2 +- .../app/core/util/parse-links.service.ts.ejs | 8 ++++---- .../list/_entityFile_.component.ts.ejs | 4 ++-- .../webapp/app/layouts/main/main.component.ts.ejs | 4 ++-- .../app/shared/alert/alert-error.component.ts.ejs | 4 ++-- .../app/shared/alert/alert-error.model.ts.ejs | 2 +- .../app/shared/alert/alert.component.ts.ejs | 2 +- .../webapp/app/shared/filter/filter.model.ts.ejs | 5 ++--- .../language/find-language-from-key.pipe.ts.ejs | 2 +- .../shared/language/translate.directive.ts.ejs | 2 +- .../templates/src/main/webapp/bootstrap.ts.ejs | 2 +- .../angular/templates/src/main/webapp/main.ts.ejs | 2 +- .../angular/templates/webpack/environment.js.ejs | 2 +- .../webpack/webpack.microfrontend.js.ejs | 2 +- 24 files changed, 45 insertions(+), 51 deletions(-) diff --git a/generators/angular/templates/src/main/webapp/app/account/password/password-strength-bar/password-strength-bar.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/account/password/password-strength-bar/password-strength-bar.component.ts.ejs index 91db00f57b40..ce474caed7c6 100644 --- a/generators/angular/templates/src/main/webapp/app/account/password/password-strength-bar/password-strength-bar.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/account/password/password-strength-bar/password-strength-bar.component.ts.ejs @@ -42,7 +42,7 @@ export default class PasswordStrengthBarComponent { const symbols = regex.test(p); const flags = [lowerLetters, upperLetters, numbers, symbols]; - const passedMatches = flags.filter((isMatchedFlag: boolean) => isMatchedFlag === true).length; + const passedMatches = flags.filter((isMatchedFlag: boolean) => isMatchedFlag).length; force += 2 * p.length + (p.length >= 10 ? 1 : 0); force += passedMatches * 10; diff --git a/generators/angular/templates/src/main/webapp/app/admin/configuration/configuration.model.ts.ejs b/generators/angular/templates/src/main/webapp/app/admin/configuration/configuration.model.ts.ejs index e88181838a45..1adc30dc05b3 100644 --- a/generators/angular/templates/src/main/webapp/app/admin/configuration/configuration.model.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/admin/configuration/configuration.model.ts.ejs @@ -20,18 +20,14 @@ export interface ConfigProps { contexts: Contexts; } -export interface Contexts { - [key: string]: Context; -} +export type Contexts = Record; export interface Context { beans: Beans; parentId?: any; } -export interface Beans { - [key: string]: Bean; -} +export type Beans = Record; export interface Bean { prefix: string; @@ -48,9 +44,7 @@ export interface PropertySource { properties: Properties; } -export interface Properties { - [key: string]: Property; -} +export type Properties = Record; export interface Property { value: string; diff --git a/generators/angular/templates/src/main/webapp/app/admin/health/health.model.ts.ejs b/generators/angular/templates/src/main/webapp/app/admin/health/health.model.ts.ejs index d26c7acde3a6..e9e3b6fd6027 100644 --- a/generators/angular/templates/src/main/webapp/app/admin/health/health.model.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/admin/health/health.model.ts.ejs @@ -63,5 +63,5 @@ export interface Health { export interface HealthDetails { status: HealthStatus; - details?: { [key: string]: unknown }; + details?: Record; } diff --git a/generators/angular/templates/src/main/webapp/app/admin/logs/log.model.ts.ejs b/generators/angular/templates/src/main/webapp/app/admin/logs/log.model.ts.ejs index 873b5db2982e..533390efd4b8 100644 --- a/generators/angular/templates/src/main/webapp/app/admin/logs/log.model.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/admin/logs/log.model.ts.ejs @@ -25,7 +25,7 @@ export interface Logger { export interface LoggersResponse { levels: Level[]; - loggers: { [key: string]: Logger }; + loggers: Record; } export class Log { diff --git a/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/jvm-memory/jvm-memory.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/jvm-memory/jvm-memory.component.ts.ejs index 5209cf859e66..ddb7d233c8e3 100644 --- a/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/jvm-memory/jvm-memory.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/jvm-memory/jvm-memory.component.ts.ejs @@ -31,7 +31,7 @@ export class JvmMemoryComponent { /** * object containing all jvm memory metrics */ - jvmMemoryMetrics = input<{ [key: string]: JvmMetrics }>(); + jvmMemoryMetrics = input>(); /** * boolean field saying if the metrics are in the process of being updated diff --git a/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/metrics-cache/metrics-cache.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/metrics-cache/metrics-cache.component.ts.ejs index d88412c0859d..f9d78f8378bc 100644 --- a/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/metrics-cache/metrics-cache.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/admin/metrics/blocks/metrics-cache/metrics-cache.component.ts.ejs @@ -33,7 +33,7 @@ export class MetricsCacheComponent { /** * object containing all cache related metrics */ - cacheMetrics = input<{ [key: string]: CacheMetrics }>(); + cacheMetrics = input>(); /** * boolean field saying if the metrics are in the process of being updated diff --git a/generators/angular/templates/src/main/webapp/app/admin/metrics/metrics.model.ts.ejs b/generators/angular/templates/src/main/webapp/app/admin/metrics/metrics.model.ts.ejs index bfba0712d3c8..fe726a74df07 100644 --- a/generators/angular/templates/src/main/webapp/app/admin/metrics/metrics.model.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/admin/metrics/metrics.model.ts.ejs @@ -17,10 +17,10 @@ limitations under the License. -%> export interface Metrics { - jvm: { [key: string]: JvmMetrics }; + jvm: Record; databases: Databases; 'http.server.requests': HttpServerRequests; - cache: { [key: string]: CacheMetrics }; + cache: Record; garbageCollector: GarbageCollector; services: Services; processMetrics: ProcessMetrics; @@ -65,7 +65,7 @@ export interface HttpServerRequests { all: { count: number; }; - percode: { [key: string]: MaxMeanCount }; + percode: Record; } export interface MaxMeanCount { @@ -92,11 +92,12 @@ export interface GarbageCollector { classesUnloaded: number; } -export interface Services { - [key: string]: { +export type Services = Record< + string, + { [key in HttpMethod]?: MaxMeanCount; - }; -} + } +>; export enum HttpMethod { Post = 'POST', diff --git a/generators/angular/templates/src/main/webapp/app/admin/user-management/service/user-management.service.ts.ejs b/generators/angular/templates/src/main/webapp/app/admin/user-management/service/user-management.service.ts.ejs index 5157587dac86..6e7071c72f26 100644 --- a/generators/angular/templates/src/main/webapp/app/admin/user-management/service/user-management.service.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/admin/user-management/service/user-management.service.ts.ejs @@ -62,7 +62,7 @@ export class UserManagementService { authorities(): Observable { <%_ if (generateBuiltInAuthorityEntity) { _%> return this.http - .get>(this.applicationConfigService.getEndpointFor('api/authorities')) + .get<{ name: string }[]>(this.applicationConfigService.getEndpointFor('api/authorities')) .pipe(map(authorities => authorities.map(a => a.name))); <%_ } else { _%> return of([Authority.ADMIN, Authority.USER]); diff --git a/generators/angular/templates/src/main/webapp/app/app.config.ts.ejs b/generators/angular/templates/src/main/webapp/app/app.config.ts.ejs index c818ec74cf74..3c6895468ac4 100644 --- a/generators/angular/templates/src/main/webapp/app/app.config.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/app.config.ts.ejs @@ -36,7 +36,7 @@ import routes from './app.routes'; import { NgbDateDayjsAdapter } from './config/datepicker-adapter'; import { AppPageTitleStrategy } from './app-page-title-strategy'; -const routerFeatures: Array = [ +const routerFeatures: RouterFeatures[] = [ withComponentInputBinding(), withNavigationErrorHandler((e: NavigationError) => { const router = inject(Router); diff --git a/generators/angular/templates/src/main/webapp/app/core/util/alert.service.ts.ejs b/generators/angular/templates/src/main/webapp/app/core/util/alert.service.ts.ejs index 3496bb4363bd..b8e0c616a808 100644 --- a/generators/angular/templates/src/main/webapp/app/core/util/alert.service.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/core/util/alert.service.ts.ejs @@ -27,12 +27,12 @@ import { translationNotFoundMessage } from 'app/config/translation.config'; export type AlertType = 'success' | 'danger' | 'warning' | 'info'; export interface Alert { - id?: number; + id: number; type: AlertType; message?: string; <%_ if (enableTranslation) { _%> translationKey?: string; - translationParams?: { [key: string]: unknown }; + translationParams?: Record; <%_ } _%> timeout?: number; toast?: boolean; @@ -75,8 +75,8 @@ export class AlertService { * Else adding `alert` to `extAlerts`. * @returns Added alert */ - addAlert(alert: Alert, extAlerts?: Alert[]): Alert { - alert.id = this.alertId++; + addAlert(alertToAdd: Omit, extAlerts?: Alert[]): Alert { + const alert: Alert = { ...alertToAdd, id: this.alertId++ }; <%_ if (enableTranslation) { _%> if (alert.translationKey) { @@ -94,13 +94,13 @@ export class AlertService { alert.timeout = alert.timeout ?? this.timeout; alert.toast = alert.toast ?? this.toast; alert.position = alert.position ?? this.position; - alert.close = (alertsArray: Alert[]) => this.closeAlert(alert.id!, alertsArray); + alert.close = (alertsArray: Alert[]) => this.closeAlert(alert.id, alertsArray); (extAlerts ?? this.alerts).push(alert); if (alert.timeout > 0) { setTimeout(() => { - this.closeAlert(alert.id!, extAlerts ?? this.alerts); + this.closeAlert(alert.id, extAlerts ?? this.alerts); }, alert.timeout); } diff --git a/generators/angular/templates/src/main/webapp/app/core/util/operators.ts.ejs b/generators/angular/templates/src/main/webapp/app/core/util/operators.ts.ejs index e6095754fff9..ffc2eb8ffbac 100644 --- a/generators/angular/templates/src/main/webapp/app/core/util/operators.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/core/util/operators.ts.ejs @@ -20,7 +20,7 @@ * Function used to workaround https://github.com/microsoft/TypeScript/issues/16069 * es2019 alternative `const filteredArr = myArr.flatMap((x) => x ? x : []);` */ -export function isPresent(t: T | undefined | null | void): t is T { +export function isPresent(t: T | undefined | null): t is T { return t !== undefined && t !== null; } diff --git a/generators/angular/templates/src/main/webapp/app/core/util/parse-links.service.ts.ejs b/generators/angular/templates/src/main/webapp/app/core/util/parse-links.service.ts.ejs index 74ee8f6784ff..92c410e4a181 100644 --- a/generators/angular/templates/src/main/webapp/app/core/util/parse-links.service.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/core/util/parse-links.service.ts.ejs @@ -28,7 +28,7 @@ export class ParseLinks { /** * Method to parse the links */ - parseAll(header: string): { [key: string]: { [key: string]: string | undefined } | undefined } { + parseAll(header: string): Record | undefined> { if (header.length === 0) { throw new Error('input must not be of zero length'); } @@ -46,7 +46,7 @@ export class ParseLinks { } const url: string = section[0].replace(/<(.*)>/, '$1').trim(); // NOSONAR - const queryString: { [key: string]: string } = {}; + const queryString: Record = {}; url.replace(/([^?=&]+)(=([^&]*))?/g, (_$0: string, $1: string | undefined, _$2: string | undefined, $3: string | undefined) => { if ($1 !== undefined && $3 !== undefined) { @@ -64,9 +64,9 @@ export class ParseLinks { /** * Method to parse the links */ - parse(header: string): { [key: string]: number } { + parse(header: string): Record { const sections = this.parseAll(header); - const links: { [key: string]: number } = {}; + const links: Record = {}; for (const [name, queryParams] of Object.entries(sections)) { if (queryParams?.page !== undefined) { links[name] = parseInt(queryParams.page, 10); diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs index 181dff2d5f9d..df9cc6783555 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs @@ -132,7 +132,7 @@ export class <%= componentName %> implements OnInit { <%- include('pagination-template'); -%> <%_ } else if (paginationInfiniteScroll) { _%> itemsPerPage = ITEMS_PER_PAGE; - links: WritableSignal<{ [key: string]: undefined | { [key: string]: string | undefined } }> = signal({}); + links: WritableSignal>> = signal({}); hasMorePage = computed(() => !!this.links().next); isFirstFetch = computed(() => Object.keys(this.links()).length === 0); <%_ } _%> @@ -302,7 +302,7 @@ export class <%= componentName %> implements OnInit { if (data) { for (const d of data) { <%_ if (primaryKey) { _%> - if (<%= entityInstancePlural %>New.map(op => op.<%= primaryKey.name %>).indexOf(d.<%= primaryKey.name %>) === -1) { + if (<%= entityInstancePlural %>New.some(op => op.<%= primaryKey.name %> === d.<%= primaryKey.name %>)) { <%_ } _%> <%= entityInstancePlural %>New.push(d); <%_ if (primaryKey) { _%> diff --git a/generators/angular/templates/src/main/webapp/app/layouts/main/main.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/layouts/main/main.component.ts.ejs index efbc28b6aa6f..eed93fb3b81f 100644 --- a/generators/angular/templates/src/main/webapp/app/layouts/main/main.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/layouts/main/main.component.ts.ejs @@ -53,12 +53,12 @@ export default class MainComponent implements OnInit { private translateService = inject(TranslateService); private rootRenderer = inject(RendererFactory2); <%_ } _%> +<%_ if (enableTranslation) { _%> constructor() { -<%_ if (enableTranslation) { _%> this.renderer = this.rootRenderer.createRenderer(document.querySelector('html'), null); -<%_ } _%> } +<%_ } _%> ngOnInit(): void { // try to log in automatically diff --git a/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.component.ts.ejs index 3625db8db419..c1cc87e9f88a 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.component.ts.ejs @@ -57,7 +57,7 @@ export class AlertErrorComponent implements OnDestroy { }); } - setClasses(alert: Alert): { [key: string]: boolean } { + setClasses(alert: Alert): Record { const classes = { 'jhi-toast': Boolean(alert.toast) }; if (alert.position) { return { ...classes, [alert.position]: true }; @@ -74,7 +74,7 @@ export class AlertErrorComponent implements OnDestroy { alert.close?.(this.alerts()); } - private addErrorAlert(message?: string<% if (enableTranslation) { %>, translationKey?: string, translationParams?: { [key: string]: unknown }<% } %>): void { + private addErrorAlert(message?: string<% if (enableTranslation) { %>, translationKey?: string, translationParams?: Record<% } %>): void { this.alertService.addAlert({ type: 'danger', message<% if (enableTranslation) { %>, translationKey, translationParams<% } %> }, this.alerts()); } diff --git a/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.model.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.model.ts.ejs index 1ee73d99eb50..18e1415dc287 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.model.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/alert/alert-error.model.ts.ejs @@ -21,7 +21,7 @@ export class AlertError { public message: string, <%_ if (enableTranslation) { _%> public key?: string, - public params?: { [key: string]: unknown } + public params?: Record <%_ } _%> ) {} } diff --git a/generators/angular/templates/src/main/webapp/app/shared/alert/alert.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/alert/alert.component.ts.ejs index 910bb025ef6d..efe5cbd3883f 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/alert/alert.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/alert/alert.component.ts.ejs @@ -37,7 +37,7 @@ export class AlertComponent implements OnInit, OnDestroy { this.alerts.set(this.alertService.get()); } - setClasses(alert: Alert): { [key: string]: boolean } { + setClasses(alert: Alert): Record { const classes = { 'jhi-toast': Boolean(alert.toast) }; if (alert.position) { return { ...classes, [alert.position]: true }; diff --git a/generators/angular/templates/src/main/webapp/app/shared/filter/filter.model.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/filter/filter.model.ts.ejs index 794a0c096724..fad713d02817 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/filter/filter.model.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/filter/filter.model.ts.ejs @@ -67,7 +67,7 @@ export class FilterOption implements IFilterOption { } export class FilterOptions implements IFilterOptions { - readonly filterChanges: Subject = new Subject(); + readonly filterChanges = new Subject(); private _filterOptions: FilterOption[]; constructor(filterOptions: FilterOption[] = []) { @@ -146,8 +146,7 @@ export class FilterOptions implements IFilterOptions { } protected getFilterOptionByName(name: string, add: true): FilterOption; - protected getFilterOptionByName(name: string, add: false): FilterOption | null; - protected getFilterOptionByName(name: string): FilterOption | null; + protected getFilterOptionByName(name: string, add?: false): FilterOption | null; protected getFilterOptionByName(name: string, add = false): FilterOption | null { const addOption = (option: FilterOption): FilterOption => { this._filterOptions.push(option); diff --git a/generators/angular/templates/src/main/webapp/app/shared/language/find-language-from-key.pipe.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/language/find-language-from-key.pipe.ts.ejs index f5889aaa620e..df041844366c 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/language/find-language-from-key.pipe.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/language/find-language-from-key.pipe.ts.ejs @@ -23,7 +23,7 @@ import { Pipe, PipeTransform } from '@angular/core'; name: 'findLanguageFromKey', }) export default class FindLanguageFromKeyPipe implements PipeTransform { - private readonly languages: { [key: string]: { name: string; rtl?: boolean } } = { + private readonly languages: Record = { // jhipster-needle-i18n-language-key-pipe - JHipster will add/remove languages in this object }; diff --git a/generators/angular/templates/src/main/webapp/app/shared/language/translate.directive.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/language/translate.directive.ts.ejs index 1929b205b604..7d8478cb282f 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/language/translate.directive.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/language/translate.directive.ts.ejs @@ -32,7 +32,7 @@ import { translationNotFoundMessage } from 'app/config/translation.config'; }) export default class TranslateDirective implements OnChanges, OnInit, OnDestroy { @Input() <%= jhiPrefix %>Translate!: string; - @Input() translateValues?: { [key: string]: unknown }; + @Input() translateValues?: Record; private readonly directiveDestroyed = new Subject(); diff --git a/generators/angular/templates/src/main/webapp/bootstrap.ts.ejs b/generators/angular/templates/src/main/webapp/bootstrap.ts.ejs index e0ad4c857ef8..ca38b57dba3a 100644 --- a/generators/angular/templates/src/main/webapp/bootstrap.ts.ejs +++ b/generators/angular/templates/src/main/webapp/bootstrap.ts.ejs @@ -31,4 +31,4 @@ if (!DEBUG_INFO_ENABLED) { bootstrapApplication(AppComponent, appConfig) // eslint-disable-next-line no-console .then(() => console.log('Application started')) - .catch(err => console.error(err)); + .catch((err: unknown) => console.error(err)); diff --git a/generators/angular/templates/src/main/webapp/main.ts.ejs b/generators/angular/templates/src/main/webapp/main.ts.ejs index 9f14222e4993..596014f3fbd1 100644 --- a/generators/angular/templates/src/main/webapp/main.ts.ejs +++ b/generators/angular/templates/src/main/webapp/main.ts.ejs @@ -16,4 +16,4 @@ See the License for the specific language governing permissions and limitations under the License. -%> -import('./bootstrap').catch(err => console.error(err)); +import('./bootstrap').catch((err: unknown) => console.error(err)); diff --git a/generators/angular/templates/webpack/environment.js.ejs b/generators/angular/templates/webpack/environment.js.ejs index d02117767c3e..6536851cb965 100644 --- a/generators/angular/templates/webpack/environment.js.ejs +++ b/generators/angular/templates/webpack/environment.js.ejs @@ -1,6 +1,6 @@ module.exports = { I18N_HASH: 'generated_hash', SERVER_API_URL: '', - __VERSION__: process.env.hasOwnProperty('APP_VERSION') ? process.env.APP_VERSION : 'DEV', + __VERSION__: process.env.APP_VERSION || 'DEV', __DEBUG_INFO_ENABLED__: false, }; diff --git a/generators/angular/templates/webpack/webpack.microfrontend.js.ejs b/generators/angular/templates/webpack/webpack.microfrontend.js.ejs index 58dbf512ecf7..6e552d9d5702 100644 --- a/generators/angular/templates/webpack/webpack.microfrontend.js.ejs +++ b/generators/angular/templates/webpack/webpack.microfrontend.js.ejs @@ -22,7 +22,6 @@ const packageJson = require('../package.json'); const apiVersion = '0.0.1'; const sharedDefaults = { singleton: true, strictVersion: true, requiredVersion: apiVersion }; -const shareAllDefaults = { ...sharedDefaults, requiredVersion: 'auto' } const shareMappings = (...mappings) => Object.fromEntries(mappings.map(map => [map, { ...sharedDefaults, version: apiVersion }])); const shareDependencies = ({ skipList = [] } = {}) => @@ -39,6 +38,7 @@ sharedDependencies = { 'rxjs/operators': sharedDependencies.rxjs, }; +// eslint-disable-next-line no-unused-vars module.exports = (config, options, targetOptions) => { return withModuleFederationPlugin({ name: '<%= lowercaseBaseName %>', From 23b1034f6482871f726bfc7dd1ac935bbf9d48f7 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Thu, 20 Jun 2024 17:27:13 -0300 Subject: [PATCH 2/6] migrate to eslint flat config --- .github/dependabot.yml | 3 - .../__snapshots__/generator.spec.ts.snap | 57 +++---- generators/angular/files-angular.js | 2 +- generators/angular/generator.ts | 23 ++- generators/angular/resources/package.json | 6 +- .../angular/templates/.eslintrc.json.ejs | 123 --------------- .../eslint.config.js.jhi.angular.ejs | 143 ++++++++++++++++++ generators/angular/templates/package.json.ejs | 9 +- .../templates/webpack/webpack.custom.js.ejs | 7 +- .../app/__snapshots__/generator.spec.ts.snap | 12 ++ generators/client/files-common.js | 2 +- generators/workspaces/generator.js | 2 +- 12 files changed, 208 insertions(+), 181 deletions(-) delete mode 100644 generators/angular/templates/.eslintrc.json.ejs create mode 100644 generators/angular/templates/eslint.config.js.jhi.angular.ejs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6a033ebc710f..bc82c55cb9d4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -83,9 +83,6 @@ updates: - 'ngx-infinite-scroll' - 'typescript' - 'zone.js' - angular-eslint: - patterns: - - '@angular-eslint/*' fortawesome: patterns: - '@fortawesome/fontawesome-svg-core' diff --git a/generators/angular/__snapshots__/generator.spec.ts.snap b/generators/angular/__snapshots__/generator.spec.ts.snap index bd1f351ff540..6ccf39207182 100644 --- a/generators/angular/__snapshots__/generator.spec.ts.snap +++ b/generators/angular/__snapshots__/generator.spec.ts.snap @@ -17,13 +17,10 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa ".yo-rc.json": { "stateCleared": "modified", }, - "clientRoot/.eslintignore": { + "clientRoot/angular.json": { "stateCleared": "modified", }, - "clientRoot/.eslintrc.json": { - "stateCleared": "modified", - }, - "clientRoot/angular.json": { + "clientRoot/eslint.config.mjs": { "stateCleared": "modified", }, "clientRoot/jest.conf.js": { @@ -700,13 +697,10 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend ".yo-rc.json": { "stateCleared": "modified", }, - "clientRoot/.eslintignore": { - "stateCleared": "modified", - }, - "clientRoot/.eslintrc.json": { + "clientRoot/angular.json": { "stateCleared": "modified", }, - "clientRoot/angular.json": { + "clientRoot/eslint.config.mjs": { "stateCleared": "modified", }, "clientRoot/jest.conf.js": { @@ -1605,13 +1599,10 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi ".yo-rc.json": { "stateCleared": "modified", }, - "clientRoot/.eslintignore": { - "stateCleared": "modified", - }, - "clientRoot/.eslintrc.json": { + "clientRoot/angular.json": { "stateCleared": "modified", }, - "clientRoot/angular.json": { + "clientRoot/eslint.config.mjs": { "stateCleared": "modified", }, "clientRoot/jest.conf.js": { @@ -2252,12 +2243,6 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterDependencies(true)-enableTranslation(true)--websocket(false) should match generated files snapshot 1`] = ` { - ".eslintignore": { - "stateCleared": "modified", - }, - ".eslintrc.json": { - "stateCleared": "modified", - }, ".jhipster/EntityWithCustomId.json": { "stateCleared": "modified", }, @@ -2276,6 +2261,9 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD "angular.json": { "stateCleared": "modified", }, + "eslint.config.mjs": { + "stateCleared": "modified", + }, "jest.conf.js": { "stateCleared": "modified", }, @@ -2923,12 +2911,6 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi(true)-skipJhipsterDependencies(true)-enableTranslation(true)--websocket(true) should match generated files snapshot 1`] = ` { - ".eslintignore": { - "stateCleared": "modified", - }, - ".eslintrc.json": { - "stateCleared": "modified", - }, ".jhipster/EntityWithCustomId.json": { "stateCleared": "modified", }, @@ -2947,6 +2929,9 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi( "angular.json": { "stateCleared": "modified", }, + "eslint.config.mjs": { + "stateCleared": "modified", + }, "jest.conf.js": { "stateCleared": "modified", }, @@ -3999,12 +3984,6 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi( exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDependencies(false)-enableTranslation(false)-websocket(false) should match generated files snapshot 1`] = ` { - ".eslintignore": { - "stateCleared": "modified", - }, - ".eslintrc.json": { - "stateCleared": "modified", - }, ".jhipster/EntityWithCustomId.json": { "stateCleared": "modified", }, @@ -4023,6 +4002,9 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe "angular.json": { "stateCleared": "modified", }, + "eslint.config.mjs": { + "stateCleared": "modified", + }, "jest.conf.js": { "stateCleared": "modified", }, @@ -4655,12 +4637,6 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe exports[`generator - angular monolith-session-skipUserManagement(true)-withAdminUi(false)-skipJhipsterDependencies(false)-enableTranslation(false)-websocket(true) should match generated files snapshot 1`] = ` { - ".eslintignore": { - "stateCleared": "modified", - }, - ".eslintrc.json": { - "stateCleared": "modified", - }, ".jhipster/EntityWithCustomId.json": { "stateCleared": "modified", }, @@ -4679,6 +4655,9 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin "angular.json": { "stateCleared": "modified", }, + "eslint.config.mjs": { + "stateCleared": "modified", + }, "jest.conf.js": { "stateCleared": "modified", }, diff --git a/generators/angular/files-angular.js b/generators/angular/files-angular.js index 838a4d2dfb4d..cd979262ec08 100644 --- a/generators/angular/files-angular.js +++ b/generators/angular/files-angular.js @@ -28,8 +28,8 @@ export const files = { common: [ clientRootTemplatesBlock({ templates: [ - '.eslintrc.json', 'angular.json', + { sourceFile: 'eslint.config.js.jhi.angular', destinationFile: ctx => `${ctx.eslintConfigFile}.jhi.angular` }, 'ngsw-config.json', 'package.json', 'tsconfig.json', diff --git a/generators/angular/generator.ts b/generators/angular/generator.ts index e29716bd8075..ddf2fdd3c917 100644 --- a/generators/angular/generator.ts +++ b/generators/angular/generator.ts @@ -33,6 +33,7 @@ import { } from '../client/support/index.js'; import type { CommonClientServerApplication } from '../base-application/types.js'; import { createNeedleCallback, mutateData } from '../base/support/index.js'; +import { writeEslintClientRootConfigFile } from '../javascript/generators/eslint/support/tasks.js'; import { writeEntitiesFiles, postWriteEntitiesFiles, cleanupEntitiesFiles } from './entity-files-angular.js'; import { writeFiles } from './files-angular.js'; import cleanupOldFilesTask from './cleanup.js'; @@ -72,6 +73,12 @@ export default class AngularGenerator extends BaseApplicationGenerator { this.fetchFromInstalledJHipster(GENERATOR_ANGULAR, 'resources', 'package.json'), ); }, + applicationDefauts({ applicationDefaults }) { + applicationDefaults({ + __override__: true, + typescriptEslint: true, + }); + }, }); } @@ -81,9 +88,13 @@ export default class AngularGenerator extends BaseApplicationGenerator { get preparing() { return this.asPreparingTaskGroup({ - prepareForTemplates({ application }) { - application.webappEnumerationsDir = `${application.clientSrcDir}app/entities/enumerations/`; - application.angularLocaleId = application.nativeLanguageDefinition.angularLocale ?? defaultLanguage.angularLocale!; + applicationDefauts({ applicationDefaults }) { + applicationDefaults({ + __override__: true, + eslintConfigFile: app => `eslint.config.${app.packageJsonType === 'module' ? 'js' : 'mjs'}`, + webappEnumerationsDir: app => `${app.clientSrcDir}app/entities/enumerations/`, + angularLocaleId: app => app.nativeLanguageDefinition.angularLocale ?? defaultLanguage.angularLocale, + }); }, addNeedles({ source, application }) { source.addEntitiesToClient = param => { @@ -222,7 +233,13 @@ export default class AngularGenerator extends BaseApplicationGenerator { get writing() { return this.asWritingTaskGroup({ + cleanup({ control }) { + control.cleanupFiles({ + '8.6.1': ['.eslintrc.json', '.eslintignore'], + }); + }, cleanupOldFilesTask, + writeEslintClientRootConfigFile, writeFiles, }); } diff --git a/generators/angular/resources/package.json b/generators/angular/resources/package.json index 8ecfd707a92f..62dbb1d74734 100644 --- a/generators/angular/resources/package.json +++ b/generators/angular/resources/package.json @@ -29,14 +29,17 @@ "@types/node": "20.11.25", "@types/sockjs-client": "1.5.4", "@typescript-eslint/eslint-plugin": "7.16.1", + "angular-eslint": "18.1.0", "browser-sync": "3.0.2", "browser-sync-webpack-plugin": "2.3.0", "buffer": "6.0.3", "copy-webpack-plugin": "12.0.2", - "eslint": "8.57.0", + "eslint": "9.7.0", "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.2.1", "eslint-webpack-plugin": "4.2.0", "folder-hash": "4.0.4", + "globals": "15.8.0", "jest": "29.7.0", "jest-date-mock": "1.0.10", "jest-junit": "16.0.0", @@ -47,6 +50,7 @@ "rimraf": "5.0.8", "ts-jest": "29.2.2", "typescript": "5.4.5", + "typescript-eslint": "8.0.0-alpha.44", "webpack": "5.93.0", "webpack-bundle-analyzer": "4.10.2", "webpack-merge": "6.0.1", diff --git a/generators/angular/templates/.eslintrc.json.ejs b/generators/angular/templates/.eslintrc.json.ejs deleted file mode 100644 index 26c41af20842..000000000000 --- a/generators/angular/templates/.eslintrc.json.ejs +++ /dev/null @@ -1,123 +0,0 @@ -<%# - 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. --%> -{ - "parser": "@typescript-eslint/parser", - "plugins": ["@angular-eslint/eslint-plugin", "@typescript-eslint"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "plugin:@angular-eslint/recommended", - "prettier", - "eslint-config-prettier" - ], - "env": { - "browser": true, - "es6": true, - "commonjs": true - }, - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module", - "project": [ - "./tsconfig.app.json", -<%_ if (cypressTests) { _%> - "./<%= this.relativeDir(clientRootDir, cypressDir) %>tsconfig.json", -<%_ } _%> - "./tsconfig.spec.json" - ] - }, - "rules": { - "@angular-eslint/component-selector": [ - "error", - { - "type": "element", - "prefix": "<%= jhiPrefixDashed %>", - "style": "kebab-case" - } - ], - "@angular-eslint/directive-selector": [ - "error", - { - "type": "attribute", - "prefix": "<%= jhiPrefix %>", - "style": "camelCase" - } - ], - "@angular-eslint/relative-url-prefix": "error", - "@typescript-eslint/ban-types": [ - "error", - { - "extendDefaults": true, - "types": { - "{}": false - } - } - ], - "@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }], - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/member-ordering": [ - "error", - { - "default": [ - "public-static-field", - "protected-static-field", - "private-static-field", - "public-instance-field", - "protected-instance-field", - "private-instance-field", - "constructor", - "public-static-method", - "protected-static-method", - "private-static-method", - "public-instance-method", - "protected-instance-method", - "private-instance-method" - ] - } - ], - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-floating-promises": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-shadow": ["error"], - "@typescript-eslint/no-unnecessary-condition": "error", - "@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-unused-vars": "off", - "@typescript-eslint/prefer-nullish-coalescing": "error", - "@typescript-eslint/prefer-optional-chain": "error", - "@typescript-eslint/unbound-method": "off", - "arrow-body-style": "error", - "curly": "error", - "eqeqeq": ["error", "always", { "null": "ignore" }], - "guard-for-in": "error", - "no-bitwise": "error", - "no-caller": "error", - "no-console": ["error", { "allow": ["warn", "error"] }], - "no-eval": "error", - "no-labels": "error", - "no-new": "error", - "no-new-wrappers": "error", - "object-shorthand": ["error", "always", { "avoidExplicitReturnArrows": true }], - "radix": "error", - "spaced-comment": ["warn", "always"] - } -} diff --git a/generators/angular/templates/eslint.config.js.jhi.angular.ejs b/generators/angular/templates/eslint.config.js.jhi.angular.ejs new file mode 100644 index 000000000000..d2b94cdbae34 --- /dev/null +++ b/generators/angular/templates/eslint.config.js.jhi.angular.ejs @@ -0,0 +1,143 @@ +<%# + 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'; +<&_ } -&> +<&_ if (fragment.configSection) { -&> + { ignores: ['<%- this.relativeDir(clientRootDir, clientDistDir) %>', '<%- temporaryDir %>'] }, + eslint.configs.recommended, + { + files: ['**/*.{js,cjs,mjs}'], + rules: { + 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + }, + }, + { + files: ['<%- this.relativeDir(clientRootDir, clientSrcDir) %>**/*.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-selector': [ + 'error', + { + type: 'element', + prefix: '<%= jhiPrefixDashed %>', + style: 'kebab-case', + }, + ], + '@angular-eslint/directive-selector': [ + 'error', + { + type: 'attribute', + prefix: '<%= jhiPrefix %>', + style: 'camelCase', + }, + ], + '@angular-eslint/relative-url-prefix': 'error', + '@typescript-eslint/ban-types': [ + 'error', + { + extendDefaults: true, + types: { + '{}': false, + }, + }, + ], + '@typescript-eslint/consistent-type-definitions': 'off', + '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }], + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/member-ordering': [ + 'error', + { + default: [ + 'public-static-field', + 'protected-static-field', + 'private-static-field', + 'public-instance-field', + 'protected-instance-field', + 'private-instance-field', + 'constructor', + 'public-static-method', + 'protected-static-method', + 'private-static-method', + 'public-instance-method', + 'protected-instance-method', + 'private-instance-method', + ], + }, + ], + '@typescript-eslint/no-confusing-void-expression': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-extraneous-class': 'off', + '@typescript-eslint/no-floating-promises': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-shadow': ['error'], + '@typescript-eslint/no-unnecessary-condition': 'error', + '@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-unused-vars': 'off', + '@typescript-eslint/prefer-nullish-coalescing': 'error', + '@typescript-eslint/prefer-optional-chain': 'error', + '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }], + '@typescript-eslint/unbound-method': 'off', + 'arrow-body-style': 'error', + curly: 'error', + eqeqeq: ['error', 'always', { null: 'ignore' }], + 'guard-for-in': 'error', + 'no-bitwise': 'error', + 'no-caller': 'error', + 'no-console': ['error', { allow: ['warn', 'error'] }], + 'no-eval': 'error', + 'no-labels': 'error', + 'no-new': 'error', + 'no-new-wrappers': 'error', + 'object-shorthand': ['error', 'always', { avoidExplicitReturnArrows: true }], + radix: 'error', + 'spaced-comment': ['warn', 'always'], + }, + }, + { + files: ['<%- this.relativeDir(clientRootDir, clientSrcDir) %>**/*.spec.ts'], + rules: { + '@typescript-eslint/no-empty-function': 'off', + }, + }, + { + files: ['**/*.html'], + extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility], + rules: {}, + }, + { + // Html templates requires some work + ignores: ['**/*.html'], + extends: [prettier], + }, +<&_ } -&> diff --git a/generators/angular/templates/package.json.ejs b/generators/angular/templates/package.json.ejs index 1af61a7c84a2..e18b8ae8aa3c 100644 --- a/generators/angular/templates/package.json.ejs +++ b/generators/angular/templates/package.json.ejs @@ -77,18 +77,18 @@ "@angular-builders/custom-webpack": "<%= nodeDependencies['@angular-builders/custom-webpack'] %>", "@angular-builders/jest": "<%= nodeDependencies['@angular-builders/jest'] %>", "@angular-devkit/build-angular": "<%= nodeDependencies['@angular/cli'] %>", - "@angular-eslint/eslint-plugin": "<%= nodeDependencies['@angular-eslint/eslint-plugin'] %>", "@types/jest": "<%= nodeDependencies['@types/jest'] %>", "@types/node": "<%= nodeDependencies['@types/node'] %>", - "@typescript-eslint/eslint-plugin": "<%= nodeDependencies['@typescript-eslint/eslint-plugin'] %>", - "@typescript-eslint/parser": "<%= nodeDependencies['@typescript-eslint/eslint-plugin'] %>", + "angular-eslint": "<%= nodeDependencies['angular-eslint'] %>", "browser-sync": "<%= nodeDependencies['browser-sync'] %>", "browser-sync-webpack-plugin": "<%= nodeDependencies['browser-sync-webpack-plugin'] %>", "buffer": "<%= nodeDependencies['buffer'] %>", "copy-webpack-plugin": "<%= nodeDependencies['copy-webpack-plugin'] %>", "eslint": "<%= nodeDependencies['eslint'] %>", "eslint-config-prettier": "<%= nodeDependencies['eslint-config-prettier'] %>", + "eslint-plugin-prettier": "<%= nodeDependencies['eslint-plugin-prettier'] %>", "eslint-webpack-plugin": "<%= nodeDependencies['eslint-webpack-plugin'] %>", + "globals": "<%= nodeDependencies.globals %>", "jest": "<%= nodeDependencies['jest'] %>", "jest-environment-jsdom": "<%= nodeDependencies['jest'] %>", "jest-preset-angular": "<%= nodeDependencies['jest-preset-angular'] %>", @@ -102,6 +102,7 @@ "swagger-ui-dist": "<%= nodeDependencies['swagger-ui-dist'] %>", "ts-jest": "<%= nodeDependencies['ts-jest'] %>", "typescript": "<%= nodeDependencies['typescript'] %>", + "typescript-eslint": "<%= nodeDependencies['typescript-eslint'] %>", "webpack-bundle-analyzer": "<%= nodeDependencies['webpack-bundle-analyzer'] %>", "webpack-merge": "<%= nodeDependencies['webpack-merge'] %>", "webpack-notifier": "<%= nodeDependencies['webpack-notifier'] %>" @@ -119,7 +120,7 @@ "scripts": { "prettier:check": "prettier --check \"{,src/**/,webpack/,.blueprint/**/}*.{<%= prettierExtensions %>}\"", "prettier:format": "prettier --write \"{,src/**/,webpack/,.blueprint/**/}*.{<%= prettierExtensions %>}\"", - "lint": "eslint . --ext .js,.ts", + "lint": "eslint .", "lint:fix": "<%= clientPackageManager %> run lint -- --fix", "cleanup": "rimraf <%= this.relativeDir(clientRootDir, temporaryDir) %>", "clean-www": "rimraf <%= this.relativeDir(clientRootDir, clientDistDir) %>", diff --git a/generators/angular/templates/webpack/webpack.custom.js.ejs b/generators/angular/templates/webpack/webpack.custom.js.ejs index a8051fa7f65a..61ba77fc332c 100644 --- a/generators/angular/templates/webpack/webpack.custom.js.ejs +++ b/generators/angular/templates/webpack/webpack.custom.js.ejs @@ -48,11 +48,8 @@ module.exports = async (config, options, targetOptions) => { if (config.mode === 'development') { config.plugins.push( new ESLintPlugin({ - baseConfig: { - parserOptions: { - project: ['../tsconfig.app.json'], - }, - }, + configType: 'flat', + extensions: ['ts', 'js', 'html'], }), new WebpackNotifierPlugin({ title: '<%= humanizedBaseName %>', diff --git a/generators/app/__snapshots__/generator.spec.ts.snap b/generators/app/__snapshots__/generator.spec.ts.snap index f97a4a996e3f..441f998a49e0 100644 --- a/generators/app/__snapshots__/generator.spec.ts.snap +++ b/generators/app/__snapshots__/generator.spec.ts.snap @@ -450,6 +450,7 @@ exports[`generator - app with default config should match snapshot 1`] = ` "com.mycompany.myapp", ], "entitySuffix": "", + "eslintConfigFile": "eslint.config.mjs", "fakerSeed": undefined, "feignClient": undefined, "fromInit": undefined, @@ -627,6 +628,7 @@ exports[`generator - app with default config should match snapshot 1`] = ` "@types/node": "TYPES_NODE_VERSION", "@types/sockjs-client": "TYPES_SOCKJS_CLIENT_VERSION", "@typescript-eslint/eslint-plugin": "TYPESCRIPT_ESLINT_ESLINT_PLUGIN_VERSION", + "angular-eslint": "ANGULAR_ESLINT_VERSION", "babel-loader": "BABEL_LOADER_VERSION", "babel-plugin-istanbul": "BABEL_PLUGIN_ISTANBUL_VERSION", "bootstrap": "BOOTSTRAP_VERSION", @@ -642,8 +644,10 @@ exports[`generator - app with default config should match snapshot 1`] = ` "eslint": "ESLINT_VERSION", "eslint-config-prettier": "ESLINT_CONFIG_PRETTIER_VERSION", "eslint-plugin-cypress": "ESLINT_PLUGIN_CYPRESS_VERSION", + "eslint-plugin-prettier": "ESLINT_PLUGIN_PRETTIER_VERSION", "eslint-webpack-plugin": "ESLINT_WEBPACK_PLUGIN_VERSION", "folder-hash": "FOLDER_HASH_VERSION", + "globals": "GLOBALS_VERSION", "husky": "HUSKY_VERSION", "jest": "JEST_VERSION", "jest-date-mock": "JEST_DATE_MOCK_VERSION", @@ -668,6 +672,7 @@ exports[`generator - app with default config should match snapshot 1`] = ` "ts-jest": "TS_JEST_VERSION", "tslib": "TSLIB_VERSION", "typescript": "TYPESCRIPT_VERSION", + "typescript-eslint": "TYPESCRIPT_ESLINT_VERSION", "wait-on": "WAIT_ON_VERSION", "webpack": "WEBPACK_VERSION", "webpack-bundle-analyzer": "WEBPACK_BUNDLE_ANALYZER_VERSION", @@ -786,6 +791,7 @@ exports[`generator - app with default config should match snapshot 1`] = ` "testJavaDir": "src/test/java/", "testJavaPackageDir": "src/test/java/com/mycompany/myapp/", "testResourceDir": "src/test/resources/", + "typescriptEslint": true, "upperFirstCamelCaseBaseName": "Jhipster", "useNpmWrapper": true, "user": Any, @@ -1060,6 +1066,7 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "com.mycompany.myapp", ], "entitySuffix": "", + "eslintConfigFile": "eslint.config.mjs", "fakerSeed": undefined, "feignClient": undefined, "fromInit": undefined, @@ -1231,6 +1238,7 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "@types/node": "TYPES_NODE_VERSION", "@types/sockjs-client": "TYPES_SOCKJS_CLIENT_VERSION", "@typescript-eslint/eslint-plugin": "TYPESCRIPT_ESLINT_ESLINT_PLUGIN_VERSION", + "angular-eslint": "ANGULAR_ESLINT_VERSION", "babel-loader": "BABEL_LOADER_VERSION", "babel-plugin-istanbul": "BABEL_PLUGIN_ISTANBUL_VERSION", "bootstrap": "BOOTSTRAP_VERSION", @@ -1246,8 +1254,10 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "eslint": "ESLINT_VERSION", "eslint-config-prettier": "ESLINT_CONFIG_PRETTIER_VERSION", "eslint-plugin-cypress": "ESLINT_PLUGIN_CYPRESS_VERSION", + "eslint-plugin-prettier": "ESLINT_PLUGIN_PRETTIER_VERSION", "eslint-webpack-plugin": "ESLINT_WEBPACK_PLUGIN_VERSION", "folder-hash": "FOLDER_HASH_VERSION", + "globals": "GLOBALS_VERSION", "husky": "HUSKY_VERSION", "jest": "JEST_VERSION", "jest-date-mock": "JEST_DATE_MOCK_VERSION", @@ -1272,6 +1282,7 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "ts-jest": "TS_JEST_VERSION", "tslib": "TSLIB_VERSION", "typescript": "TYPESCRIPT_VERSION", + "typescript-eslint": "TYPESCRIPT_ESLINT_VERSION", "wait-on": "WAIT_ON_VERSION", "webpack": "WEBPACK_VERSION", "webpack-bundle-analyzer": "WEBPACK_BUNDLE_ANALYZER_VERSION", @@ -1392,6 +1403,7 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "testJavaDir": "src/test/java/", "testJavaPackageDir": "src/test/java/com/mycompany/myapp/", "testResourceDir": "src/test/resources/", + "typescriptEslint": true, "upperFirstCamelCaseBaseName": "Jhipster", "useNpmWrapper": true, "user": Any, diff --git a/generators/client/files-common.js b/generators/client/files-common.js index c11c3840d31d..28b65e0d90bc 100644 --- a/generators/client/files-common.js +++ b/generators/client/files-common.js @@ -27,7 +27,7 @@ export const files = { templates: ['README.md.jhi.client', '.prettierignore.jhi.client'], }, clientRootTemplatesBlock({ - condition: ctx => !ctx.clientFrameworkReact, + condition: ctx => !ctx.clientFrameworkReact && !ctx.clientFrameworkAngular, templates: ['.eslintignore'], }), clientRootTemplatesBlock({ diff --git a/generators/workspaces/generator.js b/generators/workspaces/generator.js index 10f307d070e1..6603417aab56 100644 --- a/generators/workspaces/generator.js +++ b/generators/workspaces/generator.js @@ -200,8 +200,8 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { rxjs, // Set version to workaround https://github.com/npm/cli/issues/4437 }, overrides: { - webpack: webpackVersion, 'browser-sync': browserSyncVersion, + webpack: webpackVersion, }, }); } From f0c5504b46623ccd446a885b93007d0f1a9805cb Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 18 Jul 2024 13:16:48 -0300 Subject: [PATCH 3/6] workaround processInlineTemplates processor issue --- .../angular/templates/eslint.config.js.jhi.angular.ejs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/generators/angular/templates/eslint.config.js.jhi.angular.ejs b/generators/angular/templates/eslint.config.js.jhi.angular.ejs index d2b94cdbae34..2dd8e3da6fb8 100644 --- a/generators/angular/templates/eslint.config.js.jhi.angular.ejs +++ b/generators/angular/templates/eslint.config.js.jhi.angular.ejs @@ -41,7 +41,13 @@ import angular from 'angular-eslint'; project: ['./tsconfig.app.json', './tsconfig.spec.json'], }, }, - processor: angular.processInlineTemplates, + processor: { + // https://github.com/angular-eslint/angular-eslint/issues/1917 + meta:{ + name:'extract-inline-html', + }, + ...angular.processInlineTemplates, + }, rules: { '@angular-eslint/component-selector': [ 'error', From dfc16d5dee13bcafd66b1aceff1acb39870deb66 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 18 Jul 2024 13:17:01 -0300 Subject: [PATCH 4/6] drop ban-types rule and disable no-empty-object-type rule --- .../angular/templates/eslint.config.js.jhi.angular.ejs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/generators/angular/templates/eslint.config.js.jhi.angular.ejs b/generators/angular/templates/eslint.config.js.jhi.angular.ejs index 2dd8e3da6fb8..a8040493294f 100644 --- a/generators/angular/templates/eslint.config.js.jhi.angular.ejs +++ b/generators/angular/templates/eslint.config.js.jhi.angular.ejs @@ -66,15 +66,6 @@ import angular from 'angular-eslint'; }, ], '@angular-eslint/relative-url-prefix': 'error', - '@typescript-eslint/ban-types': [ - 'error', - { - extendDefaults: true, - types: { - '{}': false, - }, - }, - ], '@typescript-eslint/consistent-type-definitions': 'off', '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }], '@typescript-eslint/explicit-module-boundary-types': 'off', @@ -99,6 +90,7 @@ import angular from 'angular-eslint'; }, ], '@typescript-eslint/no-confusing-void-expression': 'off', + '@typescript-eslint/no-empty-object-type': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-extraneous-class': 'off', '@typescript-eslint/no-floating-promises': 'off', From c5697aaa07aabcd2c9e05bd726d424b75959d1de Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 18 Jul 2024 14:47:59 -0300 Subject: [PATCH 5/6] fix eslint in docker folder --- generators/docker/templates/eslint.config.js.jhi.docker.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/docker/templates/eslint.config.js.jhi.docker.ejs b/generators/docker/templates/eslint.config.js.jhi.docker.ejs index 29c527bc5d0c..2ff48d70bd5c 100644 --- a/generators/docker/templates/eslint.config.js.jhi.docker.ejs +++ b/generators/docker/templates/eslint.config.js.jhi.docker.ejs @@ -17,5 +17,5 @@ limitations under the License. -%> <&_ if (fragment.configSection) { -&> - { files: ['**/*.js'], ignores: ['<%- dockerServicesDir %>'] }, + { ignores: ['<%- dockerServicesDir %>'] }, <&_ } -&> From 2a579cecfea008d1cb59289a2419355057bb9f38 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 18 Jul 2024 16:28:17 -0300 Subject: [PATCH 6/6] cleanup --- generators/angular/resources/package.json | 2 -- generators/app/__snapshots__/generator.spec.ts.snap | 4 ---- 2 files changed, 6 deletions(-) diff --git a/generators/angular/resources/package.json b/generators/angular/resources/package.json index 62dbb1d74734..1e656b768df1 100644 --- a/generators/angular/resources/package.json +++ b/generators/angular/resources/package.json @@ -23,12 +23,10 @@ "@angular-architects/module-federation-runtime": "18.0.4", "@angular-builders/custom-webpack": "18.0.0", "@angular-builders/jest": "18.0.0", - "@angular-eslint/eslint-plugin": "18.1.0", "@angular/cli": "18.1.1", "@types/jest": "29.5.12", "@types/node": "20.11.25", "@types/sockjs-client": "1.5.4", - "@typescript-eslint/eslint-plugin": "7.16.1", "angular-eslint": "18.1.0", "browser-sync": "3.0.2", "browser-sync-webpack-plugin": "2.3.0", diff --git a/generators/app/__snapshots__/generator.spec.ts.snap b/generators/app/__snapshots__/generator.spec.ts.snap index 441f998a49e0..41fca92f6e23 100644 --- a/generators/app/__snapshots__/generator.spec.ts.snap +++ b/generators/app/__snapshots__/generator.spec.ts.snap @@ -612,7 +612,6 @@ exports[`generator - app with default config should match snapshot 1`] = ` "@angular-architects/module-federation-runtime": "ANGULAR_ARCHITECTS_MODULE_FEDERATION_RUNTIME_VERSION", "@angular-builders/custom-webpack": "ANGULAR_BUILDERS_CUSTOM_WEBPACK_VERSION", "@angular-builders/jest": "ANGULAR_BUILDERS_JEST_VERSION", - "@angular-eslint/eslint-plugin": "ANGULAR_ESLINT_ESLINT_PLUGIN_VERSION", "@angular/cli": "ANGULAR_CLI_VERSION", "@angular/common": "ANGULAR_COMMON_VERSION", "@cypress/code-coverage": "CYPRESS_CODE_COVERAGE_VERSION", @@ -627,7 +626,6 @@ exports[`generator - app with default config should match snapshot 1`] = ` "@types/jest": "TYPES_JEST_VERSION", "@types/node": "TYPES_NODE_VERSION", "@types/sockjs-client": "TYPES_SOCKJS_CLIENT_VERSION", - "@typescript-eslint/eslint-plugin": "TYPESCRIPT_ESLINT_ESLINT_PLUGIN_VERSION", "angular-eslint": "ANGULAR_ESLINT_VERSION", "babel-loader": "BABEL_LOADER_VERSION", "babel-plugin-istanbul": "BABEL_PLUGIN_ISTANBUL_VERSION", @@ -1222,7 +1220,6 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "@angular-architects/module-federation-runtime": "ANGULAR_ARCHITECTS_MODULE_FEDERATION_RUNTIME_VERSION", "@angular-builders/custom-webpack": "ANGULAR_BUILDERS_CUSTOM_WEBPACK_VERSION", "@angular-builders/jest": "ANGULAR_BUILDERS_JEST_VERSION", - "@angular-eslint/eslint-plugin": "ANGULAR_ESLINT_ESLINT_PLUGIN_VERSION", "@angular/cli": "ANGULAR_CLI_VERSION", "@angular/common": "ANGULAR_COMMON_VERSION", "@cypress/code-coverage": "CYPRESS_CODE_COVERAGE_VERSION", @@ -1237,7 +1234,6 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "@types/jest": "TYPES_JEST_VERSION", "@types/node": "TYPES_NODE_VERSION", "@types/sockjs-client": "TYPES_SOCKJS_CLIENT_VERSION", - "@typescript-eslint/eslint-plugin": "TYPESCRIPT_ESLINT_ESLINT_PLUGIN_VERSION", "angular-eslint": "ANGULAR_ESLINT_VERSION", "babel-loader": "BABEL_LOADER_VERSION", "babel-plugin-istanbul": "BABEL_PLUGIN_ISTANBUL_VERSION",