0

The generated Angular component names and module names are prefixed with the base application name specified when generating the code with JHipster as seen by the Entity Module imports shown below for a generated project.

In the following example from a generated entity.module.ts file, the entity module names have a prefix of "Gohomenotes" based I had specified a base application name of "gohomenotes" when I generated the code.

@NgModule({
imports: [
    GohomenotesPersonModule,
    GohomenotesStudentModule,
    GohomenotesHomeRoomModule,
    GohomenotesTeacherModule,
    GohomenotesSchoolModule,
    GohomenotesHostRequestModule,
    GohomenotesGuestRequestModule,
    GohomenotesEarlyPickupRequestModule,
    GohomenotesTransportationChangeRequestModule,
    GohomenotesFamilyModule,
    GohomenotesFamilyMemberModule,
    GohomenotesAddressModule,
    GohomenotesPhoneNumberModule,
    GohomenotesGoHomeNotesSettingsModule

However, the corresponding filenames do not include the base application name. This is not consistent with the Angular style guide and makes the code harder to read IMO.

Unless there is a practical reason that this is necessary, I'd prefer to not have the base application name on the component and module class names. Is there any harm if I remove the application base name from the module and component class names?

Nathan Ward
  • 560
  • 5
  • 16

1 Answers1

0

I asked this question on Gitter and got an answer from Shaheen Georgee @1in9ui5t...

Why are Angular Component and Module class names for Entities prefixed with the application base name?

"MyAppStudentModule" Rather than just "StudentModule" when I have an entity named "Student"?

Most likely to avoid potential naming conflicts with other modules in your Angular application. For example, let’s say you were working on a medical application and had a Test entity to signify some medical exam that your organization conducts; if you generated a Test entity (poor name I know), then generated test.module.ts would cause a naming conflict as there is already a module with that name.

I’m taking a guess here, I know from looking at Jhipster code in the past that there are black-listed terms.

Related: Name collision by module import in Angular 2 - is there a way to prevent it

Community
  • 1
  • 1
Nathan Ward
  • 560
  • 5
  • 16