diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index 31172b9c..913297c5 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -4,43 +4,77 @@ import pluginReact from "eslint-plugin-react" import pluginReactHooks from "eslint-plugin-react-hooks" import pluginPrettier from "eslint-plugin-prettier" import configPrettier from "eslint-config-prettier" -import { defineConfig } from "eslint/config" +import unusedImports from "eslint-plugin-unused-imports" -export default defineConfig([ +export default [ { ignores: ["**/*.min.js", "src/media/**/*"] }, + + // Base JS recommended rules + js.configs.recommended, + + // Your React/JSX files { - files: ["src/**/*.{js,jsx}"], - plugins: { js }, - extends: ["js/recommended"], - languageOptions: { globals: globals.browser } - }, - { - files: ["src/**/*.{js,jsx}"], - ...pluginReact.configs.flat.recommended, + files: ["src/**/*.{js,jsx,mjs,cjs}"], + languageOptions: { + ecmaVersion: "latest", + sourceType: "module", + parserOptions: { + ecmaFeatures: { jsx: true } + }, + globals: globals.browser + }, plugins: { + react: pluginReact, "react-hooks": pluginReactHooks, + "unused-imports": unusedImports, prettier: pluginPrettier }, settings: { - react: { - version: "detect" - } + react: { version: "detect" } }, rules: { + // React recommended rules (inline, since we're not "extending" in flat config) + ...pluginReact.configs.flat.recommended.rules, + + // If you want hooks rules, add these (recommended) + ...pluginReactHooks.configs.recommended.rules, + + // Prettier: disable conflicting stylistic rules + optionally enforce formatting ...configPrettier.rules, "prettier/prettier": "error", + + // Your overrides "react/react-in-jsx-scope": "off", "react-hooks/exhaustive-deps": "off", + "react/prop-types": "off", + "react-hooks/set-state-in-effect": "off", + "react/jsx-no-target-blank": "error", + "react/no-unescaped-entities": "off", + "react/display-name": "off", + "react-hooks/immutability": "off", + "react-hooks/preserve-manual-memoization": "off", "no-extra-boolean-cast": "off", "no-prototype-builtins": "off", - "no-unused-vars": "off", "no-empty": "off", "no-useless-escape": "off", - "no-undef": "off", + "no-undef": "error", "no-unsafe-optional-chaining": "off", - "no-constant-binary-expression": "off" + "no-constant-binary-expression": "off", + + // Unused cleanup + "no-unused-vars": "off", + "unused-imports/no-unused-imports": "error", + "unused-imports/no-unused-vars": [ + "warn", + { + vars: "all", + varsIgnorePattern: "^_", + args: "after-used", + argsIgnorePattern: "^_" + } + ] } } -]) +] diff --git a/frontend/package.json b/frontend/package.json index e1463232..071bc266 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -69,6 +69,7 @@ "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.4.3", + "eslint-plugin-unused-imports": "^4.3.0", "flow-bin": "^0.217.0", "flow-remove-types": "^2.217.1", "globals": "^16.5.0", diff --git a/frontend/src/components/ChatBubble/index.jsx b/frontend/src/components/ChatBubble/index.jsx index 7b37cd5d..3b33e8ff 100644 --- a/frontend/src/components/ChatBubble/index.jsx +++ b/frontend/src/components/ChatBubble/index.jsx @@ -4,7 +4,7 @@ import { userFromStorage } from "@/utils/request"; import renderMarkdown from "@/utils/chat/markdown"; import DOMPurify from "@/utils/chat/purify"; -export default function ChatBubble({ message, type, popMsg }) { +export default function ChatBubble({ message, type }) { const isUser = type === "user"; return ( diff --git a/frontend/src/components/DataConnectorOption/index.jsx b/frontend/src/components/DataConnectorOption/index.jsx deleted file mode 100644 index 038624ac..00000000 --- a/frontend/src/components/DataConnectorOption/index.jsx +++ /dev/null @@ -1,25 +0,0 @@ -export default function DataConnectorOption({ slug }) { - if (!DATA_CONNECTORS.hasOwnProperty(slug)) return null; - const { path, image, name, description, link } = DATA_CONNECTORS[slug]; - - return ( - - - {link} - - - - ); -} diff --git a/frontend/src/components/LLMSelection/DPAISOptions/index.jsx b/frontend/src/components/LLMSelection/DPAISOptions/index.jsx index 78f09532..af837567 100644 --- a/frontend/src/components/LLMSelection/DPAISOptions/index.jsx +++ b/frontend/src/components/LLMSelection/DPAISOptions/index.jsx @@ -5,10 +5,7 @@ import PreLoader from "@/components/Preloader"; import { DPAIS_COMMON_URLS } from "@/utils/constants"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; -export default function DellProAIStudioOptions({ - settings, - showAlert = false, -}) { +export default function DellProAIStudioOptions({ settings }) { const { autoDetecting: loading, basePath, diff --git a/frontend/src/components/LLMSelection/NvidiaNimOptions/managed.jsx b/frontend/src/components/LLMSelection/NvidiaNimOptions/managed.jsx index 0dce898a..9efc7eae 100644 --- a/frontend/src/components/LLMSelection/NvidiaNimOptions/managed.jsx +++ b/frontend/src/components/LLMSelection/NvidiaNimOptions/managed.jsx @@ -2,6 +2,6 @@ * This component is used to select, start, and manage NVIDIA NIM * containers and images via docker management tools. */ -export default function ManagedNvidiaNimOptions({ settings }) { +export default function ManagedNvidiaNimOptions({ settings: _settings }) { return null; } diff --git a/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx b/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx index a141635d..0c9f7bb5 100644 --- a/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx +++ b/frontend/src/components/Modals/ManageWorkspace/Documents/WorkspaceDirectory/WorkspaceFileRow/index.jsx @@ -256,7 +256,7 @@ const WatchForChanges = memo(({ workspace, docPath, item }) => { ); }); -const RemoveItemFromWorkspace = ({ item, onClick }) => { +const RemoveItemFromWorkspace = ({ item: _item, onClick }) => { return (
" ); - } catch (__) {} + } catch {} } return ( diff --git a/frontend/src/utils/chat/plugins/markdown-katex.js b/frontend/src/utils/chat/plugins/markdown-katex.js index 76fb940a..cb7a9ae3 100644 --- a/frontend/src/utils/chat/plugins/markdown-katex.js +++ b/frontend/src/utils/chat/plugins/markdown-katex.js @@ -33,7 +33,7 @@ function isValidDelim(state, pos) { } function math_inline(state, silent) { - var start, match, token, res, pos, esc_count; + var start, match, token, res, pos; // Only process $ and \( delimiters for inline math if ( diff --git a/frontend/src/utils/directories.js b/frontend/src/utils/directories.js index bae00594..6391eb1e 100644 --- a/frontend/src/utils/directories.js +++ b/frontend/src/utils/directories.js @@ -13,7 +13,7 @@ export function formatDateTimeAsMoment(dateString, format = "LLL") { if (!dateString) return moment().format(format); try { return moment(dateString).format(format); - } catch (error) { + } catch { return moment().format(format); } } diff --git a/frontend/yarn.lock b/frontend/yarn.lock index a8e4c2d1..b932057b 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2346,6 +2346,11 @@ eslint-plugin-react@^7.37.5: string.prototype.matchall "^4.0.12" string.prototype.repeat "^1.0.0" +eslint-plugin-unused-imports@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.3.0.tgz#69ff9c4f83f02f7789808bbbab77636cb742af50" + integrity sha512-ZFBmXMGBYfHttdRtOG9nFFpmUvMtbHSjsKrS20vdWdbfiVYsO3yA2SGYy9i9XmZJDfMGBflZGBCm70SEnFQtOA== + eslint-scope@^8.4.0: version "8.4.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.4.0.tgz#88e646a207fad61436ffa39eb505147200655c82"