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" #269

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

utarwyn
Copy link
Member

@utarwyn utarwyn commented Jan 8, 2024

Hello,
I want to propose a new rule in the ecoCode repository. You can find its declaration below.
What do you think of it?

Platform

JavaScript (React / JSX) and HTML in the future

Main caracteristics

ID Title Category
EC31 Prefer lighter formats for image files Network, Power consumption

Severity / Remediation Cost

I propose a remediation cost of 5min per image, in order to convert it to another format, based on needs.

Severity Remediation Cost
Minor 5min

Rule complete description

Check asciidoc in the PR content.

Implementation principle

  • Check for file extensions used in <img /> elements
  • Also check for imported files in the JavaScript/TypeScript code
  • Do not check for <img /> elements inside <picture> elements, because its used to support multiple formats (to support older browsers for example)

@utarwyn utarwyn added the 🗃️ rule rule improvment or rule development or bug label Jan 8, 2024
@utarwyn utarwyn self-assigned this Jan 8, 2024
@dedece35
Copy link
Member

dedece35 commented Jan 9, 2024

Hi @utarwyn,
I think it's a good idea but do you check if there isn't this kind of rule in Sonarqube or in other existing rules ?
@olegoaer, a point of view ?

@utarwyn
Copy link
Member Author

utarwyn commented Jan 9, 2024

@dedece35
I've checked: this rule does not appear in the list of rules proposed by SonarQube. However, this rule limits the image formats that can be used to reduce the carbon footprint of a website, so it's probably too "restrictive" for them and not about clean code.

@olegoaer
Copy link
Member

Indeed. .webp and .avif are best formats on website (see this study)

This rule is clearly about green code, not clean code :)

@utarwyn
Copy link
Member Author

utarwyn commented Jan 31, 2024

Thank you for the feedback! I will add this reference into rule documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗃️ rule rule improvment or rule development or bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants