From 15160a833e2868874e2214516cac8653a45ad4d2 Mon Sep 17 00:00:00 2001 From: Viachaslau Date: Mon, 2 Sep 2024 12:30:33 +0400 Subject: [PATCH] chore(client): force `consistent-type-imports` eslint rule (#388) --- client/eslint.config.mjs | 11 +++++++++++ client/src/api/httpClient.ts | 19 ++++++++----------- client/src/api/makeApiRequest.ts | 2 +- client/src/pages/auth/AdminLayout.tsx | 2 +- client/src/pages/auth/AdminPage.tsx | 5 +++-- client/src/pages/auth/AuthLayout.tsx | 3 ++- client/src/pages/auth/Dashboard.tsx | 2 +- client/src/pages/auth/Login/Login.tsx | 11 ++++++----- .../src/pages/auth/Login/showLdapReponse.tsx | 2 +- .../src/pages/auth/Login/showLoginReponse.tsx | 2 +- client/src/pages/auth/LoginNew/LoginNew.tsx | 8 +++++--- .../src/pages/auth/LoginNew/PasswordCheck.tsx | 9 +++++---- client/src/pages/auth/Register/Register.tsx | 6 ++++-- .../pages/auth/Register/showRegReponse.tsx | 2 +- client/src/pages/chat/Chat.tsx | 2 +- client/src/pages/chat/ChatWidget.tsx | 12 +++--------- client/src/pages/main/Counts.tsx | 2 +- client/src/pages/main/FAQ.tsx | 2 +- client/src/pages/main/Footer.tsx | 3 ++- client/src/pages/main/Header/Header.tsx | 3 ++- client/src/pages/main/Header/Sign.tsx | 3 ++- client/src/pages/main/Hero.tsx | 2 +- client/src/pages/main/Main.tsx | 2 +- client/src/pages/main/Userprofile.tsx | 5 +++-- client/src/pages/marketplace/DatePicker.tsx | 3 ++- client/src/pages/marketplace/Marketplace.tsx | 5 +++-- .../pages/marketplace/Partners/Partners.tsx | 5 +++-- client/src/pages/marketplace/ProductView.tsx | 5 +++-- .../marketplace/Testimonials/Testimonials.tsx | 5 +++-- .../Testimonials/TestimonialsForm.tsx | 5 +++-- .../Testimonials/TestimonialsItems.tsx | 4 ++-- client/src/router/AppRoutes.tsx | 2 +- 32 files changed, 87 insertions(+), 67 deletions(-) diff --git a/client/eslint.config.mjs b/client/eslint.config.mjs index 094466a8..d1516ebb 100644 --- a/client/eslint.config.mjs +++ b/client/eslint.config.mjs @@ -16,5 +16,16 @@ export default tseslint.config( ...globals.browser } } + }, + { + rules: { + '@typescript-eslint/consistent-type-imports': [ + 'error', + { + prefer: 'type-imports', + fixStyle: 'separate-type-imports' + } + ] + } } ); diff --git a/client/src/api/httpClient.ts b/client/src/api/httpClient.ts index 1d843cf8..1695a157 100644 --- a/client/src/api/httpClient.ts +++ b/client/src/api/httpClient.ts @@ -1,14 +1,11 @@ -import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Testimonial } from '../interfaces/Testimonial'; -import { - LoginFormMode, - LoginUser, - RegistrationUser, - UserData -} from '../interfaces/User'; -import { Product } from '../interfaces/Product'; -import { OidcClient } from '../interfaces/Auth'; -import { ChatMessage } from '../interfaces/ChatMessage'; +import type { AxiosInstance, AxiosRequestConfig } from 'axios'; +import axios from 'axios'; +import type { Testimonial } from '../interfaces/Testimonial'; +import type { LoginUser, RegistrationUser, UserData } from '../interfaces/User'; +import { LoginFormMode } from '../interfaces/User'; +import type { Product } from '../interfaces/Product'; +import type { OidcClient } from '../interfaces/Auth'; +import type { ChatMessage } from '../interfaces/ChatMessage'; import { ApiUrl } from './ApiUrl'; import { makeApiRequest } from './makeApiRequest'; diff --git a/client/src/api/makeApiRequest.ts b/client/src/api/makeApiRequest.ts index 067f9c89..9a750e60 100644 --- a/client/src/api/makeApiRequest.ts +++ b/client/src/api/makeApiRequest.ts @@ -1,4 +1,4 @@ -import { AxiosRequestConfig } from 'axios'; +import type { AxiosRequestConfig } from 'axios'; import { httpClient } from './httpClient'; export function makeApiRequest( diff --git a/client/src/pages/auth/AdminLayout.tsx b/client/src/pages/auth/AdminLayout.tsx index cc26ebca..70ba5ae4 100644 --- a/client/src/pages/auth/AdminLayout.tsx +++ b/client/src/pages/auth/AdminLayout.tsx @@ -1,4 +1,4 @@ -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; export const AdminLayout: FC = ({ children }) => { return ( diff --git a/client/src/pages/auth/AdminPage.tsx b/client/src/pages/auth/AdminPage.tsx index 30af063d..3e1bfd64 100644 --- a/client/src/pages/auth/AdminPage.tsx +++ b/client/src/pages/auth/AdminPage.tsx @@ -1,5 +1,6 @@ -import { ChangeEvent, FC, useEffect, useState } from 'react'; -import { UserData } from '../../interfaces/User'; +import type { ChangeEvent, FC } from 'react'; +import { useEffect, useState } from 'react'; +import type { UserData } from '../../interfaces/User'; import { getAdminStatus, searchUsers } from '../../api/httpClient'; import AdminLayout from './AdminLayout'; diff --git a/client/src/pages/auth/AuthLayout.tsx b/client/src/pages/auth/AuthLayout.tsx index 955fc207..553640cf 100644 --- a/client/src/pages/auth/AuthLayout.tsx +++ b/client/src/pages/auth/AuthLayout.tsx @@ -1,4 +1,5 @@ -import { ReactNode, useRef, useEffect, FC } from 'react'; +import type { ReactNode, FC } from 'react'; +import { useRef, useEffect } from 'react'; type Props = { children?: ReactNode; diff --git a/client/src/pages/auth/Dashboard.tsx b/client/src/pages/auth/Dashboard.tsx index 349d8446..3162a5d1 100644 --- a/client/src/pages/auth/Dashboard.tsx +++ b/client/src/pages/auth/Dashboard.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import AuthLayout from './AuthLayout'; export const Dashboard: FC = () => { diff --git a/client/src/pages/auth/Login/Login.tsx b/client/src/pages/auth/Login/Login.tsx index 00d861c9..553d35e5 100644 --- a/client/src/pages/auth/Login/Login.tsx +++ b/client/src/pages/auth/Login/Login.tsx @@ -1,8 +1,9 @@ -import { AxiosRequestConfig } from 'axios'; +import type { AxiosRequestConfig } from 'axios'; import getBrowserFingerprint from 'get-browser-fingerprint'; -import { FC, FormEvent, useEffect, useState } from 'react'; +import type { FC, FormEvent } from 'react'; +import { useEffect, useState } from 'react'; import { Link, useLocation } from 'react-router-dom'; -import { OidcClient } from '../../../interfaces/Auth'; +import type { OidcClient } from '../../../interfaces/Auth'; import { RoutePath } from '../../../router/RoutePath'; import { getLdap, @@ -12,13 +13,13 @@ import { loadDomXsrfToken, getOidcClient } from '../../../api/httpClient'; -import { - LoginFormMode, +import type { LoginResponse, LoginUser, UserData, RegistrationUser } from '../../../interfaces/User'; +import { LoginFormMode } from '../../../interfaces/User'; import AuthLayout from '../AuthLayout'; import showLdapResponse from './showLdapReponse'; import showLoginResponse from './showLoginReponse'; diff --git a/client/src/pages/auth/Login/showLdapReponse.tsx b/client/src/pages/auth/Login/showLdapReponse.tsx index acc5d69a..2226bdf7 100644 --- a/client/src/pages/auth/Login/showLdapReponse.tsx +++ b/client/src/pages/auth/Login/showLdapReponse.tsx @@ -1,4 +1,4 @@ -import { RegistrationUser } from '../../../interfaces/User'; +import type { RegistrationUser } from '../../../interfaces/User'; import showRegResponse from '../Register/showRegReponse'; export function showLdapResponse(ldapResponse: Array) { diff --git a/client/src/pages/auth/Login/showLoginReponse.tsx b/client/src/pages/auth/Login/showLoginReponse.tsx index 2f34fb2a..a95747c2 100644 --- a/client/src/pages/auth/Login/showLoginReponse.tsx +++ b/client/src/pages/auth/Login/showLoginReponse.tsx @@ -1,5 +1,5 @@ import InnerHTML from 'dangerously-set-html-content'; -import { LoginResponse } from '../../../interfaces/User'; +import type { LoginResponse } from '../../../interfaces/User'; export function showLoginResponse({ email, ldapProfileLink }: LoginResponse) { const fields = [ diff --git a/client/src/pages/auth/LoginNew/LoginNew.tsx b/client/src/pages/auth/LoginNew/LoginNew.tsx index dfdb3b24..15d71aa8 100644 --- a/client/src/pages/auth/LoginNew/LoginNew.tsx +++ b/client/src/pages/auth/LoginNew/LoginNew.tsx @@ -1,9 +1,11 @@ -import { AxiosRequestConfig } from 'axios'; -import { FC, FormEvent, useState } from 'react'; +import type { AxiosRequestConfig } from 'axios'; +import type { FC, FormEvent } from 'react'; +import { useState } from 'react'; import { Link } from 'react-router-dom'; import { RoutePath } from '../../../router/RoutePath'; import { getUserData } from '../../../api/httpClient'; -import { LoginFormMode, LoginUser, UserData } from '../../../interfaces/User'; +import type { LoginUser, UserData } from '../../../interfaces/User'; +import { LoginFormMode } from '../../../interfaces/User'; import AuthLayout from '../AuthLayout'; const defaultLoginUser: LoginUser = { diff --git a/client/src/pages/auth/LoginNew/PasswordCheck.tsx b/client/src/pages/auth/LoginNew/PasswordCheck.tsx index 384aec2f..b50fd096 100644 --- a/client/src/pages/auth/LoginNew/PasswordCheck.tsx +++ b/client/src/pages/auth/LoginNew/PasswordCheck.tsx @@ -1,14 +1,15 @@ -import { AxiosRequestConfig } from 'axios'; -import { FC, FormEvent, useEffect, useState } from 'react'; +import type { AxiosRequestConfig } from 'axios'; +import type { FC, FormEvent } from 'react'; +import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { RoutePath } from '../../../router/RoutePath'; import { getUser, getUserData } from '../../../api/httpClient'; -import { - LoginFormMode, +import type { LoginResponse, LoginUser, UserData } from '../../../interfaces/User'; +import { LoginFormMode } from '../../../interfaces/User'; import AuthLayout from '../AuthLayout'; const defaultLoginUser: LoginUser = { diff --git a/client/src/pages/auth/Register/Register.tsx b/client/src/pages/auth/Register/Register.tsx index a255f307..0638fa89 100644 --- a/client/src/pages/auth/Register/Register.tsx +++ b/client/src/pages/auth/Register/Register.tsx @@ -1,6 +1,8 @@ -import { FC, FormEvent, useState } from 'react'; +import type { FC, FormEvent } from 'react'; +import { useState } from 'react'; import { postUser } from '../../../api/httpClient'; -import { RegistrationUser, LoginFormMode } from '../../../interfaces/User'; +import type { RegistrationUser } from '../../../interfaces/User'; +import { LoginFormMode } from '../../../interfaces/User'; import AuthLayout from '../AuthLayout'; import { Link } from 'react-router-dom'; import showRegResponse from './showRegReponse'; diff --git a/client/src/pages/auth/Register/showRegReponse.tsx b/client/src/pages/auth/Register/showRegReponse.tsx index b188be94..b4c36a3f 100644 --- a/client/src/pages/auth/Register/showRegReponse.tsx +++ b/client/src/pages/auth/Register/showRegReponse.tsx @@ -1,5 +1,5 @@ import InnerHTML from 'dangerously-set-html-content'; -import { RegistrationUser } from '../../../interfaces/User'; +import type { RegistrationUser } from '../../../interfaces/User'; export function showRegResponse({ email, diff --git a/client/src/pages/chat/Chat.tsx b/client/src/pages/chat/Chat.tsx index 20daa155..508567cf 100644 --- a/client/src/pages/chat/Chat.tsx +++ b/client/src/pages/chat/Chat.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import Header from '../main/Header/Header'; import ChatWidget from './ChatWidget'; diff --git a/client/src/pages/chat/ChatWidget.tsx b/client/src/pages/chat/ChatWidget.tsx index cd927b1d..cb938dba 100644 --- a/client/src/pages/chat/ChatWidget.tsx +++ b/client/src/pages/chat/ChatWidget.tsx @@ -1,13 +1,7 @@ -import { - ChangeEvent, - FC, - KeyboardEvent, - useEffect, - useRef, - useState -} from 'react'; +import type { ChangeEvent, FC, KeyboardEvent } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { queryChat } from '../../api/httpClient'; -import { ChatMessage } from '../../interfaces/ChatMessage'; +import type { ChatMessage } from '../../interfaces/ChatMessage'; const UnsafeComponent: FC<{ html: string }> = ({ html }) => { return
; diff --git a/client/src/pages/main/Counts.tsx b/client/src/pages/main/Counts.tsx index 7c5c38b5..e8c7ac15 100644 --- a/client/src/pages/main/Counts.tsx +++ b/client/src/pages/main/Counts.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; export const Counts: FC = () => { const counters = [ diff --git a/client/src/pages/main/FAQ.tsx b/client/src/pages/main/FAQ.tsx index e6df8839..fbd84daa 100644 --- a/client/src/pages/main/FAQ.tsx +++ b/client/src/pages/main/FAQ.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; export const FAQ: FC = () => { const FAQItems = [ diff --git a/client/src/pages/main/Footer.tsx b/client/src/pages/main/Footer.tsx index eae9c3fd..16ccd1ab 100644 --- a/client/src/pages/main/Footer.tsx +++ b/client/src/pages/main/Footer.tsx @@ -1,4 +1,5 @@ -import { FC, FormEvent, useEffect, useState } from 'react'; +import type { FC, FormEvent } from 'react'; +import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import InnerHTML from 'dangerously-set-html-content'; import { postRender, postSubscriptions } from '../../api/httpClient'; diff --git a/client/src/pages/main/Header/Header.tsx b/client/src/pages/main/Header/Header.tsx index 114b16ed..23fa3fd7 100644 --- a/client/src/pages/main/Header/Header.tsx +++ b/client/src/pages/main/Header/Header.tsx @@ -1,4 +1,5 @@ -import { FC, useEffect } from 'react'; +import type { FC } from 'react'; +import { useEffect } from 'react'; import { Link } from 'react-router-dom'; import { goTo, postMetadata, getSpawnData } from '../../../api/httpClient'; import Nav from './Nav'; diff --git a/client/src/pages/main/Header/Sign.tsx b/client/src/pages/main/Header/Sign.tsx index 93ed6986..bc158d72 100644 --- a/client/src/pages/main/Header/Sign.tsx +++ b/client/src/pages/main/Header/Sign.tsx @@ -1,4 +1,5 @@ -import { ChangeEvent, FC, useEffect, useState } from 'react'; +import type { ChangeEvent, FC } from 'react'; +import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { Buffer } from 'buffer'; import { fileTypeFromBuffer } from 'file-type/core'; diff --git a/client/src/pages/main/Hero.tsx b/client/src/pages/main/Hero.tsx index 868010b9..65201422 100644 --- a/client/src/pages/main/Hero.tsx +++ b/client/src/pages/main/Hero.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; export const Hero: FC = () => { return ( diff --git a/client/src/pages/main/Main.tsx b/client/src/pages/main/Main.tsx index cb0a7695..dd52ae92 100644 --- a/client/src/pages/main/Main.tsx +++ b/client/src/pages/main/Main.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import Marketplace from '../marketplace/Marketplace'; import Counts from './Counts'; import Hero from './Hero'; diff --git a/client/src/pages/main/Userprofile.tsx b/client/src/pages/main/Userprofile.tsx index f3375d31..b6146890 100644 --- a/client/src/pages/main/Userprofile.tsx +++ b/client/src/pages/main/Userprofile.tsx @@ -1,4 +1,5 @@ -import { FormEvent, useEffect, useState } from 'react'; +import type { FormEvent } from 'react'; +import { useEffect, useState } from 'react'; import { Navigate } from 'react-router'; import { getAdminStatus, @@ -6,7 +7,7 @@ import { putUserData, removeUserPhotoById } from '../../api/httpClient'; -import { UserData } from '../../interfaces/User'; +import type { UserData } from '../../interfaces/User'; import { RoutePath } from '../../router/RoutePath'; import AuthLayout from '../auth/AuthLayout'; diff --git a/client/src/pages/marketplace/DatePicker.tsx b/client/src/pages/marketplace/DatePicker.tsx index 30c1523f..dd4fb3b0 100644 --- a/client/src/pages/marketplace/DatePicker.tsx +++ b/client/src/pages/marketplace/DatePicker.tsx @@ -1,4 +1,5 @@ -import { FC, useState } from 'react'; +import type { FC } from 'react'; +import { useState } from 'react'; import DatePicker from 'react-datepicker'; import 'react-datepicker/dist/react-datepicker.css'; diff --git a/client/src/pages/marketplace/Marketplace.tsx b/client/src/pages/marketplace/Marketplace.tsx index 07fca08e..07f8789b 100644 --- a/client/src/pages/marketplace/Marketplace.tsx +++ b/client/src/pages/marketplace/Marketplace.tsx @@ -1,5 +1,6 @@ -import { ChangeEvent, FC, MouseEvent, useEffect, useState } from 'react'; -import { Product } from '../../interfaces/Product'; +import type { ChangeEvent, FC, MouseEvent } from 'react'; +import { useEffect, useState } from 'react'; +import type { Product } from '../../interfaces/Product'; import { getProducts, getLatestProducts, diff --git a/client/src/pages/marketplace/Partners/Partners.tsx b/client/src/pages/marketplace/Partners/Partners.tsx index fb42081d..34a12502 100644 --- a/client/src/pages/marketplace/Partners/Partners.tsx +++ b/client/src/pages/marketplace/Partners/Partners.tsx @@ -1,4 +1,5 @@ -import { FC, useEffect, useState } from 'react'; +import type { FC } from 'react'; +import { useEffect, useState } from 'react'; import { DOMParser } from 'xmldom'; import OwlCarousel from 'react-owl-carousel'; @@ -6,7 +7,7 @@ import 'owl.carousel/dist/assets/owl.carousel.css'; import 'owl.carousel/dist/assets/owl.theme.default.css'; import { searchPartners, partnerLogin } from '../../../api/httpClient'; -import { Partner } from '../../../interfaces/Partner'; +import type { Partner } from '../../../interfaces/Partner'; export const Partners: FC = () => { const PARTNER_DEFAULT_USERNAME = 'walter100'; diff --git a/client/src/pages/marketplace/ProductView.tsx b/client/src/pages/marketplace/ProductView.tsx index 7c58eecf..78e7833e 100644 --- a/client/src/pages/marketplace/ProductView.tsx +++ b/client/src/pages/marketplace/ProductView.tsx @@ -1,5 +1,6 @@ -import { FC, useEffect } from 'react'; -import { Product } from '../../interfaces/Product'; +import type { FC } from 'react'; +import { useEffect } from 'react'; +import type { Product } from '../../interfaces/Product'; import { viewProduct } from '../../api/httpClient'; interface Props { diff --git a/client/src/pages/marketplace/Testimonials/Testimonials.tsx b/client/src/pages/marketplace/Testimonials/Testimonials.tsx index a1aff7ed..6ccc1f77 100644 --- a/client/src/pages/marketplace/Testimonials/Testimonials.tsx +++ b/client/src/pages/marketplace/Testimonials/Testimonials.tsx @@ -1,6 +1,7 @@ -import { FC, useEffect, useState } from 'react'; +import type { FC } from 'react'; +import { useEffect, useState } from 'react'; import { getTestimonials, getTestimonialsCount } from '../../../api/httpClient'; -import { Testimonial } from '../../../interfaces/Testimonial'; +import type { Testimonial } from '../../../interfaces/Testimonial'; import OwlCarousel from 'react-owl-carousel'; import 'owl.carousel/dist/assets/owl.carousel.css'; import 'owl.carousel/dist/assets/owl.theme.default.css'; diff --git a/client/src/pages/marketplace/Testimonials/TestimonialsForm.tsx b/client/src/pages/marketplace/Testimonials/TestimonialsForm.tsx index 7df2d86c..25c888c8 100644 --- a/client/src/pages/marketplace/Testimonials/TestimonialsForm.tsx +++ b/client/src/pages/marketplace/Testimonials/TestimonialsForm.tsx @@ -1,6 +1,7 @@ -import { Dispatch, FC, FormEvent, useState } from 'react'; +import type { Dispatch, FC, FormEvent } from 'react'; +import { useState } from 'react'; import { postTestimonials } from '../../../api/httpClient'; -import { Testimonial } from '../../../interfaces/Testimonial'; +import type { Testimonial } from '../../../interfaces/Testimonial'; const defaultTestimonial: Testimonial = { name: '', diff --git a/client/src/pages/marketplace/Testimonials/TestimonialsItems.tsx b/client/src/pages/marketplace/Testimonials/TestimonialsItems.tsx index a0bf3272..816da1d2 100644 --- a/client/src/pages/marketplace/Testimonials/TestimonialsItems.tsx +++ b/client/src/pages/marketplace/Testimonials/TestimonialsItems.tsx @@ -1,6 +1,6 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import InnerHTML from 'dangerously-set-html-content'; -import { Testimonial } from '../../../interfaces/Testimonial'; +import type { Testimonial } from '../../../interfaces/Testimonial'; interface Props { testimonials: Array; diff --git a/client/src/router/AppRoutes.tsx b/client/src/router/AppRoutes.tsx index 7423a40d..f25f5cd5 100644 --- a/client/src/router/AppRoutes.tsx +++ b/client/src/router/AppRoutes.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { Route, Routes, Navigate } from 'react-router-dom'; import { RoutePath } from './RoutePath'; import Main from '../pages/main/Main';