Skip to content

Commit

Permalink
Update CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn committed Nov 10, 2023
1 parent 0f1262e commit 103fa20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- [#30](https://github.com/green-code-initiative/ecoCode-javascript/issues/30) Fix typo in EC12 rule

## [1.4.0] - 2023-10-30

### Added
Expand Down
27 changes: 17 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ But it can be useful to prepare a test project to check the correct execution of

1. Clone the Git repository
2. Run `yarn install` inside **eslint-plugin** directory
3. You are good to go! 🚀
3. Synchronize dependencies using Maven inside **sonar-plugin** directory
4. You are good to go! 🚀

## Create a rule

### Before starting

Before even starting to implement the rule, it must have been discussed, mesured and documented in the ecoCode
referential. Please follow
the [dedicated documentation](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/README.md)
to find out how to proceed.

### In the ESLint plugin

The file structure inside **eslint-plugin** package provides an ESLint-compliant project.\
Expand All @@ -66,16 +74,13 @@ The project itself uses ESLint to helps linting rule algorithms.

### In the SonarQube plugin

The SonarQube plugin does not contain the implementation of rules, only declarations and documentations.

Example set of files to add a rule called **"my-awesome-rule"** (SonarQube key: **EC1**):
Now that the rule has been implemented in the ecoCode referential and its implementation written in the ESLint plugin,
all that remains is to reference it in the SonarQube plugin. Here are the simple steps:

- `src/main/java/io/ecocode/javascript/checks/MyAwesomeRule.java`: declaration file with the SonarQube key and the
ESLint key
- `src/main/resources/rules/javascript/EC1.json`: detail of the rule for SonarQube
- `src/main/resources/rules/javascript/EC1.html`: documentation of the rule for SonarQube

You will also need to edit custom profile JSON file and `CheckList.java` to add your rule name in appropriate lists.
1. Create a Java class in `src/main/java/io/ecocode/javascript/checks/` with the declaration of the SonarQube key and
the ESLint key (check other classes to have an example)
2. Reference created in method `getAllChecks()` of Java class `CheckList` (please use alphabetical order)
3. Add the SonarQube key of the rule in the appropriate profile Json file.

### Test the rule

Expand All @@ -89,6 +94,8 @@ This will allow a large code coverage and avoid false positives.
Run the following script to start all test suites: `yarn run test`.\
To display tests coverage, use `yarn run test:cov`.

> ℹ You don't need to add a test in the Sonar plugin, the class will be tested automatically.
### Generate rule documentation

A tool called [eslint-doc-generator](https://github.com/bmish/eslint-doc-generator) is used in the project to update
Expand Down

0 comments on commit 103fa20

Please sign in to comment.