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

Remove ts-nocheck from brave://settings files #27107

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Jan 2, 2025

Resolves brave/brave-browser#31715

This PR removes @ts-nocheck from all brave://settings files, allowing type-checking to be enforced consistently there.

I tried to add and use appropriate types everywhere it was feasible and pragmatic, but in a few situations I was forced to use any in order to avoid making unreasonably large changes. I also didn't try to convert the one or two legacy behaviors we still use into mixins.

One of our existing settings-related patches need to be updated to include new routes/identifiers. Other than that, no patches were introduced.

It's best to review these by commit. The cosmetic/linter commit can largely be ignored, I just tried to bring our code somewhat up to the standards currently defined by our linter (I managed to eliminate about 50% of the linter-related errors with that commit).

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

This requires full testing of brave://settings, but changes primarily occurred in the following areas:

  • Clear browsing data, especially the "On exit" tab
  • Reset settings
  • Sync settings
  • Brave Tor settings
  • Brave Wallet settings, including network lists
  • Brave Shields settings
  • Adblock settings
  • Pin shortcut settings

@emerick emerick self-assigned this Jan 2, 2025
@emerick emerick added the CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) label Jan 2, 2025
@github-actions github-actions bot added CI/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet feature/web3/wallet/core labels Jan 2, 2025
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@emerick emerick requested a review from AlexeyBarabash January 2, 2025 21:40
Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

Wow, great work on this @emerick - that was a lot of thankless work.

LGTM % nits

Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

lgtm!

@emerick emerick force-pushed the emerick-remove-ts-nocheck-from-settings-files branch 3 times, most recently from 5e704f0 to fe8f786 Compare January 7, 2025 02:58
@emerick emerick marked this pull request as ready for review January 7, 2025 11:53
@emerick emerick requested a review from a team as a code owner January 7, 2025 11:53
@emerick emerick force-pushed the emerick-remove-ts-nocheck-from-settings-files branch from fe8f786 to 4690527 Compare January 7, 2025 15:12
Copy link
Contributor

github-actions bot commented Jan 7, 2025

[puLL-Merge] - brave/brave-core@27107

Description

This PR makes significant changes to the Brave browser's settings pages, primarily focusing on TypeScript improvements and code modernization. It updates various components, adds type annotations, and refactors code to improve type safety and readability.

Possible Issues

  1. The extensive changes across multiple files may introduce unintended side effects or regressions in the settings functionality.
  2. Some type assertions and casts (as any) are used, which could potentially hide type errors.

Security Hotspots

  1. The changes to the wallet and adblock components should be carefully reviewed to ensure no security vulnerabilities are introduced, especially in areas dealing with user data or network requests.
Changes

Changes

  1. brave_clear_browsing_data_dialog_behavior.ts:

    • Added type annotations and improved TypeScript compatibility.
    • Refactored event handling and DOM manipulation.
  2. brave_clear_browsing_data_dialog_proxy.ts:

    • Added type annotations to the interface and implementation.
  3. brave_clear_browsing_data_on_exit_page.ts:

    • Converted to a class-based component with proper TypeScript annotations.
  4. about_page.ts, basic_page.ts, clear_browsing_data_dialog.ts:

    • Improved TypeScript compatibility and added type annotations.
  5. default_browser_page.ts, import_data_dialog.ts, page_visibility.ts:

    • Added type annotations and improved code structure.
  6. settings_menu.ts, settings_ui.ts, site_details.ts:

    • Refactored to use TypeScript features and improved type safety.
  7. brave_sync_page/*.ts:

    • Added type annotations and improved TypeScript compatibility.
  8. brave_tor_page/*.ts:

    • Converted to TypeScript and added proper type annotations.
  9. brave_wallet_page/*.ts:

    • Improved TypeScript compatibility and added type annotations.
  10. default_brave_shields_page/*.ts:

    • Converted to TypeScript and added type annotations.
  11. pin_shortcut_page/*.ts:

    • Added TypeScript annotations and improved code structure.
sequenceDiagram
    participant User
    participant Settings
    participant BraveProxy
    participant ChromeAPI

    User->>Settings: Open Settings
    Settings->>BraveProxy: Initialize proxies
    BraveProxy->>ChromeAPI: Get initial settings
    ChromeAPI-->>BraveProxy: Return settings
    BraveProxy-->>Settings: Update UI
    User->>Settings: Change setting
    Settings->>BraveProxy: Update setting
    BraveProxy->>ChromeAPI: Apply setting change
    ChromeAPI-->>BraveProxy: Confirm change
    BraveProxy-->>Settings: Update UI
Loading

@emerick emerick force-pushed the emerick-remove-ts-nocheck-from-settings-files branch from 4690527 to c45e471 Compare January 7, 2025 15:13
Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

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

patches++

@emerick emerick merged commit feab1f7 into master Jan 7, 2025
18 checks passed
@emerick emerick deleted the emerick-remove-ts-nocheck-from-settings-files branch January 7, 2025 17:23
@github-actions github-actions bot added this to the 1.75.x - Nightly milestone Jan 7, 2025
@brave-builds
Copy link
Collaborator

Released in v1.75.153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) CI/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet/core feature/web3/wallet puLL-Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define types and remove ts-nocheck on brave://settings pages
4 participants