Repository: jhipster/jhipster-lite
Pull request #11296 (2024-11-03 16:59:41)

Vue/ESLint: add @typescript-eslint/consistent-type-imports rule


Patch:
diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
index 6119d26c3..33e43d96a 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java
@@ -149,6 +149,7 @@ public class VueModulesFactory {
           .add(eslintTypescriptVueRule("'vue/html-self-closing': 'off',", properties.indentation()))
           .add(eslintTypescriptVueRule("'@typescript-eslint/no-explicit-any': 'off',", properties.indentation()))
           .add(eslintTypescriptVueRule("'@typescript-eslint/no-empty-object-type': 'off',", properties.indentation()))
+          .add(eslintTypescriptVueRule("'@typescript-eslint/consistent-type-imports': 'error',", properties.indentation()))
           .and()
         .and();
     //@formatter:on
diff --git a/src/main/resources/generator/client/common/cypress/utils/Interceptor.ts b/src/main/resources/generator/client/common/cypress/utils/Interceptor.ts
index da9e96637..076025717 100755
--- a/src/main/resources/generator/client/common/cypress/utils/Interceptor.ts
+++ b/src/main/resources/generator/client/common/cypress/utils/Interceptor.ts
@@ -1,4 +1,4 @@
-import { HttpResponseInterceptor, RouteMatcher, StaticResponse } from 'cypress/types/net-stubbing';
+import type { HttpResponseInterceptor, RouteMatcher, StaticResponse } from 'cypress/types/net-stubbing';
 
 type ResponseSender = {
   send: () => void;
diff --git a/src/main/resources/generator/client/common/playwright/common/primary/app/Home-Page.ts b/src/main/resources/generator/client/common/playwright/common/primary/app/Home-Page.ts
index 8d61573c7..8dbc05911 100644
--- a/src/main/resources/generator/client/common/playwright/common/primary/app/Home-Page.ts
+++ b/src/main/resources/generator/client/common/playwright/common/primary/app/Home-Page.ts
@@ -1,4 +1,4 @@
-import { Page } from '@playwright/test';
+import { type Page } from '@playwright/test';
 
 export class HomePage {
   readonly page: Page;
diff --git a/src/main/resources/generator/client/vue/documentation/vue-oauth2-keycloak-authentication-components.md b/src/main/resources/generator/client/vue/documentation/vue-oauth2-keycloak-authentication-components.md
index 49384df28..e376bf8e1 100644
--- a/src/main/resources/generator/client/vue/documentation/vue-oauth2-keycloak-authentication-components.md
+++ b/src/main/resources/generator/client/vue/documentation/vue-oauth2-keycloak-authentication-components.md
@@ -423,7 +423,7 @@ Location: `src/test/webapp/unit/auth/infrastructure/secondary/KeycloakStub.ts`
 This file provides a stub for Keycloak to be used in tests.
 
 ```typescript
-import Keycloak from 'keycloak-js';
+import type Keycloak from 'keycloak-js';
 import sinon from 'sinon';
 import type { SinonStub } from 'sinon';
 
diff --git a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/application/AuthProvider.ts.mustache b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/application/AuthProvider.ts.mustache
index 9ccdb2992..8bc094212 100644
--- a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/application/AuthProvider.ts.mustache
+++ b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/application/AuthProvider.ts.mustache
@@ -1,6 +1,6 @@
 import type { AuthRepository } from '@/auth/domain/AuthRepository';
 import { KeycloakAuthRepository } from '@/auth/infrastructure/secondary/KeycloakAuthRepository';
-import { KeycloakHttp } from '@/auth/infrastructure/secondary/KeycloakHttp';
+import { type KeycloakHttp } from '@/auth/infrastructure/secondary/KeycloakHttp';
 import { provide } from '@/injections';
 import { key } from 'piqure';
 
diff --git a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakAuthRepository.ts.mustache b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakAuthRepository.ts.mustache
index 6d9613b07..920ecbe6f 100644
--- a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakAuthRepository.ts.mustache
+++ b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakAuthRepository.ts.mustache
@@ -1,6 +1,6 @@
 import type { AuthRepository } from '@/auth/domain/AuthRepository';
 import type { AuthenticatedUser } from '@/auth/domain/AuthenticatedUser';
-import { KeycloakHttp } from './KeycloakHttp';
+import { type KeycloakHttp } from './KeycloakHttp';
 
 export class KeycloakAuthRepository implements AuthRepository {
   constructor(private readonly keycloakHttp: KeycloakHttp) {}
diff --git a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakHttp.ts.mustache b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakHttp.ts.mustache
index e21618f1a..7a7a9651a 100644
--- a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakHttp.ts.mustache
+++ b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/infrastructure/secondary/KeycloakHttp.ts.mustache
@@ -1,5 +1,5 @@
 import type { AuthenticatedUser } from '@/auth/domain/AuthenticatedUser';
-import Keycloak from 'keycloak-js';
+import type Keycloak from 'keycloak-js';
 
 export class KeycloakHttp {
   private initialized: boolean = false;
diff --git a/src/main/resources/generator/client/vue/webapp/app/env.d.ts.mustache b/src/main/resources/generator/client/vue/webapp/app/env.d.ts.mustache
index 025ac41ec..2435bff5c 100644
--- a/src/main/resources/generator/client/vue/webapp/app/env.d.ts.mustache
+++ b/src/main/resources/generator/client/vue/webapp/app/env.d.ts.mustache
@@ -1,7 +1,7 @@
 /// <reference types="vite/client" />
 
 declare module '*.vue' {
-  import { DefineComponent } from 'vue';
+  import type DefineComponent from 'vue';
   const component: DefineComponent<{}, {}, any>;
   export default component;
 }


Test patch:
diff --git a/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts b/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts
index b082d640b..536fa9cff 100644
--- a/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts
+++ b/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts
@@ -1,5 +1,5 @@
 import HomepageVue from '@/home/infrastructure/primary/HomepageVue.vue';
-import { shallowMount, VueWrapper } from '@vue/test-utils';
+import { shallowMount, type VueWrapper } from '@vue/test-utils';
 import { describe, expect, it } from 'vitest';
 
 let wrapper: VueWrapper;
diff --git a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/test/webapp/unit/auth/infrastructure/secondary/KeycloakStub.ts.mustache b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/test/webapp/unit/auth/infrastructure/secondary/KeycloakStub.ts.mustache
index d49fdea74..c8a8ff8cf 100644
--- a/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/test/webapp/unit/auth/infrastructure/secondary/KeycloakStub.ts.mustache
+++ b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/test/webapp/unit/auth/infrastructure/secondary/KeycloakStub.ts.mustache
@@ -1,4 +1,4 @@
-import Keycloak from 'keycloak-js';
+import type Keycloak from 'keycloak-js';
 import type { SinonStub } from 'sinon';
 import sinon from 'sinon';
 
diff --git a/src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts.mustache b/src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts.mustache
index b40d2e636..340d6a158 100644
--- a/src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts.mustache
+++ b/src/main/resources/generator/client/vue/webapp/app/test/webapp/unit/router/infrastructure/primary/HomeRouter.spec.ts.mustache
@@ -1,6 +1,6 @@
 import HomepageVue from '@/home/infrastructure/primary/HomepageVue.vue';
 import { routes } from '@/router';
-import { mount, VueWrapper } from '@vue/test-utils';
+import { mount, type VueWrapper } from '@vue/test-utils';
 import { beforeEach, describe, expect, it } from 'vitest';
 import { createRouter, createWebHistory, type Router } from 'vue-router';
 
diff --git a/src/test/resources/projects/vue/HomepageVue.spec.ts.template b/src/test/resources/projects/vue/HomepageVue.spec.ts.template
index b082d640b..536fa9cff 100644
--- a/src/test/resources/projects/vue/HomepageVue.spec.ts.template
+++ b/src/test/resources/projects/vue/HomepageVue.spec.ts.template
@@ -1,5 +1,5 @@
 import HomepageVue from '@/home/infrastructure/primary/HomepageVue.vue';
-import { shallowMount, VueWrapper } from '@vue/test-utils';
+import { shallowMount, type VueWrapper } from '@vue/test-utils';
 import { describe, expect, it } from 'vitest';
 
 let wrapper: VueWrapper;
diff --git a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt
index a45582a4a..275694c96 100644
--- a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt
+++ b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt
@@ -31,6 +31,7 @@ export default typescript.config(
     },
     rules: {
       quotes: ['error', 'single', { avoidEscape: true }],
+      '@typescript-eslint/consistent-type-imports': 'error',
       '@typescript-eslint/no-empty-object-type': 'off',
       '@typescript-eslint/no-explicit-any': 'off',
       'vue/html-self-closing': 'off',
diff --git a/src/test/webapp/unit/root/infrastructure/primary/App.spec.ts b/src/test/webapp/unit/root/infrastructure/primary/App.spec.ts
index 24f572233..2af6cdb3f 100644
--- a/src/test/webapp/unit/root/infrastructure/primary/App.spec.ts
+++ b/src/test/webapp/unit/root/infrastructure/primary/App.spec.ts
@@ -1,5 +1,5 @@
 import { AppVue } from '@/root/infrastructure/primary';
-import { shallowMount, VueWrapper } from '@vue/test-utils';
+import { shallowMount, type VueWrapper } from '@vue/test-utils';
 import { describe, expect, it } from 'vitest';
 
 let wrapper: VueWrapper;