Skip to content

Conversation

@LinKCoding
Copy link
Contributor

@LinKCoding LinKCoding commented Nov 18, 2025

Overview

Added a custom ESLint rule gamut/no-inline-style to eslint-plugin-gamut to disallow inline style props on JSX elements. This rule encourages the use of styled components, CSS classes, or design system utilities instead of inline styles.

Changes:

  • Created no-inline-style rule with full test coverage in eslint-plugin-gamut
  • Updated .eslintrc.js to use the custom rule (set to 'error' level)
  • Added rule to recommended configuration
  • Disabled rule for gamut-illustrations package where inline styles are acceptable
  • Added ESLint disable comments to existing components that require inline styles (Card, Rotation, ExpandInCollapseOut, FocusTrap, Popover, VidstackPlayer, SelectDropdown components)
  • Created comprehensive ESLint rules documentation page in Storybook (Meta/ESLint Rules)
  • Added ESLint rules link to Meta section table of contents

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GMT-231
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

  1. Check the ESLint documentation:

    • Open the Preview, or run Storybook locally, and navigate to Meta → ESLint Rules
    • Verify all four rules are documented with examples
  2. Verify the rule catches inline styles locally:

    • Try adding something like: <div style={{ padding: 0 }} /> to any component in the gamut package
    • You should see an ESLint error about inline styles
  3. Check that components with disable comments still work:

    • Open one of: Card/index.tsx, Animation/Rotation.tsx, Animation/ExpandInCollapseOut.tsx, FocusTrap/index.tsx, Popover/Popover.tsx, Video/lib/VidstackPlayer.tsx, or Form/SelectDropdown/elements/controls.tsx
    • Verify no ESLint errors are shown despite the style props
    • Go to their respective stories and see that the component works just fine

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

@LinKCoding LinKCoding requested a review from a team as a code owner November 18, 2025 17:07
@nx-cloud
Copy link

nx-cloud bot commented Nov 18, 2025

View your CI Pipeline Execution ↗ for commit 95f3c4e

Command Status Duration Result
nx run-many --target=verify --parallel=3 --all ✅ Succeeded <1s View ↗
nx run-many --target=build --all ✅ Succeeded 44s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-24 20:02:45 UTC

@LinKCoding LinKCoding marked this pull request as draft November 18, 2025 17:11
@LinKCoding LinKCoding marked this pull request as ready for review November 20, 2025 16:05
Copy link
Contributor

@dreamwasp dreamwasp left a 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.',
Copy link
Contributor

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';
Copy link
Contributor

Choose a reason for hiding this comment

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

love love love these

Comment on lines +248 to +255
## 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
Copy link
Contributor

Choose a reason for hiding this comment

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

loveee this

@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@github-actions
Copy link
Contributor

@LinKCoding LinKCoding added the Ship It :shipit: Automerge this PR when possible label Dec 1, 2025
@codecademydev codecademydev merged commit e695579 into main Dec 1, 2025
16 of 17 checks passed
@codecademydev codecademydev removed the Ship It :shipit: Automerge this PR when possible label Dec 1, 2025
@codecademydev codecademydev deleted the kl-gmt-231-disable-inline-style branch December 1, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants