From 7ff392de530ee76a26231f36088bc695bffdbd2a Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 3 Nov 2024 17:59:16 +0100 Subject: [PATCH] Vue/ESLint: add @typescript-eslint/consistent-type-imports rule --- .../generator/client/vue/core/domain/VueModulesFactory.java | 1 + .../generator/client/common/cypress/utils/Interceptor.ts | 2 +- .../client/common/playwright/common/primary/app/Home-Page.ts | 2 +- .../vue-oauth2-keycloak-authentication-components.md | 2 +- .../generator/client/vue/i18n/src/test/HomePageVue.spec.ts | 2 +- .../webapp/app/auth/application/AuthProvider.ts.mustache | 2 +- .../infrastructure/secondary/KeycloakAuthRepository.ts.mustache | 2 +- .../app/auth/infrastructure/secondary/KeycloakHttp.ts.mustache | 2 +- .../unit/auth/infrastructure/secondary/KeycloakStub.ts.mustache | 2 +- .../resources/generator/client/vue/webapp/app/env.d.ts.mustache | 2 +- .../router/infrastructure/primary/HomeRouter.spec.ts.mustache | 2 +- src/test/resources/projects/vue/HomepageVue.spec.ts.template | 2 +- ...toryTest.shouldCreateVueModule.eslint.config.js.approved.txt | 1 + src/test/webapp/unit/root/infrastructure/primary/App.spec.ts | 2 +- 14 files changed, 14 insertions(+), 12 deletions(-) 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 6119d26c382..33e43d96a1e 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 @@ private Consumer patchEslintConfig(JHipsterModuleProperti .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 da9e9663799..07602571751 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 8d61573c7f2..8dbc0591176 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 49384df281d..e376bf8e119 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/i18n/src/test/HomePageVue.spec.ts b/src/main/resources/generator/client/vue/i18n/src/test/HomePageVue.spec.ts index b082d640bb7..536fa9cff77 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/auth/application/AuthProvider.ts.mustache b/src/main/resources/generator/client/vue/security/oauth2_keycloak/webapp/app/auth/application/AuthProvider.ts.mustache index 9ccdb2992a3..8bc094212d5 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 6d9613b07dc..920ecbe6fb8 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 e21618f1ab4..7a7a9651a63 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/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 d49fdea7498..c8a8ff8cff0 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/env.d.ts.mustache b/src/main/resources/generator/client/vue/webapp/app/env.d.ts.mustache index 025ac41ec43..2435bff5c02 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 @@ /// declare module '*.vue' { - import { DefineComponent } from 'vue'; + import type DefineComponent from 'vue'; const component: DefineComponent<{}, {}, any>; export default component; } 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 b40d2e636ff..340d6a158d5 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 b082d640bb7..536fa9cff77 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 a45582a4a09..275694c9617 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 24f572233a8..2af6cdb3f8c 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;