Skip to content

chore: adding design tokens eslint plugin color-no-hex rule #24089

Merged
georgewrmarshall merged 2 commits intodevelopfrom
fix/eslint-plugin-design-tokens
Apr 25, 2024
Merged

chore: adding design tokens eslint plugin color-no-hex rule #24089
georgewrmarshall merged 2 commits intodevelopfrom
fix/eslint-plugin-design-tokens

Conversation

@georgewrmarshall
Copy link
Copy Markdown
Contributor

@georgewrmarshall georgewrmarshall commented Apr 17, 2024

Description

This PR introduces the @metamask/eslint-plugin-design-tokens library to the MetaMask extension codebase, along with the implementation of the color-no-hex rule. This rule aims to prevent the use of static hex color values in our .js, .ts and .tsx files encouraging instead the adoption of design tokens. The motivation behind this change is to ensure our styling remains consistent with the MetaMask design system, enhancing themability, accessibility, and overall alignment with our design principles. Additionally, this update is a crucial step towards enabling the seamless rollout of future brand evolution within MetaMask, ensuring that our UI can adapt to new design standards with minimal effort.

Related issues

Fixes: #24111

Manual testing steps

To ensure the successful integration of the eslint-plugin-design-tokens and the effectiveness of the color-no-hex rule:

  1. Install the updated dependencies by running yarn install.
  2. Execute yarn lint:check to identify any instances of static hex color values.
  3. Review the linting output and update any flagged instances to use the corresponding design tokens.
  4. Navigate through the extension's UI to verify that the updates maintain visual consistency and adhere to the design system.

Screenshots/Recordings

Before

before720.mov

After

after1080.mov

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability.
  • I’ve included tests if applicable.
  • I’ve documented my code using JSDoc format if applicable.
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g., pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@georgewrmarshall georgewrmarshall added the team-design-system All issues relating to design system in Extension label Apr 17, 2024
@georgewrmarshall georgewrmarshall self-assigned this Apr 17, 2024
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

.eslintrc.js Outdated
Comment on lines 21 to 24
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adding plugin and color no hex rule to eslintrc.js file

.eslintrc.js Outdated
Comment on lines 446 to 458
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ignoring all test files

Comment on lines 452 to 446
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is a current issue with some false positives that need to be fixed issue here MetaMask/eslint-plugin-design-tokens#20

package.json Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring this file

@georgewrmarshall georgewrmarshall force-pushed the fix/eslint-plugin-design-tokens branch from c863882 to d8f2ce6 Compare April 17, 2024 16:46
@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 17, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/eslint-plugin-design-tokens@1.1.0 None 0 40.1 kB metamaskbot

View full report↗︎

@georgewrmarshall georgewrmarshall force-pushed the fix/eslint-plugin-design-tokens branch from d8f2ce6 to 93a0e05 Compare April 17, 2024 17:13
@georgewrmarshall georgewrmarshall changed the title Adding design tokens eslint plugin color-no-hex rule chore: adding design tokens eslint plugin color-no-hex rule Apr 17, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [93a0e05]
Page Load Metrics (1446 ± 731 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint673581517938
domContentLoaded126627157
load55380014461522731
domInteractive126627157
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 67.46%. Comparing base (fef4fa5) to head (f7543dd).
Report is 12 commits behind head on develop.

Files Patch % Lines
app/scripts/controllers/preferences.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #24089   +/-   ##
========================================
  Coverage    67.46%   67.46%           
========================================
  Files         1258     1258           
  Lines        49259    49261    +2     
  Branches     12826    12826           
========================================
+ Hits         33229    33231    +2     
  Misses       16030    16030           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@georgewrmarshall georgewrmarshall marked this pull request as ready for review April 17, 2024 18:00
@georgewrmarshall georgewrmarshall requested review from a team as code owners April 17, 2024 18:00
garrettbear
garrettbear previously approved these changes Apr 19, 2024
@georgewrmarshall georgewrmarshall force-pushed the fix/eslint-plugin-design-tokens branch from 25bf40a to d105e2c Compare April 23, 2024 17:26
garrettbear
garrettbear previously approved these changes Apr 23, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [d105e2c]
Page Load Metrics (994 ± 610 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint691761062914
domContentLoaded107624167
load5234299941271610
domInteractive107624167
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

darkwing
darkwing previously approved these changes Apr 24, 2024
@darkwing darkwing added the needs-assets-ux-review A shared label between the Assets and UX team to flag PRs ready for consolidated team review. label Apr 24, 2024
NidhiKJha
NidhiKJha previously approved these changes Apr 24, 2024
@@ -1,3 +1,4 @@
/* eslint-disable @metamask/design-tokens/color-no-hex*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring image asset svg component

@georgewrmarshall georgewrmarshall requested a review from a team as a code owner April 24, 2024 16:45
@@ -1,3 +1,4 @@
/* eslint-disable @metamask/design-tokens/color-no-hex*/
import React from 'react';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring image asset svg component

@@ -1,3 +1,4 @@
/* eslint-disable @metamask/design-tokens/color-no-hex*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring image asset svg component

@@ -1,3 +1,4 @@
/* eslint-disable @metamask/design-tokens/color-no-hex*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring image asset svg component

@@ -1,3 +1,4 @@
/* eslint-disable @metamask/design-tokens/color-no-hex*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring image asset svg component

@@ -1,3 +1,4 @@
/* eslint-disable @metamask/design-tokens/color-no-hex*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring image asset svg component

Copy link
Copy Markdown
Contributor

@dbrans dbrans left a comment

Choose a reason for hiding this comment

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

Thank you for adding this, George!

Copy link
Copy Markdown
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

Changes in files owned by confirmation ux team look good.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [f7543dd]
Page Load Metrics (1305 ± 736 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint601931043215
domContentLoaded9472184
load48419513051533736
domInteractive9472184
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@georgewrmarshall georgewrmarshall merged commit d5dbf74 into develop Apr 25, 2024
@georgewrmarshall georgewrmarshall deleted the fix/eslint-plugin-design-tokens branch April 25, 2024 15:30
@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2024
@gauthierpetetin gauthierpetetin added the release-12.0.0 Issue or pull request that will be included in release 12.0.0 label Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

needs-assets-ux-review A shared label between the Assets and UX team to flag PRs ready for consolidated team review. release-12.0.0 Issue or pull request that will be included in release 12.0.0 team-design-system All issues relating to design system in Extension

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Implement color-no-hex Rule in Extension to Enforce Design Token Usage