Skip to content

Conversation

@Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Dec 15, 2025

Explanation

This PR addresses ESLint suppressions for Group 2 files as part of the ASSETS-2100 cleanup initiative.

  • Current State: ESLint suppressions were present for @typescript-eslint/naming-convention, @typescript-eslint/explicit-function-return-type, and id-length rules in the specified files.
  • Solution:
    • notification-schema.ts:
      • For the TRIGGER_TYPES enum, an eslint-disable comment was added for @typescript-eslint/naming-convention. This is a deliberate choice to use SCREAMING_SNAKE_CASE for enum members to mirror snake_case API string values, enhancing readability.
      • The type alias NOTIFICATION_CHAINS_IDS was renamed to NotificationChainsIds (PascalCase) and its usages updated in ui/constants.ts and get-notification-message.ts.
    • mockResponses.ts: Explicit return types (: MockResponse) were added to all 6 functions to resolve @typescript-eslint/explicit-function-return-type violations.
    • process-api-notifications.test.ts: The variable n was renamed to notification to fix the id-length rule.
    • eslint-suppressions.json: All corresponding suppression entries for these files were removed.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Open in Cursor Open in Web


Note

Removes ESLint suppressions by adding targeted disables and type-safe helpers in notification services, and minor test variable rename.

  • Notification Services:
    • constants/notification-schema.ts:
      • Add targeted @typescript-eslint/naming-convention disable/enable around TRIGGER_TYPES enum; document SCREAMING_SNAKE_CASE usage.
      • Keep NOTIFICATION_CHAINS_IDS with explicit compatibility comment and rule disable.
    • mocks/mockResponses.ts:
      • Use satisfies MockResponse with temporary @typescript-eslint/explicit-function-return-type disables to preserve narrow types for mock factory functions.
    • processors/process-api-notifications.test.ts:
      • Rename mapping variable from n to notification.
  • ESLint:
    • Update eslint-suppressions.json to remove suppressions for the adjusted files.

Written by Cursor Bugbot for commit 3b5f3a0. This will update automatically on new commits. Configure here.

@cursor
Copy link

cursor bot commented Dec 15, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@Prithpal-Sooriya
Copy link
Contributor Author

@cursor update the packages/notification-services-controller/CHANGELOG.md changelog to reflect changes made.

@cursor
Copy link

cursor bot commented Dec 15, 2025

The changelog has been updated successfully. I've added a breaking change entry for the type rename:

