MetaMask / MetaMask/metamask-mobile
chore: enforce color-no-hex rule for hex values inside Tailwind arbitrary brackets
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
## Summary
The `@metamask/design-tokens/color-no-hex` ESLint rule does not catch hex color values embedded inside Tailwind arbitrary value brackets (e.g. `bg-[#330745]`).
The rule matches hex strings as standalone JS string values but not when they appear as part of a larger string like a Tailwind class.
## Example
```tsx
// Not caught by color-no-hex ❌
```
## Current rule config
The `tailwindcss/no-arbitrary-value` rule is set to `'off'` in the component-library/components override because there are legitimate reasons to use arbitrary values — but the comment notes we *should* specifically error on static colors:
```js
'tailwindcss/no-arbitrary-value': 'off', // There are legitimate reasons to use arbitrary values but we should specifically error on static colors
```
## Proposed fix
Enable `tailwindcss/no-arbitrary-value: 'error'` and add `// eslint-disable-next-line` comments for any legitimate non-color arbitrary values, OR write/configure a rule that specifically targets hex patterns inside `[...]` brackets in Tailwind class strings.
## References
- PR: `remove-static-hex-from-tests`
- File with violation: `app/components/UI/Card/components/Onboarding/KYCFailed.tsx`
Contributor guide
Research direction
Start with the component-library/components ESLint override and the violation in app/components/UI/Card/components/Onboarding/KYCFailed.tsx. Check how color-no-hex handles standalone strings and how Tailwind arbitrary classes are linted, then run the relevant lint checks. Done means the hex in bg-[#330745] is reported while legitimate non-color arbitrary values remain supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, tailwindcss, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100