Description
Implement eslint-plugin-tailwindcss to provide comprehensive linting and validation for Tailwind CSS usage across the design system. This plugin will complement our existing VS Code IntelliSense setup and enforce consistent Tailwind CSS practices, particularly important now that we've removed default Tailwind utilities to enforce design system component usage.
The plugin offers 8+ rules for enforcing best practices, with the key benefit being the no-custom-classname rule that prevents usage of invalid Tailwind classes - perfect for our goal of enforcing Text component usage and design system compliance.
Technical Details
Installation:
- Add
eslint-plugin-tailwindcss as a dev dependency
- Configure ESLint flat config to use the plugin with our existing dual-config setup
Key Rules to Implement:
no-custom-classname: Prevents invalid Tailwind classes (main enforcement mechanism)
no-contradicting-classname: Prevents conflicting classes like text-left text-right
classnames-order: Enforces consistent class ordering (complements prettier-plugin-tailwindcss)
enforces-shorthand: Merges multiple classnames into shorthand (e.g. mx-5 my-5 → m-5)
no-unnecessary-arbitrary-value: Suggests configuration-based classnames over arbitrary values
Configuration Strategy:
- Mirror existing VS Code IntelliSense setup with two configurations:
- React Web: Use
apps/storybook-react/tailwind.config.js
- React Native: Use
apps/storybook-react-native/tailwind-intellisense.config.js
- Configure
callees to match existing setup: ["tw", "twMerge", "clsx", "cn", "cva"]
- Set
classRegex to match existing patterns: "^(class(Name)?|tw(ClassName)?)$"
File Patterns:
- React Web Files:
packages/design-system-react/src/**, apps/storybook-react/**, packages/design-tokens/stories/**
- React Native Files:
packages/design-system-react-native/src/**, apps/storybook-react-native/stories/**
Acceptance Criteria
Success Indicators:
- Developers cannot use removed default Tailwind utilities without ESLint errors
- Class ordering and formatting remain consistent with existing Prettier setup
- Build failures occur when invalid classes are introduced
- Team receives immediate feedback on Tailwind CSS best practices
References
- Package: https://www.npmjs.com/package/eslint-plugin-tailwindcss
- Current VS Code Setup:
.vscode/settings.json with tailwindCSS.validate: true
- Current ESLint Config:
eslint.config.mjs using flat config format
- Prettier Config:
.prettierrc.js with prettier-plugin-tailwindcss
- Related Work: Recent changes removing default font sizes and colors to enforce design system usage
- Tailwind Configs:
- React:
apps/storybook-react/tailwind.config.js
- React Native:
apps/storybook-react-native/tailwind-intellisense.config.js
- ESLint 9 Compatibility: Plugin supports flat config format (required for our setup)
- GitHub Repository: https://github.com/francoismassart/eslint-plugin-tailwindcss
Description
Implement eslint-plugin-tailwindcss to provide comprehensive linting and validation for Tailwind CSS usage across the design system. This plugin will complement our existing VS Code IntelliSense setup and enforce consistent Tailwind CSS practices, particularly important now that we've removed default Tailwind utilities to enforce design system component usage.
The plugin offers 8+ rules for enforcing best practices, with the key benefit being the
no-custom-classnamerule that prevents usage of invalid Tailwind classes - perfect for our goal of enforcing Text component usage and design system compliance.Technical Details
Installation:
eslint-plugin-tailwindcssas a dev dependencyKey Rules to Implement:
no-custom-classname: Prevents invalid Tailwind classes (main enforcement mechanism)no-contradicting-classname: Prevents conflicting classes liketext-left text-rightclassnames-order: Enforces consistent class ordering (complements prettier-plugin-tailwindcss)enforces-shorthand: Merges multiple classnames into shorthand (e.g.mx-5 my-5→m-5)no-unnecessary-arbitrary-value: Suggests configuration-based classnames over arbitrary valuesConfiguration Strategy:
apps/storybook-react/tailwind.config.jsapps/storybook-react-native/tailwind-intellisense.config.jscalleesto match existing setup:["tw", "twMerge", "clsx", "cn", "cva"]classRegexto match existing patterns:"^(class(Name)?|tw(ClassName)?)$"File Patterns:
packages/design-system-react/src/**,apps/storybook-react/**,packages/design-tokens/stories/**packages/design-system-react-native/src/**,apps/storybook-react-native/stories/**Acceptance Criteria
eslint-plugin-tailwindcssis installed and configured ineslint.config.mjsno-custom-classnamerule prevents usage of removed default utilities (e.g.,text-sm,bg-red-500)yarn lintcommand catches invalid Tailwind classesprettier-plugin-tailwindcsswithout conflictsSuccess Indicators:
References
.vscode/settings.jsonwithtailwindCSS.validate: trueeslint.config.mjsusing flat config format.prettierrc.jswithprettier-plugin-tailwindcssapps/storybook-react/tailwind.config.jsapps/storybook-react-native/tailwind-intellisense.config.js