diff --git a/apps/frontend/.eslintrc.cjs b/apps/frontend/.eslintrc.cjs new file mode 100644 index 0000000..5378294 --- /dev/null +++ b/apps/frontend/.eslintrc.cjs @@ -0,0 +1,29 @@ +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + project: 'tsconfig.json', + tsconfigRootDir: __dirname, + sourceType: 'module', + ecmaFeatures: { jsx: true }, + }, + plugins: ['@typescript-eslint/eslint-plugin', 'react', 'react-hooks'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:react/recommended', + 'plugin:react-hooks/recommended', + ], + root: true, + env: { + browser: true, + es2020: true, + }, + settings: { + react: { version: 'detect' }, + }, + ignorePatterns: ['.eslintrc.cjs', 'vite.config.ts', 'vitest.config.ts', 'dist/'], + rules: { + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/no-explicit-any': 'off', + 'react/react-in-jsx-scope': 'off', + }, +}; diff --git a/apps/frontend/package.json b/apps/frontend/package.json index 8654816..cb93512 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -8,6 +8,7 @@ "build": "tsc -b && vite build", "preview": "vite preview", "codegen": "openapi-typescript http://localhost:3000/api/docs-json -o src/api/types.ts", + "lint": "eslint \"src/**/*.{ts,tsx}\"", "test": "vitest run", "test:watch": "vitest" }, @@ -20,6 +21,11 @@ "react-router-dom": "^6.20.0" }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^7.0.0", + "@typescript-eslint/parser": "^7.0.0", + "eslint": "^8.0.0", + "eslint-plugin-react": "^7.34.0", + "eslint-plugin-react-hooks": "^4.6.0", "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^14.6.1", diff --git a/apps/frontend/src/hooks/useBond.test.tsx b/apps/frontend/src/hooks/useBond.test.tsx index 7e3c64e..4777e98 100644 --- a/apps/frontend/src/hooks/useBond.test.tsx +++ b/apps/frontend/src/hooks/useBond.test.tsx @@ -1,13 +1,9 @@ import { describe, it, expect } from 'vitest'; import { renderHook, waitFor } from '@testing-library/react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { http, HttpResponse } from 'msw'; -import { server } from '../test/server'; import { useBond } from './useBond'; import { type ReactNode } from 'react'; -const API = '/api/v1'; - function createWrapper() { const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } }); return function Wrapper({ children }: { children: ReactNode }) { diff --git a/apps/frontend/src/hooks/useStock.test.tsx b/apps/frontend/src/hooks/useStock.test.tsx index a84e6bf..2a127fe 100644 --- a/apps/frontend/src/hooks/useStock.test.tsx +++ b/apps/frontend/src/hooks/useStock.test.tsx @@ -1,13 +1,9 @@ import { describe, it, expect } from 'vitest'; import { renderHook, waitFor } from '@testing-library/react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { http, HttpResponse } from 'msw'; -import { server } from '../test/server'; import { useStock } from './useStock'; import { type ReactNode } from 'react'; -const API = '/api/v1'; - function createWrapper() { const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } }); return function Wrapper({ children }: { children: ReactNode }) { diff --git a/apps/frontend/src/pages/LoginPage.test.tsx b/apps/frontend/src/pages/LoginPage.test.tsx index 39a7334..2b1e9bb 100644 --- a/apps/frontend/src/pages/LoginPage.test.tsx +++ b/apps/frontend/src/pages/LoginPage.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { screen, waitFor } from '@testing-library/react'; +import { screen } from '@testing-library/react'; import { Routes, Route } from 'react-router-dom'; import userEvent from '@testing-library/user-event'; import { http, HttpResponse } from 'msw'; @@ -9,10 +9,6 @@ import { renderWithProviders } from '../test/test-utils'; const API = '/api/v1'; -async function waitForAuth() { - await screen.findByText('Войти'); -} - describe('LoginPage', () => { it('renders login form', async () => { server.use(http.post(`${API}/auth/refresh`, () => new HttpResponse(null, { status: 401 }))); diff --git a/apps/frontend/src/pages/ProfilePage.test.tsx b/apps/frontend/src/pages/ProfilePage.test.tsx index 27f5661..1575afc 100644 --- a/apps/frontend/src/pages/ProfilePage.test.tsx +++ b/apps/frontend/src/pages/ProfilePage.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { screen, waitFor } from '@testing-library/react'; +import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { http, HttpResponse } from 'msw'; import { server } from '../test/server'; diff --git a/apps/frontend/src/pages/RegisterPage.test.tsx b/apps/frontend/src/pages/RegisterPage.test.tsx index a7943f5..cc080b7 100644 --- a/apps/frontend/src/pages/RegisterPage.test.tsx +++ b/apps/frontend/src/pages/RegisterPage.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { screen, waitFor } from '@testing-library/react'; +import { screen } from '@testing-library/react'; import { Routes, Route } from 'react-router-dom'; import userEvent from '@testing-library/user-event'; import { http, HttpResponse } from 'msw';