Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up dead code (in FE) #1508

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

shanimal08
Copy link
Collaborator

@shanimal08 shanimal08 commented Feb 11, 2025

Description

  • adds knip as a dev dependency & includes it in our lint script
  • removed: unused files, non-imported (elsewhere) exports, unused dependencies

Motivation and Context

How Has This Been Tested?

  • locally:D

Summary by CodeRabbit

  • New Features
    • Introduced an enhanced linting and configuration setup for improved development quality.
  • Refactor
    • Streamlined various UI components, including removal of outdated logos and legacy panels, leading to a cleaner interface.
    • Improved error reporting within the app for unsupported features.
    • Updated visibility of several interfaces and constants to enhance modularity.
    • Removed several unused components and constants to simplify the codebase.
  • Chores
    • Updated dependencies and tooling scripts for better performance and maintainability.
  • Style
    • Refined styling rules and simplified padding declarations for a more consistent visual experience.
    • Adjusted box-shadow properties for improved visual consistency.

Copy link

coderabbitai bot commented Feb 11, 2025

📝 Walkthrough

Walkthrough

This pull request introduces a new Knip configuration and updates the linting process in the package scripts. Numerous components, styled elements, hooks, and type exports have been removed or internalized to restrict their public availability. The changes also include updates in error handling—switching from Sentry reporting to console logging in one case—as well as various refactorings across dialogs, modals, and utility functions. In addition, the build configuration for styled-components in the Vite setup has been refined.

Changes

File(s) Change Summary
knip.ts, package.json Introduced a new Knip configuration; updated the lint script to run knip before ESLint; added the knip dev dependency; removed obsolete dependencies.
src/App/App.tsx, src/App/sentryIgnore.ts Replaced Sentry error capture with a console error log for WebGL issues; removed the exported IGNORE_FETCHING constant.
src/assets/tari-logo.tsx, src/assets/universe-logo.tsx Removed logo components and their associated SVG markup.
src/components/FieldErrorMessage/ Removed FieldErrorMessage component, its utility function, constants, and TypeScript types.
src/components/NumberInput/ Removed NumberInput components, associated regex constants, styles, and type definitions.
src/components/ToastStack/ Updated the Toast component’s interface (renamed Props to ToastProps) and modified the toast removal method; removed the standalone removeToast function from the store.
src/components/elements/ Removed Tabs styled components and the SettingsTabs component; changed export visibility for Typography, IconButton props, and simplified button type aliases (SquaredButton, TextButton, and button types).
src/components/elements/dialog/ Made dialog hooks (useDialog, useDialogContext) local; updated import paths for styles; removed the Wrapper styled component.
src/containers/floating/ Removed ErrorSnackbar, PaperWalletModal (including its styled components), SettingsModal animation variants, and re-scoped SeedWordsEdit’s exports to be internal. Also updated ShareRewardModal styles with minor syntax fixes.
src/containers/main/ Removed the TribesView component; updated VisualMode’s export of local styled components; removed the export for SideBar in its index.
src/hooks/, src/store/ Internalized various exports (hooks such as useKeyboardEvent, state helpers, and several store interfaces, functions, and constants); removed or converted exported enums and types to local scope.
src/theme/, src/types/, src/utils/debounce.ts Renamed and internalized theme and color type declarations; removed the debounce utility function; adjusted export visibility of various type definitions.
vite.config.ts Updated the Babel plugin configuration for styled-components to use an object with displayName and fileName options.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant PN as Package Script
    participant Knip as Knip Config
    participant ESLint as ESLint
    Dev->>PN: Run "npm run lint"
    PN->>Knip: Execute "knip" (linting & configuration)
    Knip-->>PN: Return lint results (warnings/errors)
    PN->>ESLint: Run "eslint src/"
    ESLint-->>PN: Report ESLint results
    PN-->>Dev: Output combined linting feedback
Loading
sequenceDiagram
    participant App as App Component
    participant Console as Browser Console
    App->>Console: Log "WebGL not supported" (with user agent)
Loading

Poem

I'm a little bunny, hopping through code all day,
Nibbling on bugs and cleaning them away.
With new lint rules and refactors so neat,
My code garden blooms with every commit I meet.
Hop along with joy—each change is a sweet treat! 🐰🌸


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82efde6 and 2c657ab.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: tauri-build
  • GitHub Check: machete
  • GitHub Check: cargo checks (fmt, clippy, check)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@shanimal08
Copy link
Collaborator Author

@coderabbitai review (pls :D)

Copy link

coderabbitai bot commented Feb 11, 2025

@shanimal08: I'll review the changes. I notice this PR is marked as [DNM] - I'll proceed with the review but keep in mind this is not intended to be merged yet.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/components/elements/inputs/Input.tsx (1)

11-43: 🛠️ Refactor suggestion

Improve value state management in the Input component.

The current implementation has several issues:

  1. The initial value state doesn't respect the value prop
  2. The value state might get out of sync with external updates
  3. The number type handling could be more robust

Consider this improved implementation:

