Skip to content

Add ESLint rule for slow CSS properties that may impact GPU rendering #5425

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

Merged
merged 4 commits into from
Jun 19, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 19, 2025

This PR adds a new ESLint rule @remotion/slow-css-property that warns developers when they use CSS properties that may slow down rendering on machines without a GPU.

What it does

The rule detects usage of the following CSS properties in React style objects:

  • boxShadow - Box shadow effects
  • textShadow - Text shadow effects
  • filter - CSS filter effects (blur, brightness, etc.)

When any of these properties are used, the rule displays a warning:

This GPU effect may slow down the render on machines which don't have a GPU.
See: https://remotion.dev/docs/gpu

Examples

Invalid (triggers warning):

const style = {
  boxShadow: "0 0 5px red",
  textShadow: "1px 1px 1px black",
  filter: "blur(5px)"
};

Valid (no warning):

const style = {
  color: "red",
  backgroundColor: "blue",
  margin: 10,
  // String keys don't trigger the rule
  "box-shadow": "0 0 5px red"
};

Implementation Details

  • Added new rule file: src/rules/slow-css-property.ts
  • Added comprehensive tests: src/tests/slow-css-property.test.ts
  • Updated main index to export the rule and include it in recommended config as a "warn" level rule
  • Follows existing code patterns and ESLint plugin conventions
  • All existing tests continue to pass

The rule is automatically included when using @remotion/eslint-plugin with the recommended configuration.

Fixes #5424.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

vercel bot commented Jun 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bugs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 6:12am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
remotion ⬜️ Skipped (Inspect) Jun 19, 2025 6:12am

@vercel vercel bot temporarily deployed to Preview – remotion June 19, 2025 05:05 Inactive
@Copilot Copilot AI changed the title [WIP] ESLint rule if a slow CSS property is being used in React Add ESLint rule for slow CSS properties that may impact GPU rendering Jun 19, 2025
@Copilot Copilot AI requested a review from JonnyBurger June 19, 2025 05:07
Copilot finished work on behalf of JonnyBurger June 19, 2025 05:07
@JonnyBurger
Copy link
Member

@copilot String keys like "box-shadow" should indeed also trigger the warning

@vercel vercel bot temporarily deployed to Preview – remotion June 19, 2025 05:27 Inactive
Copy link
Contributor Author

Copilot AI commented Jun 19, 2025

@copilot String keys like "box-shadow" should indeed also trigger the warning

Fixed! The rule now detects both camelCase properties (boxShadow) and string literal properties ("box-shadow"). Updated tests to verify both patterns trigger warnings. (e4b29bb)

@JonnyBurger
Copy link
Member

@copilot Nice, please also detect these properties applied via Tailwind classes

@vercel vercel bot temporarily deployed to Preview – remotion June 19, 2025 06:12 Inactive
Copy link
Contributor Author

Copilot AI commented Jun 19, 2025

@copilot Nice, please also detect these properties applied via Tailwind classes

Added Tailwind CSS class detection! The rule now detects slow CSS properties in both React style objects and Tailwind classes including shadow-, blur-, brightness-, contrast-, drop-shadow-, grayscale, hue-rotate-, invert, saturate-*, and sepia classes. (c631da5)

Copilot finished work on behalf of JonnyBurger June 19, 2025 06:13
@JonnyBurger JonnyBurger marked this pull request as ready for review June 19, 2025 08:00
@JonnyBurger JonnyBurger enabled auto-merge June 19, 2025 08:00
@JonnyBurger JonnyBurger merged commit b969199 into main Jun 19, 2025
14 checks passed
@JonnyBurger JonnyBurger deleted the copilot/fix-5424 branch June 19, 2025 08:10
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.

ESLint rule if a slow CSS property is being used in React
2 participants