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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#315](https://github.com/green-code-initiative/ecoCode/pull/315) Add rule EC530 for javascript
- [#321](https://github.com/green-code-initiative/ecoCode/pull/321) Add rule EC522 for javascript (avoid brightness override)
- [#335](https://github.com/green-code-initiative/ecoCode/pull/335) Implementing rule EC31 for javascript (prefer lighter formats for image files)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Some are applicable for different technologies.
| EC28 | Optimize read file exceptions | | | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 |
| EC29 | Avoid usage of CSS animations | ESLint key : @ecocode/avoid-css-animations /// type : Front-end | | ❓ | ❓ | ✅ | ❓ | ❓ | ❓ | 🚫 |
| EC30 | Provide a print stylesheet | ESLint key : @ecocode/provide-print-css /// type : Front-end | | ❓ | ❓ | ✅ | ❓ | ❓ | ❓ | 🚫 |
| EC31 | Prefer lighter formats for image files | ESLint key : ... /// type : ... | | ❓ | ❓ | 🚀 | ❓ | ❓ | ❓ | 🚀 |
| EC31 | Prefer lighter formats for image files | ESLint key : ... /// type : ... | | ❓ | ❓ | | ❓ | ❓ | ❓ | 🚀 |
| EC32 | Initialize builder/buffer with the appropriate size | If you know in advance how many characters would be appended, initialize builder/buffer with the appropriate size. They will thus never have to be resized. This saves CPU cycles and therefore consumes less energy. | | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 |
| EC35 | Using try...catch calls (on File Not Found error) | When an exception is thrown, a variable (the exception itself) is created in the catch block and destroyed at the end of the block. Creating this variable and destroying it consumes CPU cycles and RAM unnecessarily. That is why it is important not to use this construction and to prefer, as much as possible, a logical test. This new rule replace old EC34 only for a particular use case (FileNotFoundException) | [cnumr best practices (3rd edition) BP_047 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) | 🚫 | ✅ | 🚀 | ✅ | 🚀 | 🚫 | 🚫 |
| EC36 | Avoid autoplay for videos and audio content | Autoplaying media consumes unnecessary energy, especially when users might not be actively engaging with the content. | [cnumr best practices BP_4003](https://github.com/cnumr/best-practices/blob/main/chapters/BP_4003_en.md) | 🚫 | 🚫 | 🚀 | 🚫 | 🚫 | 🚫 | 🚧 |
Expand Down
Loading