Skip to content

Commit e4ce6f1

Browse files
authored
Integrate the test project alongside the plugin (#79)
1 parent e3f35d2 commit e4ce6f1

33 files changed

+4081
-940
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- [#51](https://github.com/green-code-initiative/creedengo-javascript/pull/51) Add ESLint v9 and flat config support
1313

14+
### Changed
15+
16+
- [#79](https://github.com/green-code-initiative/creedengo-javascript/pull/79) Integrate the test project alongside the plugin
17+
1418
## [2.1.0] - 2025-03-31
1519

1620
### Added

CONTRIBUTING.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ have the basic information before starting.
88

99
## Structure
1010

11-
The JavaScript plugin is divided into 2 modules:
11+
The JavaScript plugin is divided into 3 modules:
1212

1313
- `eslint-plugin` contains the ESLint plugin part
1414
- `sonar-plugin` contains the SonarQube plugin implementation
15+
- `test-project` contains a project to test the rules on SonarQube
1516

1617
The ESLint plugin **can be standalone** and is packed inside SonarQube plugin during the build phase.
1718

@@ -96,6 +97,12 @@ To display tests coverage, use `yarn run test:cov`.
9697

9798
> ℹ You don't need to add a test in the Sonar plugin, the class will be tested automatically.
9899
100+
### Add an integration test
101+
102+
It is also necessary to add an example of non-compliant code to the test project in the
103+
repository. This allows to check that the plgin works correctly with a real
104+
SonarQube instance. A README is present in `test-project` directory to help running a local analysis.
105+
99106
### Generate rule documentation
100107

101108
A tool called [eslint-doc-generator](https://github.com/bmish/eslint-doc-generator) is used in the project to update
@@ -110,9 +117,17 @@ Two npm scripts are available:
110117
All the generated code is between commented lines with "auto-generated" in the text.\
111118
**Please run update script** after a rule creation.
112119

113-
## End of development?
120+
## What else?
121+
122+
You should be ready to open a PR on GitHub with all your code!
123+
124+
Check one last time that you have respected the following points:
114125

115-
The last step is to open a PR on this project with the implementation of the rule, and a second one on the test
116-
project with an exemple of a code not following rule needs. Keep an eye on the coverage of your rule implementation 👀
126+
- [ ] My rule implementation covers the use case without false-positive
127+
- [ ] My code is explicit or well documented
128+
- [ ] I have provided unit tests
129+
- [ ] I have added a non-compliant example code inside the test project
130+
- [ ] The coverage of my code is greather than 80%
131+
- [ ] I have modified the CHANGELOG with my change
117132

118133
This is the end of this guide, thank you for reading this far and contributing to the project 🙏.

eslint-plugin/.yarn/releases/yarn-4.6.0.cjs

Lines changed: 0 additions & 934 deletions
This file was deleted.

eslint-plugin/.yarn/releases/yarn-4.9.1.cjs

Lines changed: 948 additions & 0 deletions
Large diffs are not rendered by default.

eslint-plugin/.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ enableGlobalCache: false
44

55
nodeLinker: node-modules
66

7-
yarnPath: .yarn/releases/yarn-4.6.0.cjs
7+
yarnPath: .yarn/releases/yarn-4.9.1.cjs

eslint-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@
5555
"peerDependencies": {
5656
"eslint": ">= 7 < 10"
5757
},
58-
"packageManager": "yarn@4.6.0"
58+
"packageManager": "yarn@4.9.1"
5959
}

test-project/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Yarn
2+
.pnp.*
3+
.yarn/*
4+
!.yarn/patches
5+
!.yarn/plugins
6+
!.yarn/releases
7+
!.yarn/sdks
8+
!.yarn/versions
9+
node_modules
10+
11+
# Auto-generated files
12+
*-report.json
13+
.nyc_output
14+
.scannerwork

test-project/.yarn/releases/yarn-4.9.1.cjs

Lines changed: 948 additions & 0 deletions
Large diffs are not rendered by default.

test-project/.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-4.9.1.cjs

test-project/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
A sample project to test SonarQube and ESLint plugins of **creedengo-javascript**.
2+
3+
👉 See [creedengo-javascript README](../README.md) to have more information.
4+
5+
## Purpose of this project
6+
7+
This project allows to test the rules edited by the ecoCode project for the JavaScript language.\
8+
The files in this repository contain both compliant and non-compliant code.
9+
10+
### 1. Setup local environment
11+
12+
First, follow [this complete guide](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/HOWTO.md#installing-local-environment-local-sonarqube) to install your local SonarQube development environment. \
13+
Then, check that _creedengo_ rules are enabled in the quality profile that will be used during the analysis.
14+
15+
You will also need some JavaScript tools installed on your computer:
16+
17+
- A supported version of Node.js
18+
- Yarn (install it globally with `npm install -g yarn`)
19+
20+
### 2. Send Sonar metrics to local SonarQube
21+
22+
Use the following Shell script which will do the job for you:
23+
24+
```sh
25+
./tool_send_to_sonar.sh MY_SONAR_TOKEN
26+
```
27+
28+
Or you can manually run these commands:
29+
30+
- Install dependencies: `yarn install`
31+
- Start Sonar Scanner: `yarn sonar -Dsonar.token=MY_SONAR_TOKEN`
32+
33+
### 3. Check errors
34+
35+
On your SonarQube instance, check if each JavaScript file contains the rule error defined for this class (you can search for tag `eco-design` rule on a special file).

0 commit comments

Comments
 (0)