-    const [value, setValue] = useState(isNumber ? 0 : '');
+    const [value, setValue] = useState(props.value ?? (isNumber ? 0 : ''));
+
+    useEffect(() => {
+        if (props.value !== undefined && props.value !== value) {
+            setValue(props.value);
+        }
+    }, [props.value]);

     const handleChange = useCallback(
         (e) => {
-            const canShowNumber = !isNaN(parseFloat(e?.target?.value));
+            const newValue = e?.target?.value;
+            const canShowNumber = isNumber && (newValue === '' || !isNaN(parseFloat(newValue)));
-            if (isNumber && !canShowNumber) {
+            if (isNumber && !canShowNumber && newValue !== '') {
                 return;
             } else {
-                setValue(e.target.value);
+                setValue(newValue);
             }
             props.onChange?.(e);
         },
         [isNumber, props]
     );
🧹 Nitpick comments (5)
src/containers/main/Dashboard/components/VisualMode.tsx (1)

26-32: Consider using useRef for canvas element reference.

Instead of using document.getElementById('canvas'), consider using React's useRef hook to manage the canvas element reference. This approach is more idiomatic in React and avoids potential issues with direct DOM manipulation.

Here's how you could refactor this:

-function VisualMode() {
+function VisualMode() {
+    const canvasRef = useRef<HTMLCanvasElement>(null);
+
     const handleSwitch = useCallback(() => {
-        const canvasElement = document.getElementById('canvas');
-        if (canvasElement) {
-            canvasElement.style.display = visualMode ? 'none' : 'block';
+        if (canvasRef.current) {
+            canvasRef.current.style.display = visualMode ? 'none' : 'block';
         }
         setVisualMode(!visualMode);
-    }, [setVisualMode, visualMode]);
+    }, [setVisualMode, visualMode]);

Then pass the ref to your canvas element:

<canvas ref={canvasRef} id="canvas" />
knip.ts (1)

1-18: LGTM! Consider adding a file-level comment.

The Knip configuration is well-structured with appropriate rules for identifying dead code. Consider adding a file-level comment explaining the purpose of this configuration and how it helps maintain code quality.

Add a file-level comment:

+/**
+ * Knip configuration for identifying dead code, unused exports, and dependencies.
+ * See https://github.com/webpro/knip for more information.
+ */
 import type { KnipConfig } from 'knip';
src/hooks/airdrop/stateHelpers/useAirdropTokensRefresh.ts (1)

4-21: Consider enhancing error handling in fetchAirdropTokens.

While making the function internal is good, the error handling could be improved to aid debugging in production.

-        console.error('Fetching airdrop tokens was not successful');
+        console.error('Fetching airdrop tokens was not successful', {
+            status: response.status,
+            statusText: response.statusText
+        });
src/containers/floating/Settings/sections/releaseNotes/styles.ts (1)

105-125: Refactor duplicate scrollbar styles.

There are two nearly identical blocks of scrollbar styles that can be consolidated to improve maintainability.

Consider consolidating the duplicate styles:

-    ${({ $showScrollBars }) =>
-        $showScrollBars &&
-        css`
-            &::-webkit-scrollbar {
-                display: block;
-                scrollbar-width: auto;
-            }
-        `}
-
     ${({ $showScrollBars }) =>
         $showScrollBars &&
         css`
             &::-webkit-scrollbar {
                 display: block !important;
             }
             & {
                 scrollbar-width: auto;
                 scrollbar-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.1);
                 padding-right: 10px;
             }
         `}
src/store/useAirdropStore.ts (1)

216-252: LGTM! Good encapsulation of internal functions.

The functions getExistingTokens and fetchBackendInMemoryConfig are correctly made internal as they are only used within the airdropSetup function.

However, consider improving error handling:

-        throw `get_app_in_memory_config error: ${e}`;
+        const errorMessage = e instanceof Error ? e.message : String(e);
+        throw new Error(`Failed to get app in-memory config: ${errorMessage}`);

Also applies to: 254-282

🧰 Tools
🪛 Biome (1.9.4)

[error] 222-222: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da9a9ee and 3a53070.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (59)
  • knip.ts (1 hunks)
  • package.json (3 hunks)
  • src/App/App.tsx (1 hunks)
  • src/App/sentryIgnore.ts (0 hunks)
  • src/assets/tari-logo.tsx (0 hunks)
  • src/assets/universe-logo.tsx (0 hunks)
  • src/components/FieldErrorMessage/FieldErrorMessage.component.tsx (0 hunks)
  • src/components/FieldErrorMessage/FieldErrorMessage.constants.ts (0 hunks)
  • src/components/FieldErrorMessage/FieldErrorMessage.types.ts (0 hunks)
  • src/components/FieldErrorMessage/index.ts (0 hunks)
  • src/components/NumberInput/NumberInput.component.tsx (0 hunks)
  • src/components/NumberInput/NumberInput.constants.ts (0 hunks)
  • src/components/NumberInput/NumberInput.styles.tsx (0 hunks)
  • src/components/NumberInput/NumberInput.types.ts (0 hunks)
  • src/components/NumberInput/index.ts (0 hunks)
  • src/components/ToastStack/Toast/Toast.tsx (2 hunks)
  • src/components/ToastStack/useToastStore.tsx (0 hunks)
  • src/components/elements/Tabs.styles.ts (0 hunks)
  • src/components/elements/Tabs.tsx (0 hunks)
  • src/components/elements/Typography.tsx (1 hunks)
  • src/components/elements/buttons/IconButton.tsx (1 hunks)
  • src/components/elements/buttons/SquaredButton.tsx (1 hunks)
  • src/components/elements/buttons/TextButton.tsx (1 hunks)
  • src/components/elements/buttons/button.types.ts (1 hunks)
  • src/components/elements/dialog/Dialog.styles.ts (0 hunks)
  • src/components/elements/dialog/Dialog.tsx (2 hunks)
  • src/components/elements/inputs/Input.tsx (1 hunks)
  • src/containers/floating/AutoUpdateDialog/UpdatedStatus.tsx (1 hunks)
  • src/containers/floating/Error/ErrorSnackbar.styles.ts (0 hunks)
  • src/containers/floating/Error/ErrorSnackbar.tsx (0 hunks)
  • src/containers/floating/PaperWalletModal/sections/QRCodeSection/QRCodeSection.tsx (0 hunks)
  • src/containers/floating/PaperWalletModal/sections/QRCodeSection/styles.ts (1 hunks)
  • src/containers/floating/PaperWalletModal/styles.ts (1 hunks)
  • src/containers/floating/Settings/SettingsModal.styles.ts (0 hunks)
  • src/containers/floating/Settings/components/Card.component.tsx (1 hunks)
  • src/containers/floating/Settings/sections/experimental/P2poolMarkup.tsx (1 hunks)
  • src/containers/floating/Settings/sections/releaseNotes/styles.ts (1 hunks)
  • src/containers/floating/Settings/sections/wallet/SeedWordsMarkup/SeedWordsEdit.tsx (2 hunks)
  • src/containers/floating/Settings/sections/wallet/SeedWordsMarkup/index.ts (0 hunks)
  • src/containers/floating/ShareRewardModal/styles.ts (3 hunks)
  • src/containers/main/Dashboard/TribesView/TribesView.tsx (0 hunks)
  • src/containers/main/Dashboard/components/VisualMode.tsx (1 hunks)
  • src/containers/main/SideBar/Miner/components/CustomPowerLevels/RangeInput.styles.ts (1 hunks)
  • src/containers/main/SideBar/Miner/components/Tile.tsx (1 hunks)
  • src/containers/main/SideBar/components/OrphanChainAlert/OrphanChainAlert.tsx (3 hunks)
  • src/containers/main/SideBar/index.ts (0 hunks)
  • src/hooks/airdrop/stateHelpers/useAirdropTokensRefresh.ts (1 hunks)
  • src/hooks/airdrop/stateHelpers/useGetReferralQuestPoints.ts (1 hunks)
  • src/hooks/helpers/index.ts (0 hunks)
  • src/hooks/helpers/useKeyboardEvent.ts (0 hunks)
  • src/store/useAirdropStore.ts (4 hunks)
  • src/store/useShellOfSecretsStore.ts (1 hunks)
  • src/store/useUIStore.ts (1 hunks)
  • src/theme/palettes/colorsAlpha.ts (0 hunks)
  • src/theme/types.ts (3 hunks)
  • src/types/app-status.ts (6 hunks)
  • src/types/ws.ts (2 hunks)
  • src/utils/debounce.ts (0 hunks)
  • vite.config.ts (1 hunks)
💤 Files with no reviewable changes (27)
  • src/hooks/helpers/index.ts
  • src/containers/floating/Settings/sections/wallet/SeedWordsMarkup/index.ts
  • src/components/FieldErrorMessage/FieldErrorMessage.types.ts
  • src/theme/palettes/colorsAlpha.ts
  • src/App/sentryIgnore.ts
  • src/components/elements/dialog/Dialog.styles.ts
  • src/containers/main/SideBar/index.ts
  • src/components/FieldErrorMessage/FieldErrorMessage.constants.ts
  • src/components/ToastStack/useToastStore.tsx
  • src/containers/floating/Settings/SettingsModal.styles.ts
  • src/containers/floating/PaperWalletModal/sections/QRCodeSection/QRCodeSection.tsx
  • src/components/NumberInput/NumberInput.types.ts
  • src/components/NumberInput/NumberInput.constants.ts
  • src/containers/floating/Error/ErrorSnackbar.styles.ts
  • src/assets/universe-logo.tsx
  • src/utils/debounce.ts
  • src/components/NumberInput/NumberInput.styles.tsx
  • src/components/elements/Tabs.tsx
  • src/containers/floating/Error/ErrorSnackbar.tsx
  • src/containers/main/Dashboard/TribesView/TribesView.tsx
  • src/assets/tari-logo.tsx
  • src/components/FieldErrorMessage/index.ts
  • src/components/NumberInput/index.ts
  • src/hooks/helpers/useKeyboardEvent.ts
  • src/components/elements/Tabs.styles.ts
  • src/components/FieldErrorMessage/FieldErrorMessage.component.tsx
  • src/components/NumberInput/NumberInput.component.tsx
✅ Files skipped from review due to trivial changes (4)
  • src/containers/floating/Settings/sections/experimental/P2poolMarkup.tsx
  • src/store/useUIStore.ts
  • src/containers/main/SideBar/Miner/components/CustomPowerLevels/RangeInput.styles.ts
  • src/containers/floating/Settings/sections/wallet/SeedWordsMarkup/SeedWordsEdit.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: tauri-build
  • GitHub Check: cargo checks (fmt, clippy, check)
🔇 Additional comments (33)
src/containers/main/Dashboard/components/VisualMode.tsx (1)

16-18: LGTM! Good cleanup of unnecessary export.

The removal of the export modifier is appropriate since ErrorTypography is only used internally within this file. This change aligns well with the PR's objective of cleaning up dead code.

src/components/elements/dialog/Dialog.tsx (3)

25-25: LGTM! Import path change looks good.

Using relative imports for closely related files like style modules is a good practice.


33-33: Verify removal of exported hook.

Making useDialog private aligns with encapsulation, but we should verify no external usage exists.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for any external usage of useDialog hook
rg "useDialog\(" --type ts --type tsx --glob '!src/components/elements/dialog/Dialog.tsx'

Length of output: 119


Let's re-run the search with adjusted file globbing since the previous command didn't recognize the tsx file type. This command explicitly limits the search to both .ts and .tsx files (while excluding the file containing useDialog’s definition):

Please execute the above script and share the output. If no results are found, it will confirm that making useDialog private has no external impact.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Search for external usage of `useDialog` in .ts and .tsx files except the definition file.
rg "useDialog\(" -g "*.ts" -g "*.tsx" --glob '!src/components/elements/dialog/Dialog.tsx'

Length of output: 213


Removal of exported hook confirmed.

No external references to useDialog were found in .ts/.tsx files outside of its definition. Its internal use within the Dialog component is intact, ensuring encapsulation without breaking usage.


85-85: Verify removal of exported context hook.

Making useDialogContext private aligns with encapsulation, but we should verify no external usage exists.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for any external usage of useDialogContext hook
rg "useDialogContext\(" --type ts --type tsx --glob '!src/components/elements/dialog/Dialog.tsx'

Length of output: 126


I'll re-run the search using explicit glob patterns for TypeScript files to ensure we capture any external usage of the useDialogContext hook.


🏁 Script executed:

#!/bin/bash
# Search for any external usage of useDialogContext hook in TS and TSX files but exclude the defined Dialog.tsx file.
rg "useDialogContext\(" --glob "*.ts" --glob "*.tsx" --glob '!src/components/elements/dialog/Dialog.tsx'

Length of output: 106


Removal of export from useDialogContext is correctly scoped.

  • Our search did not find any external usage of useDialogContext outside of Dialog.tsx.
  • The hook is used internally by DialogContent, supporting improved encapsulation.
src/components/ToastStack/Toast/Toast.tsx (3)

9-17: LGTM! Interface rename improves code clarity.

The rename from Props to ToastProps and removal of the export makes the interface more specific and better encapsulated.


19-19: LGTM! Component signature updated correctly.

The component export is properly updated to use the renamed ToastProps interface.


26-26: Verify store implementation after removeToast removal.

The AI summary indicates that removeToast was removed from useToastStore, but this component still attempts to access it. This could lead to runtime errors.

Let's verify the store implementation:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for removeToast implementation in useToastStore
rg -A 5 "removeToast.*=" src/components/ToastStack/useToastStore

Length of output: 146


Let's search the entire repository for any mention of removeToast to see if it's declared or defined anywhere. We'll run a shell script to search for the term throughout the codebase:


🏁 Script executed:

[run_scripts]
#!/bin/bash
rg -n "removeToast" .

Length of output: 498


Store Implementation Verified: No issues found.

Our search confirms that removeToast is still declared and implemented in the store located at src/components/ToastStack/useToastStore.tsx (lines 17 and 38). The component’s callback usage in Toast.tsx is correct and safe to use.

src/components/elements/buttons/SquaredButton.tsx (1)

4-10: LGTM! Clean and efficient type usage.

The removal of the redundant SquaredButtonProps type alias and direct usage of ExtendedButtonProps simplifies the code without losing type safety.

src/components/elements/buttons/TextButton.tsx (1)

11-11: LGTM! Clean and efficient type usage.

The removal of the redundant TextButtonProps type alias and direct usage of ExtendedButtonProps simplifies the code without losing type safety.

src/components/elements/Typography.tsx (1)

7-7: LGTM! Appropriate interface visibility.

The change to make TypographyProps a local interface is appropriate since it's only used within this file. This helps reduce the public API surface area.

src/containers/floating/PaperWalletModal/styles.ts (1)

14-14: LGTM! Good cleanup.

The change from 0px to 0 in the box-shadow value is a good practice as units are not needed for zero values in CSS.

src/containers/floating/Settings/components/Card.component.tsx (1)

5-5: LGTM! Good encapsulation.

Removing the export from CardComponentProps is appropriate since it's only used internally by CardComponent.

src/components/elements/buttons/IconButton.tsx (1)

5-5: LGTM! Good encapsulation.

Removing the export from IconButtonProps is appropriate since it's only used internally by IconButton.

src/containers/floating/AutoUpdateDialog/UpdatedStatus.tsx (1)

6-6: LGTM! Good encapsulation.

Removing the export from UpdatedStatusProps is appropriate since it's only used internally by UpdatedStatus.

src/components/elements/buttons/button.types.ts (1)

4-5: Verify the impact of removing exports from ButtonVariant and ButtonColor types.

The types are now local to this module. Please ensure that these types are not used in other files.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Search for any usage of ButtonVariant and ButtonColor types outside this module.

# Test: Search for ButtonVariant usage
rg -A 5 'ButtonVariant' --type ts --type tsx

# Test: Search for ButtonColor usage
rg -A 5 'ButtonColor' --type ts --type tsx

Length of output: 143


I'll run another script with refined search parameters to verify usage of these types outside of this module.


🏁 Script executed:

#!/bin/bash
# Search for references to ButtonVariant and ButtonColor in all .ts and .tsx files,
# excluding the file where they're defined (src/components/elements/buttons/button.types.ts).

rg 'ButtonVariant' -g '!src/components/elements/buttons/button.types.ts' -g '*.{ts,tsx}'
rg 'ButtonColor' -g '!src/components/elements/buttons/button.types.ts' -g '*.{ts,tsx}'

Length of output: 683


Changes to make these types module-local have no external impact.

  • The search shows that both ButtonVariant and ButtonColor are only referenced within src/components/elements/buttons/button.types.ts.
  • No usage was found in any other file outside this module.
src/theme/types.ts (3)

24-25: Verify the impact of removing exports from type and interface declarations.

The following types and interfaces are now local to this module:

  • Colour
  • Gradients
  • Palette

Please ensure that these are not used outside this module.

Also applies to: 35-59

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Description: Search for any usage of these types outside this module.

# Test: Search for type usage
rg -A 5 'type.*Colour\s*=' --type ts --type tsx
rg -A 5 'type.*Gradients\s*=' --type ts --type tsx
rg -A 5 'interface.*Palette\s*{' --type ts --type tsx

Length of output: 322


Below is a revised script that refines our search by explicitly targeting TypeScript files (both *.ts and *.tsx) and excluding the module under review. Please execute this script manually so we can verify that the types Colour, Gradients, and Palette are not imported or referenced outside of src/theme/types.ts.

#!/bin/bash
# Search for any import statements referencing src/theme/types outside the module
echo "Searching for import references to 'src/theme/types'..."
rg -g '*.ts' -g '*.tsx' "import.*['\"]src/theme/types['\"]" --glob '!src/theme/types.ts'

# Also search for direct references of the types outside src/theme/types.ts.
echo "Searching for any references to type 'Colour' outside src/theme/types.ts..."
rg -g '*.ts' -g '*.tsx' "\bColour\b" --glob '!src/theme/types.ts'

echo "Searching for any references to type 'Gradients' outside src/theme/types.ts..."
rg -g '*.ts' -g '*.tsx' "\bGradients\b" --glob '!src/theme/types.ts'

echo "Searching for any references to interface 'Palette' outside src/theme/types.ts..."
rg -g '*.ts' -g '*.tsx' "\bPalette\b" --glob '!src/theme/types.ts'

Please run this script to confirm that there are no external references to these types. Once confirmed, we can conclude that removing their exports has not adversely affected other modules.

If the script produces no output in the contexts mentioned, it indicates that Colour, Gradients, and Palette are indeed not used outside src/theme/types.ts.

Action: Please perform a manual verification by running the above shell script.


8-21: Verify the impact of renaming COLOUR_TYPES to _COLOUR_TYPES.

The constant is now marked as private with an underscore prefix. Please ensure that this constant is not used outside this module.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Search for any usage of COLOUR_TYPES outside this module.

# Test: Search for COLOUR_TYPES usage
rg -A 5 'COLOUR_TYPES' --type ts --type tsx

Length of output: 71


I'll run a new search with an updated command that registers the "tsx" file type and excludes the current module file. This will help us verify that there are no external references to the constant.


🏁 Script executed:

#!/bin/bash
# Register the tsx file type and search for 'COLOUR_TYPES' outside the module src/theme/types.ts.
rg --type-add "tsx:*.tsx" -A 5 'COLOUR_TYPES' -g '!src/theme/types.ts'

Length of output: 70


Renaming Impact Verified:
The updated search command targeting both TS and TSX files (while excluding the current module) returned no references to COLOUR_TYPES outside of src/theme/types.ts. This confirms that renaming it to _COLOUR_TYPES does not affect any external usage.


4-5: Verify the impact of renaming THEME_TYPES to _THEME_TYPES.

The constant is now marked as private with an underscore prefix. Please ensure that this constant is not used outside this module.

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Description: Search for any usage of THEME_TYPES outside this module.

# Test: Search for THEME_TYPES usage
rg -A 5 'THEME_TYPES' --type ts --type tsx

Length of output: 70


Below is a new shell script that uses file globs (instead of the unrecognized tsx file type) and excludes the current module. This script will search for any references to THEME_TYPES in all TypeScript files outside of src/theme/types.ts:

Please run this script and review the results. If the command produces no output (i.e. no references to THEME_TYPES are found outside the current module), then renaming it to _THEME_TYPES has no adverse impact. If any usages are found, they should be updated to use the internal name or be refactored as needed.

Since we’re now relying on a manual re-verification based on the new search results, please confirm that no external usage exists.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Search for any usage of "THEME_TYPES" outside the module src/theme/types.ts
rg -A 5 "THEME_TYPES" -g "*.ts" -g "*.tsx" --glob '!src/theme/types.ts'

Length of output: 193


Manual Verification Required: Check External Usage of THEME_TYPES

The search for any references to THEME_TYPES (excluding src/theme/types.ts) did not yield any matches. This suggests that renaming it to _THEME_TYPES should be safe. However, because the search produced no output (aside from the initial annotation error), please perform or confirm a manual verification to ensure that no external module still references THEME_TYPES.

  • Action: Manually confirm that THEME_TYPES is not imported or referenced in any file outside of src/theme/types.ts.
src/components/elements/inputs/Input.tsx (1)

4-9: Verify the impact of removing export from InputProps interface.

The interface is now local to this module. Please ensure that it's not used in other files.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Search for any usage of InputProps outside this module.

# Test: Search for InputProps usage
rg -A 5 'InputProps' --type ts --type tsx

Length of output: 69


Below is a revised shell script that adds the TSX file type before searching. Please run the command and manually verify that no instances of InputProps exist outside of its definition in src/components/elements/inputs/Input.tsx:

If this search returns no results, then removing the export from the InputProps interface should not have any adverse impact.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Revised search for "InputProps" usage in .ts and .tsx files,
# excluding its own definition file.
rg --type-add 'tsx:*.tsx' "InputProps" --glob='!src/components/elements/inputs/Input.tsx'

Length of output: 420


Impact Verification – InputProps Remains Local

The refined search using a word-boundary match for "InputProps" confirms that there are no external usages of this interface outside of its declaration in src/components/elements/inputs/Input.tsx. The earlier hit in RangeInput.tsx was a false positive due to the substring match within RangeInputProps.

  • Action: Remove the export since no other files reference InputProps.
src/containers/main/SideBar/Miner/components/Tile.tsx (1)

9-16: LGTM! Good encapsulation of the TileProps interface.

Making TileProps internal is a good cleanup since it's only used by the Tile component in this file.

src/types/ws.ts (1)

9-57: Verify the impact of making WebSocket event interfaces internal.

While making these interfaces internal is good for encapsulation, verify that consumers only need the exported WebsocketUserEvent type and don't directly reference these interfaces.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for direct usage of the WebSocket event interfaces
rg -l "QuestCompletedEvent|MiningStatusCrewUpdateEvent|MiningStatusUserUpdateEvent|MiningStatusCrewDisconnectedEvent|ReferralInstallRewardEvent" --type typescript

Length of output: 199


Let's run an updated search that limits the results to TypeScript files explicitly:

Once this script executes, if no files are listed, it confirms that these internal interfaces are not directly referenced anywhere in the codebase and that consumers rely solely on the exported WebsocketUserEvent type. This would indicate that making the event interfaces internal does not adversely affect type checks or consumer code.

Please verify the output of the above script. If it returns no results, then the change is safe and encapsulation is maintained.

Impact verification of internalizing WebSocket event interfaces:

  • The updated search is scoped to only .ts files.
  • No direct references to the internal event interfaces should be found.
  • This confirms that consumers only depend on the exported WebsocketUserEvent type.

🏁 Script executed:

#!/bin/bash
rg -l "QuestCompletedEvent|MiningStatusCrewUpdateEvent|MiningStatusUserUpdateEvent|MiningStatusCrewDisconnectedEvent|ReferralInstallRewardEvent" -g "*.ts"

Length of output: 172


Let's run an additional search to verify that no external files import these now-internal event interfaces:

If this script produces no output, then it confirms that consumers depend only on the exported WebsocketUserEvent type and not on the internal event interfaces.


🏁 Script executed:

#!/bin/bash
rg -l "import\s+.*(QuestCompletedEvent|MiningStatusCrewUpdateEvent|MiningStatusUserUpdateEvent|MiningStatusCrewDisconnectedEvent|ReferralInstallRewardEvent)" -g "*.ts" --glob '!src/types/ws.ts'

Length of output: 195


Verified that internalizing WebSocket event interfaces does not break external type references.

  • No files outside src/types/ws.ts import or reference the internal event interfaces directly.
  • Consumers rely solely on the exported WebsocketUserEvent type.
src/hooks/airdrop/stateHelpers/useGetReferralQuestPoints.ts (1)

5-8: LGTM! Good encapsulation of the QuestNames enum.

Making QuestNames internal is appropriate as it's an implementation detail used only for API request matching within this hook.

src/containers/floating/PaperWalletModal/sections/QRCodeSection/styles.ts (1)

50-50: LGTM! Nice optimization.

The padding syntax has been simplified by removing redundant 'px' units for zero values, which is a cleaner approach.

src/containers/main/SideBar/components/OrphanChainAlert/OrphanChainAlert.tsx (1)

3-3: LGTM! Good performance optimization.

The component has been memoized using React.memo, which will prevent unnecessary re-renders when props don't change.

Also applies to: 20-20, 77-77

src/App/App.tsx (1)

71-71: Verify the impact of removing Sentry error tracking.

While adding userAgent info is helpful for debugging, switching from Sentry to console.error means we'll lose centralized error tracking. Please ensure this aligns with the error monitoring strategy.

✅ Verification successful

🌐 Web query:

What are the implications of switching from Sentry to console.error for error tracking in production?

💡 Result:

Switching from Sentry to console.error for production error tracking has significant implications for visibility, debugging efficiency, and user experience. Below is a breakdown of the key differences and trade-offs:


1. Loss of Automated Error Context

Sentry automatically captures:

  • Stack traces (file/line numbers) [1][4][5]
  • Breadcrumbs (user actions leading to errors) [1][6]
  • Device/OS details, release versions, and user sessions [5][9]
  • Unhandled exceptions (even without explicit try/catch blocks) [1][4]

With console.error, you must manually log these details for every error, increasing code complexity and risking incomplete data.


2. Reduced Debugging Efficiency

  • Sentry aggregates errors into actionable issues with severity levels ([3][7]), while console.error produces unstructured logs requiring manual triage.
  • Missing features like release tracking ([1][4]) or performance monitoring ([5][9]) makes correlating errors to code changes harder.

3. No Real-Time Alerts or Dashboards

Sentry provides:

  • Real-time notifications via Slack/email [3][5]
  • Dashboards for error trends and prioritization [3][9]

console.error only logs to browser/dev tools, leaving teams unaware of critical issues until users report them ([1][7]).


4. Risk of Missing Errors

  • Uncaught exceptions: Sentry captures these automatically ([1][4]), but console.error requires explicit handling in every error-prone code path.
  • Asynchronous errors (e.g., promises) often bypass console.error unless manually tracked ([1][6]).

5. Security and Privacy Risks

  • console.error exposes sensitive data in browser logs (e.g., API keys), whereas Sentry filters PII by default ([7][9]).

When console.error Might Suffice

  • Small projects with minimal error-handling needs.
  • Temporary debugging during development (though Sentry’s dev tools integration is more robust) ([6][8]).

Recommendation

Use console.error alongside Sentry for local debugging but retain Sentry in production for automated monitoring. If cost is a concern, consider open-source alternatives like self-hosted Sentry or lighter tools like Raygun ([3][7]).

Citations:


Impact of Removing Sentry Error Tracking

  • Loss of Automated Context: Sentry automatically captures stack traces, breadcrumbs, release/version data, and device info—details that are not provided by console.error, potentially making troubleshooting more difficult.
  • Reduced Observability: Without Sentry, there are no real-time alerts, dashboards, or aggregated error grouping, increasing the risk of missing critical errors in production.
  • Manual Effort Required: With console.error, you must manually log and manage error context, which can lead to inconsistent or incomplete error data and higher maintenance overhead.
  • Potential Security Risks: Sentry provides built-in filtering for sensitive data, whereas logging directly to the console may expose sensitive information if not carefully handled.

Given these implications, please ensure that replacing Sentry with console.error aligns with our production error monitoring strategy.

src/containers/floating/Settings/sections/releaseNotes/styles.ts (1)

49-49: LGTM! Nice optimization.

The padding syntax has been simplified by removing redundant 'px' units for zero values, which is a cleaner approach.

src/store/useShellOfSecretsStore.ts (1)

17-20: LGTM! Good cleanup of unused exports.

The change to make WsConnectionEvent internal is appropriate as it's only used within this module.

src/containers/floating/ShareRewardModal/styles.ts (1)

51-51: LGTM! Good CSS cleanup.

The changes simplify CSS values by removing redundant units (e.g., 0px0) while maintaining the same visual appearance.

Also applies to: 62-62, 101-101

src/types/app-status.ts (1)

10-15: Verify that these types aren't used externally.

Multiple interfaces and an enum have been changed from exported to internal. While this aligns with the PR's goal of cleaning up dead code, we should verify that these types aren't imported elsewhere in the codebase.

Also applies to: 60-64, 107-111, 113-116, 118-123, 133-145, 158-161, 163-167, 168-174, 176-179, 181-185, 200-202

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Search for any imports of the affected types.
# Note: This will help identify if any of these types are still being used externally.

echo "Searching for imports of affected types..."
rg -l "import.*\b(WindowSettings|Manufacturer|P2poolConnectionInfo|P2poolNetworkInfo|P2poolConnectionCounters|P2poolSquadDetails|P2poolBlockStats|PeerInfo|DeviceStatus|DeviceParameters|HardwareVendor|CpuMinerConnectionStatus)\b"

Length of output: 325


Verification Result: No external imports found for the affected types

The rg search returned no files importing any of the specified types, which implies that they are not used externally. You can proceed confidently with making these types internal.

src/store/useAirdropStore.ts (1)

57-73: LGTM! Good cleanup of unused exports.

The change to make these interfaces internal is appropriate as they are only used within this module.

Also applies to: 104-108, 112-115

package.json (3)

11-11: LGTM! Script changes look good.

The addition of knip to the lint command and as a separate script aligns with the PR's objective of cleaning up dead code. The trailing comma in the translate script maintains consistent formatting.

Also applies to: 14-15


17-44: Verify the impact of removed dependencies.

According to the AI summary, several dependencies were removed (@sentry/react, @tauri-apps/plugin-process, @tauri-apps/plugin-updater). Please ensure that:

  1. All code using these dependencies has been properly removed or refactored
  2. No functionality breaks due to these removals
✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Search for any remaining usage of removed dependencies

echo "Searching for @sentry/react usage..."
rg "@sentry/react"

echo "Searching for @tauri-apps/plugin-process usage..."
rg "@tauri-apps/plugin-process"

echo "Searching for @tauri-apps/plugin-updater usage..."
rg "@tauri-apps/plugin-updater"

Length of output: 383


Dependency cleanup appears complete: The search results do not show any references to @sentry/react, @tauri-apps/plugin-process, or @tauri-apps/plugin-updater remaining in the codebase. It looks like all code using these dependencies has been removed or refactored.

Please ensure integration tests verify that no functionalities are affected by these removals.


51-51: Verify the Node.js types version compatibility.

The update to @types/node from ^22.10.5 to ^22.13.1 and addition of knip ^5.44.0 should be verified for compatibility with the project's Node.js version.

Also applies to: 64-64

✅ Verification successful

🌐 Web query:

What Node.js version is compatible with @types/node ^22.13.1?

💡 Result:

The @types/node package version ^22.13.1 is designed to align with Node.js v22.x (LTS)[1][2][6]. This matches the latest Node.js v22.13.1 security release from January 21, 2025[1][2], which includes critical fixes for vulnerabilities like path traversal and HTTP/2 memory leaks.

Key Compatibility Details:

  • Version synchronization: @types/node versions mirror major Node.js releases (e.g., v22 types for Node.js v22)[4][6].
  • LTS support: Node.js v22 is under long-term support until April 30, 2027[6], making @types/node@^22.x the recommended choice for TypeScript projects targeting this LTS branch.
  • Security alignment: Both packages received updates for CVEs like CVE-2025-23083 (High severity permission model issue) and CVE-2025-23084 (Windows path traversal)[1][2].

For projects using Node.js v23.x or other versions, use the corresponding @types/node version matching your runtime’s major release[6].

Citations:


Node.js Compatibility Verified for Updated Dependencies

Based on the web query, @types/node version ^22.13.1 is designed for Node.js v22.x (LTS), which confirms that the update from ^22.10.5 is compatible with projects targeting Node.js v22. Additionally, there is no evidence from available sources indicating that knip ^5.44.0 introduces any Node.js version compatibility issues. As long as the project’s Node.js environment aligns with the v22 LTS release, these dependency updates are compatible.

Comment on lines +9 to +19
babel: {
plugins: [
[
'babel-plugin-styled-components',
{
displayName: true,
fileName: false,
},
],
],
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the babel-plugin-styled-components configuration options.

The configuration now includes specific options for styled-components. Let's verify if these options are valid and recommended.


🌐 Web query:

What are the recommended configuration options for babel-plugin-styled-components?

💡 Result:

The recommended configuration options for babel-plugin-styled-components focus on improving debugging, SSR compatibility, and CSS specificity management. Here are key settings based on best practices:

Core Configuration

  1. Basic Setup
    Enable server-side rendering and consistent classnames:

    {
      "plugins": ["babel-plugin-styled-components"]
    }

    This provides automatic component IDs for SSR checksum matching[7][9].

  2. Debugging Enhancements
    Add human-readable classnames and React DevTools integration:

    {
      "plugins": [
        ["babel-plugin-styled-components", {
          "displayName": true,
          "fileName": true  
        }]
      ]
    }
    • Shows component names instead of styled.button in DevTools[7][10]
    • Applies filename prefixes in classnames (e.g., Button-asdf123)[9]

Advanced Scenarios

  1. Legacy CSS Conflicts
    For projects needing increased specificity against legacy styles:

    {
      "plugins": [
        ["@quickbaseoss/babel-plugin-styled-components-css-namespace", {
          "cssNamespace": "&&&" // Triple && = 3x specificity boost
        }],
        "babel-plugin-styled-components"
      ]
    }

    Generates .c0.c0.c0 selectors to override nested legacy rules[4][1].

  2. Micro Frontend Isolation
    Prevent CSS collisions in shared environments:

    {
      "plugins": [
        ["babel-plugin-styled-components", {
          "namespace": "my-app"
        }]
      ]
    }

    Adds unique component IDs like my-app__sc-3rfj0a-1[7].

Optimization Flags

  1. Production Settings
    Enable size optimizations:
    {
      "plugins": [
        ["babel-plugin-styled-components", {
          "minify": true,
          "transpileTemplateLiterals": false
        }]
      ]
    }
    • Reduces bundle size via template literal compression[7]
    • Disables CSS source maps for production builds[7]

For Next.js users, ensure proper Babel config merging by placing the plugin in each environment's plugins array rather than the global list[3][5]. The plugin should always appear before other style-related transformers in your Babel configuration chain[6][9].

Citations:


Babel-plugin-styled-components: Configuration Mismatch

  • The plugin accepts both options, and using displayName: true is valid.
  • However, best practices for improved debugging recommend setting fileName to true (to show filename prefixes in generated class names).
  • If your goal is to enhance component traceability in DevTools during development, consider changing fileName from false to true.

@shanimal08 shanimal08 changed the title chore: clean up dead code [DNM] chore: clean up dead code (in FE) Feb 12, 2025
@shanimal08 shanimal08 marked this pull request as ready for review February 12, 2025 07:08
@shanimal08 shanimal08 added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant