Skip to content

Conversation

@Azurinine
Copy link

@Azurinine Azurinine commented Feb 11, 2026

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

This PR address the concerns brought up in issue #6472, and enforces the use of @theme/IdealImage component instead of tags.

Following feedback from @slorber in previous discussions (#8826, #11416), this rule adopts a tiered approach to minimize false positives and noise:

  • Error Tier: Triggered for src={require('./img.png')}. Since the asset is explicitly required, we are certain it is a local file that would benefit from the Ideal Image optimization pipeline.
  • Warning Tier: Triggered for static relative paths (e.g., ./img.png) or root-relative paths (/img.png). This nudges the user to optimize if the file is indeed local.
  • Silent/Ignored: * External URLs (https://...) and protocol-relative links (//).
    • Dynamic values (e.g., src={props.src} or src={someVariable}) to avoid annoying users in generic components.
    • SVGs: Since IdealImage does not support vector formats, these are explicitly ignored to prevent useless warnings.

Test Plan

I have implemented a comprehensive test suite in prefer-ideal-image.test.ts covering the following:

  • Valid cases: External HTTPS links, template literals with external prefixes, dynamic props/variables, and .svg files.
  • Invalid cases: Standard <img> tags using require(), relative strings, and manual srcset implementations.

Tested locally using yarn jest packages/docusaurus-eslint-plugin with all cases passing.

Related issues/PRs

@meta-cla
Copy link

meta-cla bot commented Feb 11, 2026

Hi @Azurinine!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link

netlify bot commented Feb 11, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 27a484a
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/698c32d7683b4600084f3efe
😎 Deploy Preview https://deploy-preview-11730--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla
Copy link

meta-cla bot commented Feb 11, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Feb 11, 2026
@Azurinine Azurinine changed the title Feat/prefer ideal image feat: prefer ideal image Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create ESLint plugin rules to enforce best Docusaurus practices

1 participant