Skip to content

apply eslint/prettier to angular templates #26952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,62 +23,54 @@

<<%= jhiPrefixDashed %>-alert-error></<%= jhiPrefixDashed %>-alert-error>

@if (!success()) {
<div class="alert alert-warning">
<span>__jhiTranslateTag__('reset.request.messages.info')</span>
</div>
<form name="form" (ngSubmit)="requestReset()" [formGroup]="resetRequestForm">
<div class="mb-3">
<label class="form-label" for="email">__jhiTranslateTag__('global.form.email.label')</label>
<input
type="email"
class="form-control"
id="email"
name="email"
placeholder="__jhiTranslatePipe__('global.form.email.placeholder')"
formControlName="email"
data-cy="emailResetPassword"
#email
/>
@if (!success()) {
<div class="alert alert-warning">
<span>__jhiTranslateTag__('reset.request.messages.info')</span>
</div>
<form name="form" (ngSubmit)="requestReset()" [formGroup]="resetRequestForm">
<div class="mb-3">
<label class="form-label" for="email">__jhiTranslateTag__('global.form.email.label')</label>
<input
type="email"
class="form-control"
id="email"
name="email"
placeholder="__jhiTranslatePipe__('global.form.email.placeholder')"
formControlName="email"
data-cy="emailResetPassword"
#email
/>

@let emailRef = resetRequestForm.get('email')!;
@if (emailRef.invalid &&
(emailRef.dirty || emailRef.touched)) {
<div>
@if (emailRef?.errors?.required) {
<small class="form-text text-danger"
>__jhiTranslateTag__('global.messages.validate.email.required')</small>
}
@if (emailRef?.errors?.email) {
<small class="form-text text-danger"
>__jhiTranslateTag__('global.messages.validate.email.invalid')</small>
}
@let emailRef = resetRequestForm.get('email')!;
@if (emailRef.invalid && (emailRef.dirty || emailRef.touched)) {
<div>
@if (emailRef?.errors?.required) {
<small class="form-text text-danger">__jhiTranslateTag__('global.messages.validate.email.required')</small>
}
@if (emailRef?.errors?.email) {
<small class="form-text text-danger">__jhiTranslateTag__('global.messages.validate.email.invalid')</small>
}

@if (emailRef?.errors?.minlength) {
<small class="form-text text-danger"
>__jhiTranslateTag__('global.messages.validate.email.minlength')</small>
}
@if (emailRef?.errors?.minlength) {
<small class="form-text text-danger">__jhiTranslateTag__('global.messages.validate.email.minlength')</small>
}

@if (emailRef?.errors?.maxlength) {
<small class="form-text text-danger"
>__jhiTranslateTag__('global.messages.validate.email.maxlength')</small>
}
@if (emailRef?.errors?.maxlength) {
<small class="form-text text-danger">__jhiTranslateTag__('global.messages.validate.email.maxlength')</small>
}
</div>
}
</div>
}
<button type="submit" [disabled]="resetRequestForm.invalid" class="btn btn-primary" data-cy="submit">
__jhiTranslateTag__('reset.request.form.button')
</button>
</form>
} @else {
<div class="alert alert-success">
<span>__jhiTranslateTag__('reset.request.messages.success')</span>
</div>

<button
type="submit"
[disabled]="resetRequestForm.invalid"
class="btn btn-primary"
data-cy="submit"
>__jhiTranslateTag__('reset.request.form.button')</button>
</form>
} @else {
<div class="alert alert-success">
<span>__jhiTranslateTag__('reset.request.messages.success')</span>
</div>
}
}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@

<div class="mt-3 alert alert-warning">
<span>__jhiTranslateTag__('global.messages.info.authenticated.prefix')</span>
<a class="alert-link" routerLink="/login">__jhiTranslateTag__('global.messages.info.authenticated.link')</a><span>__jhiTranslateTag__('global.messages.info.authenticated.suffix')</span>
<a class="alert-link" routerLink="/login">__jhiTranslateTag__('global.messages.info.authenticated.link')</a
><span>__jhiTranslateTag__('global.messages.info.authenticated.suffix')</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ describe('User Management Component', () => {
new HttpResponse({
body: [new User(<%- tsKeyId %>)],
headers,
})
)
}),
),
);

// WHEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const translationNotFoundMessage = 'translation-not-found';

export class MissingTranslationHandlerImpl implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams): string {
const key = params.key;
const { key } = params;
return `${translationNotFoundMessage}[${key}]`;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const UserRouteAccessService: CanActivateFn = (next: ActivatedRouteSnapsh
return accountService.identity().pipe(
map(account => {
if (account) {
const authorities = next.data.authorities;
const { authorities } = next.data;

if (!authorities || authorities.length === 0 || accountService.hasAnyAuthority(authorities)) {
return true;
Expand All @@ -56,6 +56,6 @@ export const UserRouteAccessService: CanActivateFn = (next: ActivatedRouteSnapsh
loginService.login();
<%_ } _%>
return false;
})
}),
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ describe('Alert service test', () => {
expect.objectContaining({
type: 'info',
message: 'Hello Jhipster',
} as Alert)
} as Alert),
);
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class DataUtils {
};
observer.error(error);
} else {
const fieldContentType = field + 'ContentType';
const fieldContentType = `${field}ContentType`;
this.toBase64(file, (base64Data: string) => {
editForm.patchValue({
[field]: base64Data,
Expand Down Expand Up @@ -143,6 +143,6 @@ export class DataUtils {
}

private formatAsBytes(size: number): string {
return size.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ') + ' bytes'; // NOSONAR
return `${size.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')} bytes`; // NOSONAR
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const <%= entityInstance %>Route: Routes = [
authorities: [<%- entityAngularReadAuthorities %>],
<%_ } _%>
},
canActivate: [UserRouteAccessService]
canActivate: [UserRouteAccessService],
},
{
path: ':<%= primaryKey.name %>/view',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('MainComponent', () => {
translateService.onLangChange.emit(langChangeEvent);

// THEN
expect(document.title).toBe(defaultPageTitle + ' translated');
expect(document.title).toBe(`${defaultPageTitle} translated`);
});

it('should set page title to root route pageTitle if there is no child routes', fakeAsync(() => {
Expand All @@ -192,7 +192,7 @@ describe('MainComponent', () => {
tick();

// THEN
expect(document.title).toBe(parentRoutePageTitle + ' translated');
expect(document.title).toBe(`${parentRoutePageTitle} translated`);

// GIVEN
document.title = 'other title';
Expand All @@ -201,7 +201,7 @@ describe('MainComponent', () => {
translateService.onLangChange.emit(langChangeEvent);

// THEN
expect(document.title).toBe(parentRoutePageTitle + ' translated');
expect(document.title).toBe(`${parentRoutePageTitle} translated`);
}));

it('should set page title to child route pageTitle if child routes exist and pageTitle is set for child route', fakeAsync(() => {
Expand All @@ -219,7 +219,7 @@ describe('MainComponent', () => {
tick();

// THEN
expect(document.title).toBe(childRoutePageTitle + ' translated');
expect(document.title).toBe(`${childRoutePageTitle} translated`);

// GIVEN
document.title = 'other title';
Expand All @@ -228,7 +228,7 @@ describe('MainComponent', () => {
translateService.onLangChange.emit(langChangeEvent);

// THEN
expect(document.title).toBe(childRoutePageTitle + ' translated');
expect(document.title).toBe(`${childRoutePageTitle} translated`);
}));

it('should set page title to parent route pageTitle if child routes exists but pageTitle is not set for child route data', fakeAsync(() => {
Expand All @@ -246,7 +246,7 @@ describe('MainComponent', () => {
tick();

// THEN
expect(document.title).toBe(parentRoutePageTitle + ' translated');
expect(document.title).toBe(`${parentRoutePageTitle} translated`);

// GIVEN
document.title = 'other title';
Expand All @@ -255,7 +255,7 @@ describe('MainComponent', () => {
translateService.onLangChange.emit(langChangeEvent);

// THEN
expect(document.title).toBe(parentRoutePageTitle + ' translated');
expect(document.title).toBe(`${parentRoutePageTitle} translated`);
}));
});
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
</form>
<%_ if (generateUserManagement) { _%>
<div class="mt-3 alert alert-warning">
<a class="alert-link" routerLink="/account/reset/request" data-cy="forgetYourPasswordSelector">__jhiTranslateTag__('login.password.forgot')</a>
<a class="alert-link" routerLink="/account/reset/request" data-cy="forgetYourPasswordSelector"
>__jhiTranslateTag__('login.password.forgot')</a
>
</div>

<div class="alert alert-warning">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class AlertErrorComponent implements OnDestroy {
}

private handleFieldsError(httpErrorResponse: HttpErrorResponse): void {
const fieldErrors = httpErrorResponse.error.fieldErrors;
const { fieldErrors } = httpErrorResponse.error;
for (const fieldError of fieldErrors) {
if (['Min', 'Max', 'DecimalMin', 'DecimalMax'].includes(fieldError.message)) {
fieldError.message = 'Size';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FilterOption implements IFilterOption {
}

nameAsQueryParam(): string {
return 'filter[' + this.name + ']';
return `filter[${this.name}]`;
}

isSet(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class LazyTranslationModule {
private stateStorageService = inject(StateStorageService);

constructor() {
const currentLang = this.translateService.store.currentLang;
const { currentLang } = this.translateService.store;
this.translateLoader.getTranslation(currentLang).subscribe(translation => {
this.translateService.setTranslation(currentLang, translation);
});
Expand Down
4 changes: 2 additions & 2 deletions generators/angular/templates/webpack/webpack.custom.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const postcssRTLCSS = require('postcss-rtlcss');
<%_ } _%>
<%_ } _%>
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const WebpackNotifierPlugin = require('webpack-notifier');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
Expand All @@ -54,7 +54,7 @@ module.exports = async (config, options, targetOptions) => {
new WebpackNotifierPlugin({
title: '<%= humanizedBaseName %>',
contentImage: path.join(__dirname, 'logo-jhipster.png'),
})
}),
);
}

Expand Down
13 changes: 10 additions & 3 deletions generators/client/templates/src/main/webapp/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,22 @@

<h3>If you have a question on how to use JHipster</h3>
<p>
Go to Stack Overflow with the <a href="http://stackoverflow.com/tags/jhipster" target="_blank" rel="noopener noreferrer">"jhipster"</a> tag.
Go to Stack Overflow with the
<a href="http://stackoverflow.com/tags/jhipster" target="_blank" rel="noopener noreferrer">"jhipster"</a> tag.
</p>

<h3>If you have a bug or a feature request</h3>
<p>
First read our <a href="https://github.com/jhipster/generator-jhipster/blob/main/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer">contributing guidelines</a>.
First read our
<a href="https://github.com/jhipster/generator-jhipster/blob/main/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer"
>contributing guidelines</a
>.
</p>
<p>
Then, fill a ticket on our <a href="https://github.com/jhipster/generator-jhipster/issues/new/choose" target="_blank" rel="noopener noreferrer">bug tracker</a>, we'll be happy to resolve your issue!
Then, fill a ticket on our
<a href="https://github.com/jhipster/generator-jhipster/issues/new/choose" target="_blank" rel="noopener noreferrer"
>bug tracker</a
>, we'll be happy to resolve your issue!
</p>

<h3>If you want to chat with contributors and other users</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@
req.headers['Authorization'] = getBearerToken();
<%_ } _%>
// Remove the sample Swagger UI request body if present
if (
req.method === 'GET' &&
req.body === '{"additionalProp1":"string","additionalProp2":"string","additionalProp3":"string"}'
) {
if (req.method === 'GET' && req.body === '{"additionalProp1":"string","additionalProp2":"string","additionalProp3":"string"}') {
req.body = undefined;
}
return req;
Expand Down
Loading