- **BREAKING:** Rename type `NOTIFICATION_CHAINS_IDS` to `NotificationChainsIds` ([#7486](https://github.com/MetaMask/core/pull/7486))

This entry documents the change from NOTIFICATION_CHAINS_IDS (SCREAMING_SNAKE_CASE) to NotificationChainsIds (PascalCase) to comply with the @typescript-eslint/naming-convention ESLint rule. It's marked as breaking because consumers who were using the old type name will need to update their code.


Open in Cursor Open in Web

Learn more about Cursor Agents

export const CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();

export const getMockFeatureAnnouncementResponse = () => {
export const getMockFeatureAnnouncementResponse = (): MockResponse => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cursor these return types that use satisfies are special cases and the returning object is a narrow subset of MockResponse.

I'm open to adding eslint ignore comments on this file with a good 1-liner explanation.

Copy link

@cursor cursor bot Dec 15, 2025

Choose a reason for hiding this comment

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

I've reverted the explicit return types and added eslint-disable comments with explanations. Here's the updated mockResponses.ts:

// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse
/* eslint-disable @typescript-eslint/explicit-function-return-type */
export const getMockFeatureAnnouncementResponse = () => {
  return {
    url: FEATURE_ANNOUNCEMENT_API,
    requestMethod: 'GET',
    response: CONTENTFUL_RESPONSE,
  } satisfies MockResponse;
};

export const getMockUpdateOnChainNotifications = () => {
  return {
    url: TRIGGER_API_NOTIFICATIONS_ENDPOINT(),
    requestMethod: 'POST',
    response: null,
  } satisfies MockResponse;
};

export const getMockOnChainNotificationsConfig = () => {
  return {
    url: TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT(),
    requestMethod: 'POST',
    response: [{ address: '0xTestAddress', enabled: true }],
  } satisfies MockResponse;
};
/* eslint-enable @typescript-eslint/explicit-function-return-type */

The explanation comment clarifies that satisfies is used to preserve narrow return types while ensuring type safety, and that adding explicit return types would widen the type to MockResponse and lose the specific inferred types. ESLint passes on all files.


Open in Cursor Open in Web

Learn more about Cursor Agents

@Prithpal-Sooriya
Copy link
Contributor Author

@cursor fix prettier issues on files changed

@cursor
Copy link

cursor bot commented Dec 15, 2025

Prettier issues have been fixed. The only file that needed formatting was eslint-suppressions.json (it was missing a trailing newline). All other changed files were already correctly formatted.

All lint and formatting checks now pass:

  • ✅ ESLint passes
  • ✅ Prettier/misc lint passes

Open in Cursor Open in Web

Learn more about Cursor Agents

} as const;

export type NOTIFICATION_CHAINS_IDS =
export type NotificationChainsIds =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cursor can you keep this SCREAMING_SNAKE_CASE as I want to avoid modifying other files.
You can specify that this is to maintain backwards compatibility.

Copy link

@cursor cursor bot Dec 15, 2025

Choose a reason for hiding this comment

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

I've reverted the type alias back to NOTIFICATION_CHAINS_IDS with an inline eslint-disable comment explaining it's kept for backwards compatibility:

// Kept as SCREAMING_SNAKE_CASE for backwards compatibility
// eslint-disable-next-line @typescript-eslint/naming-convention
export type NOTIFICATION_CHAINS_IDS =
  (typeof NOTIFICATION_CHAINS_ID)[keyof typeof NOTIFICATION_CHAINS_ID];

I also:

  • Reverted ui/constants.ts and get-notification-message.ts back to using NOTIFICATION_CHAINS_IDS
  • Removed the breaking change entry from the changelog

All ESLint and Prettier checks pass.


Open in Cursor Open in Web

Learn more about Cursor Agents

@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review December 15, 2025 11:19
@Prithpal-Sooriya Prithpal-Sooriya requested review from a team as code owners December 15, 2025 11:19
@Prithpal-Sooriya
Copy link
Contributor Author

https://github.com/cursor update the packages/notification-services-controller/CHANGELOG.md changelog to reflect changes made.

@cursor
Copy link

cursor bot commented Dec 15, 2025

The changelog has been updated with an entry for this PR:

- Refactor: Add inline ESLint disable comments for intentional naming conventions in `notification-schema.ts` and `mockResponses.ts` ([#7486](https://github.com/MetaMask/core/pull/7486))

The changelog validation passes.


Open in Cursor Open in Web

Learn more about Cursor Agents

@Prithpal-Sooriya Prithpal-Sooriya changed the title Notification controller eslint cleanup chore: Notification controller eslint cleanup Dec 15, 2025
@Prithpal-Sooriya
Copy link
Contributor Author

@cursor please remove the changelog changes, as these eslint changes does not impact the implementation

@cursor
Copy link

cursor bot commented Dec 15, 2025

Done. I've removed the changelog entry for this PR since the ESLint changes don't impact the implementation.


Open in Cursor Open in Web

Learn more about Cursor Agents

juanmigdr
juanmigdr previously approved these changes Dec 15, 2025
bergarces
bergarces previously approved these changes Dec 15, 2025
@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Dec 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Dec 15, 2025
@Prithpal-Sooriya Prithpal-Sooriya dismissed stale reviews from bergarces and juanmigdr via b1d52b0 December 15, 2025 13:04
@Prithpal-Sooriya
Copy link
Contributor Author

@cursor fix & cleanup eslint-suppressions.json

@cursor
Copy link

cursor bot commented Dec 15, 2025

The eslint-suppressions.json has been fixed and cleaned up. The branch is now in the correct state:

Changes from main:

  1. eslint-suppressions.json - Removed the 3 suppression entries for:

    • notification-schema.ts (@typescript-eslint/naming-convention: 18)
    • mockResponses.ts (@typescript-eslint/explicit-function-return-type: 6)
    • process-api-notifications.test.ts (id-length: 1)
  2. notification-schema.ts - Added inline eslint-disable comments with explanations for the TRIGGER_TYPES enum and NOTIFICATION_CHAINS_IDS type alias

  3. mockResponses.ts - Added inline eslint-disable comments with explanations for functions using satisfies

  4. process-api-notifications.test.ts - Renamed n to notification to satisfy the id-length rule

Verification:

  • ✅ ESLint passes
  • ✅ Prettier formatting is correct
  • ✅ JSON is valid
  • ✅ Only the intended 4 files differ from main

Open in Cursor Open in Web

Learn more about Cursor Agents

@Prithpal-Sooriya Prithpal-Sooriya force-pushed the cursor/notification-controller-eslint-cleanup-ba8d branch from b1d52b0 to ed9ece0 Compare December 15, 2025 13:28
@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Dec 15, 2025
Merged via the queue into main with commit e1f8e9c Dec 15, 2025
285 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the cursor/notification-controller-eslint-cleanup-ba8d branch December 15, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants