-
Notifications
You must be signed in to change notification settings - Fork 31
feat: Disable inline style prop for components
#3213
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
Conversation
|
View your CI Pipeline Execution ↗ for commit 95f3c4e
☁️ Nx Cloud last updated this comment at |
dreamwasp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfection
| }, | ||
| messages: { | ||
| noInlineStyle: | ||
| 'Inline styles are not allowed. Use styled components, CSS classes, or design system utilities instead.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should tone this down a little - The use of inline styles is discouraged
| @@ -0,0 +1,72 @@ | |||
| import { ESLintUtils } from '@typescript-eslint/utils'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love love love these
| ## Related documentation | ||
|
|
||
| - <LinkTo id="Meta/Best Practices">Best Practices</LinkTo> - Learn about Gamut styling | ||
| best practices | ||
| - <LinkTo id="Foundations/System/Props">System Props</LinkTo> - Using system props | ||
| as an alternative to inline styles | ||
| - <LinkTo id="Foundations/System/Variants">Variants</LinkTo> - Creating styled variants | ||
| with gamut-styles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loveee this
|
📬 Published Alpha Packages: |
|
🚀 Styleguide deploy preview ready! Preview URL: https://6924baafb1ab8c7677e16824--gamut-preview.netlify.app |
Overview
Added a custom ESLint rule
gamut/no-inline-styletoeslint-plugin-gamutto disallow inlinestyleprops on JSX elements. This rule encourages the use of styled components, CSS classes, or design system utilities instead of inline styles.Changes:
no-inline-stylerule with full test coverage ineslint-plugin-gamut.eslintrc.jsto use the custom rule (set to 'error' level)recommendedconfigurationgamut-illustrationspackage where inline styles are acceptableMeta/ESLint Rules)PR Checklist
Testing Instructions
Check the ESLint documentation:
Verify the rule catches inline styles locally:
<div style={{ padding: 0 }} />to any component in thegamutpackageCheck that components with disable comments still work:
Card/index.tsx,Animation/Rotation.tsx,Animation/ExpandInCollapseOut.tsx,FocusTrap/index.tsx,Popover/Popover.tsx,Video/lib/VidstackPlayer.tsx, orForm/SelectDropdown/elements/controls.tsxstylepropsPR Links and Envs