Skip to content

Add rule no-imported-number-format-library (GCI535) - #84

Merged
utarwyn merged 8 commits into
green-code-initiative:mainfrom
Nephtys:challenge-int-format
May 18, 2026
Merged

utarwyn merged 8 commits into
green-code-initiative:mainfrom
Nephtys:challenge-int-format

Conversation

@Nephtys

@Nephtys Nephtys commented May 20, 2025 •

Copy link
Copy Markdown
Contributor

Importing an external library for lightweight operations increases overall size of the program.
Using native methods instead reduces the amount of memory and storage to run and store the application.
This is especially critical in environments with limited resources, such as on mobile devices or in web applications
where bandwidth and download times matter.

Smaller programs generally have better runtime performance.
Reducing the number of unnecessary modules minimizes the amount of code that needs to be interpreted or compiled,
leading to faster execution and improved overall performance.

It also increases the maintainability and security of your program by depending on less external dependencies.

@Nephtys
Nephtys force-pushed the challenge-int-format branch 2 times, most recently from 561fd15 to 80cfc07 Compare May 20, 2025 16:02
@Nephtys Nephtys changed the title Add rule GCI1433 "No imported number format library" Add rule GCI1433 "No imported number format library" #TERRE May 21, 2025
@Nephtys Nephtys changed the title Add rule GCI1433 "No imported number format library" #TERRE GCI1433[TERRE][2025] Add rule GCI1433 "No imported number format library" May 21, 2025
@fbezagu
fbezagu force-pushed the challenge-int-format branch from a635200 to b93f455 Compare May 21, 2025 13:02
@Nephtys Nephtys changed the title GCI1433[TERRE][2025] Add rule GCI1433 "No imported number format library" GCI535[TERRE][2025] Add rule GCI1433 "No imported number format library" May 21, 2025
@Nephtys Nephtys changed the title GCI535[TERRE][2025] Add rule GCI1433 "No imported number format library" GCI535[TERRE][2025] Add rule GCI535 "No imported number format library" May 21, 2025
@fbezagu
fbezagu force-pushed the challenge-int-format branch from b93f455 to 634590d Compare May 21, 2025 13:10
@utarwyn
utarwyn marked this pull request as ready for review May 18, 2026 13:51
@utarwyn utarwyn changed the title GCI535[TERRE][2025] Add rule GCI535 "No imported number format library" Add rule @creedengo/no-imported-number-format-library GCI535 "No imported number format library" May 18, 2026
@utarwyn utarwyn changed the title Add rule @creedengo/no-imported-number-format-library GCI535 "No imported number format library" Add rule no-imported-number-format-library (GCI535) May 18, 2026
@utarwyn
utarwyn requested review from Copilot and utarwyn May 18, 2026 13:57
@utarwyn utarwyn moved this from In Progress to Ready To Review in Hackathon kanban - JS/TS May 18, 2026
@utarwyn utarwyn moved this from Ready To Review to Review in progress in Hackathon kanban - JS/TS May 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new eco-design lint rule (GCI535) to discourage using external number-formatting libraries for lightweight formatting tasks, preferring native Intl.NumberFormat, and wires the rule into the Sonar JavaScript profile and project documentation.

Changes:

  • Added ESLint rule @creedengo/no-imported-number-format-library with unit tests and documentation.
  • Added Sonar hook class NoImportedNumberFormatLibrary and registered it in CheckList.
  • Enabled rule key GCI535 in the Sonar JavaScript profile and added a test-project example + changelog entry.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test-project/src/no-imported-number-format-library.js Adds sample compliant/non-compliant code for the new rule.
sonar-plugin/src/main/resources/org/greencodeinitiative/creedengo/profiles/javascript_profile.json Activates GCI535 in the JS profile.
sonar-plugin/src/main/java/org/greencodeinitiative/creedengo/javascript/checks/NoImportedNumberFormatLibrary.java Adds Sonar EslintHook mapping for the new rule key.
sonar-plugin/src/main/java/org/greencodeinitiative/creedengo/javascript/CheckList.java Registers the new hook in the Sonar plugin checklist.
eslint-plugin/tests/lib/rules/no-imported-number-format-library.test.js Adds ESLint RuleTester coverage for the new rule.
eslint-plugin/README.md Documents the new rule in the rules table.
eslint-plugin/lib/rules/no-imported-number-format-library.js Implements the new ESLint rule logic (numbro/numerable detection).
eslint-plugin/docs/rules/no-imported-number-format-library.md Adds rule documentation and examples.
CHANGELOG.md Adds an Unreleased changelog entry for GCI535.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread eslint-plugin/lib/rules/no-imported-number-format-library.js Outdated
Comment thread eslint-plugin/lib/rules/no-imported-number-format-library.js
Comment thread eslint-plugin/docs/rules/no-imported-number-format-library.md Outdated
Comment thread eslint-plugin/tests/lib/rules/no-imported-number-format-library.test.js Outdated
Comment thread eslint-plugin/docs/rules/no-imported-number-format-library.md Outdated
@utarwyn
utarwyn force-pushed the challenge-int-format branch from 2b67b88 to 2324c44 Compare May 18, 2026 14:22
@utarwyn utarwyn added the 🗃️ rule Impacts a rule label May 18, 2026
@utarwyn
utarwyn merged commit 21dc372 into green-code-initiative:main May 18, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Review in progress to Done in Hackathon kanban - JS/TS May 18, 2026
@utarwyn utarwyn linked an issue May 18, 2026 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

🗃️ rule Impacts a rule

Projects

Development

Successfully merging this pull request may close these issues.

Add rule "Use native Intl.NumberFormat to format numbers"

3 participants