Skip to content
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

Add rule "Prefer lighter formats for image files" #46

Conversation

anthony-o
Copy link
Contributor

Fixing #35

Co-authored-by: Lucas Leroux <[email protected]>
Co-authored-by: Vincent-Letourmy <[email protected]>
@utarwyn utarwyn marked this pull request as ready for review February 1, 2025 13:43
@utarwyn utarwyn self-requested a review February 1, 2025 13:43
@utarwyn utarwyn added 🗃️ rule Impacts a rule 🏆 challenge 🏆 Work done during the ecoCode Challenge labels Feb 1, 2025
Comment on lines 60 to 67
if (dotIndex === -1) {
context.report({
node,
messageId: "DefineFormatsForImageFiles",
data: { eligibleExtensions: eligibleExtensions.join(", ") },
});
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

To avoid any false-positive report, I propose to remove this check.

If the source filename does not have an extension, we can't know which format the file uses. Some cloud/storage services does not use extensions in URL but are sending a content-type header instead. In this case we do not want to warn the developer because the best practice may be respected.

Comment on lines 83 to 84
- https://greenspector.com/en/which-image-format-to-choose-to-reduce-its-energy-consumption-and-its-environmental-impact/[greenspector.com - Which image format choose to reduce energy consumption and environmental impact?]
- https://dodonut.com/blog/use-cases-of-web-image-formats/[dodonut.com - The Most Efficient Web Image Formats. Use Cases For Different Types Of Images.]
Copy link
Member

Choose a reason for hiding this comment

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

There are some issues with the Markdown format here

@utarwyn utarwyn force-pushed the ec31-prefer-lighter-formats-for-image-files branch 3 times, most recently from 8cba468 to 36b9f82 Compare February 2, 2025 11:20
@utarwyn utarwyn force-pushed the ec31-prefer-lighter-formats-for-image-files branch from 36b9f82 to 0e185f1 Compare February 2, 2025 11:33
@utarwyn
Copy link
Member

utarwyn commented Feb 2, 2025

@dedece35 I have reworked the implementation of this rule. So this PR is ready to be included in the JavaScript plugin.
Sound good for you too? That will unblock the other tickets on the subject, won't it?

@utarwyn utarwyn merged commit 3360ca3 into green-code-initiative:main Feb 3, 2025
3 checks passed
@utarwyn utarwyn linked an issue Feb 3, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏆 challenge 🏆 Work done during the ecoCode Challenge 🗃️ rule Impacts a rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement rule "Prefer lighter formats for image files"
3 participants