Skip to content

Commit d296d5c

Browse files
Genyusharish-janardhanan
authored andcommitted
fix(frontend): fix linter/typecheck warnings
1 parent 9c53ba4 commit d296d5c

34 files changed

+198
-312
lines changed

frontend/eslint.config.js

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1+
import { FlatCompat } from '@eslint/eslintrc';
12
import js from '@eslint/js';
3+
import tseslint from '@typescript-eslint/eslint-plugin';
4+
import parser from '@typescript-eslint/parser';
25
import react from 'eslint-plugin-react';
36
import reactHooks from 'eslint-plugin-react-hooks';
4-
import { FlatCompat } from '@eslint/eslintrc';
5-
import parser from '@typescript-eslint/parser';
6-
import tseslint from '@typescript-eslint/eslint-plugin';
77

88
const compat = new FlatCompat();
99

1010
export default [
11+
// Global ignores
12+
{
13+
ignores: [
14+
'node_modules/**',
15+
'dist/**',
16+
'build/**',
17+
'coverage/**',
18+
'*.config.js',
19+
'*.config.ts',
20+
'vite.config.ts',
21+
'tailwind.config.ts',
22+
'postcss.ts',
23+
],
24+
},
25+
// Base configuration
1126
js.configs.recommended,
1227
...compat.extends('plugin:react/recommended'),
1328
...compat.extends('plugin:@typescript-eslint/recommended'),
@@ -21,19 +36,58 @@ export default [
2136
sourceType: 'module',
2237
ecmaFeatures: { jsx: true },
2338
},
39+
globals: {
40+
// Browser globals
41+
window: 'readonly',
42+
document: 'readonly',
43+
console: 'readonly',
44+
setTimeout: 'readonly',
45+
clearTimeout: 'readonly',
46+
setInterval: 'readonly',
47+
clearInterval: 'readonly',
48+
localStorage: 'readonly',
49+
sessionStorage: 'readonly',
50+
fetch: 'readonly',
51+
// Node globals (for build tools)
52+
process: 'readonly',
53+
Buffer: 'readonly',
54+
__dirname: 'readonly',
55+
__filename: 'readonly',
56+
global: 'readonly',
57+
module: 'readonly',
58+
require: 'readonly',
59+
exports: 'readonly',
60+
},
2461
},
2562
plugins: {
2663
'@typescript-eslint': tseslint,
2764
react,
2865
'react-hooks': reactHooks,
2966
},
3067
rules: {
68+
// React rules
3169
'react/react-in-jsx-scope': 'off',
3270
'react/prop-types': 'off',
71+
'react/jsx-uses-react': 'off',
72+
'react/jsx-uses-vars': 'error',
73+
74+
// TypeScript rules
3375
'@typescript-eslint/no-unused-vars': 'warn',
3476
'@typescript-eslint/explicit-module-boundary-types': 'off',
77+
'@typescript-eslint/no-explicit-any': 'warn',
78+
'@typescript-eslint/no-unused-expressions': 'off', // Too strict for modern React
79+
'@typescript-eslint/no-non-null-assertion': 'warn',
80+
81+
// React Hooks rules
3582
'react-hooks/rules-of-hooks': 'error',
3683
'react-hooks/exhaustive-deps': 'warn',
84+
85+
// General rules
86+
'no-undef': 'off', // TypeScript handles this
87+
'no-unused-vars': 'off', // Use @typescript-eslint/no-unused-vars instead
88+
'no-prototype-builtins': 'warn',
89+
'prefer-const': 'warn',
90+
'no-var': 'error',
3791
},
3892
settings: {
3993
react: {

frontend/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
"ag-grid-react": "^33.3.2",
2222
"axios": "^1.9.0",
2323
"mobx": "^6.13.7",
24-
"mobx-react": "^9.2.0",
2524
"mobx-react-lite": "^4.1.0",
26-
"playwright": "^1.52.0",
2725
"react": "^19.1.0",
2826
"react-dom": "^19.1.0",
2927
"react-router-dom": "^7.6.2",
@@ -42,8 +40,6 @@
4240
"eslint": "^9.25.0",
4341
"eslint-plugin-react": "^7.37.5",
4442
"eslint-plugin-react-hooks": "^5.2.0",
45-
"eslint-plugin-react-refresh": "^0.4.19",
46-
"globals": "^16.0.0",
4743
"jsdom": "^26.1.0",
4844
"postcss": "^8.5.4",
4945
"tailwindcss": "^4.1.8",

frontend/pnpm-lock.yaml

Lines changed: 0 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/AppRouter.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
2-
import {BrowserRouter, Navigate, Route, Routes} from 'react-router-dom';
3-
import {observer} from 'mobx-react-lite';
4-
import SignIn from './pages/SignIn';
3+
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
4+
import Admin from "./pages/Admin";
55
import Main from './pages/Main';
6-
import userStore from './stores/userStore';
7-
import TraderSales from "./pages/TraderSales";
86
import MiddleOffice from "./pages/MiddleOffice";
7+
import SignIn from './pages/SignIn';
98
import Support from "./pages/Support";
10-
import Admin from "./pages/Admin";
9+
import TraderSales from "./pages/TraderSales";
1110
import PrivateRoute from "./PrivateRoute";
11+
import userStore from './stores/userStore';
1212

1313
const AppRouter = observer(() => (
1414

1515
<BrowserRouter>
1616
<Routes>
1717
<Route path="/signin" element={<SignIn/>}/>
1818
<Route path="/home" element={<PrivateRoute><Main/></PrivateRoute>}/>
19-
<Route path="/trade" element={<PrivateRoute> <TraderSales/> </PrivateRoute>}/>
19+
<Route path="/trade" element={<PrivateRoute><TraderSales/></PrivateRoute>}/>
2020
<Route path="/middle-office" element={<PrivateRoute><MiddleOffice/></PrivateRoute>}/>
2121
<Route path="/support" element={<PrivateRoute><Support/></PrivateRoute>}/>
2222
<Route path="/admin" element={<PrivateRoute><Admin/></PrivateRoute>}/>

frontend/src/components/FieldRenderer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React from "react";
2-
import Input from "./Input";
32
import Dropdown from "./Dropdown";
3+
import Input from "./Input";
44

55
/**
66
* Props for the FieldRenderer component
77
*/
8-
export interface FieldRendererProps {
8+
interface FieldRendererProps {
99
field: {
1010
key: string;
1111
label: string;
1212
type: string;
1313
options?: (() => { value: string; label: string }[] | string[]) | { value: string; label: string }[] | string[]
1414
};
15-
value: string | number | undefined | null;
15+
value: unknown | string | number | undefined | null;
1616
disabled: boolean;
1717
onChange: (e: React.ChangeEvent<HTMLInputElement> | string) => void;
1818
}

frontend/src/components/Navbar.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from 'react';
2-
import {useNavigate} from 'react-router-dom';
3-
//@ts-expect-error - Logo might not be found
4-
import logo from '../assets/trading-logo.svg'
5-
import Button from './Button';
2+
import { useNavigate } from 'react-router-dom';
3+
import logo from '../assets/trading-logo.svg';
64
import userStore from "../stores/userStore";
5+
import Button from './Button';
76

87
const navItems = [
98
{label: 'Home', aria: 'home', path: '/home', profile: ['default', 'TRADER_SALES', 'MO', 'SUPPORT', 'ADMIN', 'SUPER_USER']},

frontend/src/components/ProtectedRoute.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, {ReactNode} from 'react';
2-
import {Navigate} from 'react-router-dom';
1+
import React, { ReactNode } from 'react';
2+
import { Navigate } from 'react-router-dom';
33

44
interface ProtectedRouteProps {
55
isAllowed: boolean;
6-
redirectPath: string;
6+
redirectPath?: string;
77
children: ReactNode;
88
}
99

frontend/src/components/Sidebar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, {useState} from 'react';
2-
import {useLocation, useSearchParams} from 'react-router-dom';
1+
import React, { useState } from 'react';
2+
import { useLocation, useSearchParams } from 'react-router-dom';
33
import Button from './Button';
44

55
const navItems = [
@@ -14,7 +14,7 @@ const navItems = [
1414

1515
const Sidebar = () => {
1616
const [collapsed, setCollapsed] = useState(false);
17-
const [searchParams, setSearchParams] = useSearchParams();
17+
const [, setSearchParams] = useSearchParams();
1818

1919
const handleSideBarClick = (param: string) => {
2020
setSearchParams({view: param});

frontend/src/components/TradeDetails.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from "react";
2-
import Label from "./Label";
3-
import FieldRenderer from "./FieldRenderer";
2+
import { DISABLED_FIELDS, TRADE_FIELDS } from "../utils/tradeFormFields";
43
import { Trade } from "../utils/tradeTypes";
5-
import { TRADE_FIELDS, DISABLED_FIELDS } from "../utils/tradeFormFields";
4+
import FieldRenderer from "./FieldRenderer";
5+
import Label from "./Label";
66

77
/**
88
* Props for the TradeDetails component
99
*/
10-
export interface TradeDetailsProps {
10+
interface TradeDetailsProps {
1111
trade?: Trade;
1212
mode: "view" | "edit";
1313
onFieldChange?: (key: keyof Trade, value: unknown) => void;

0 commit comments

Comments
 (0)