Skip to content

Commit

Permalink
Merge pull request #16 from green-code-initiative/feature-rules-speci…
Browse files Browse the repository at this point in the history
…fication

Use centralized rules specifications
  • Loading branch information
utarwyn authored Jul 20, 2023
2 parents 0302ef8 + f553404 commit ea5096c
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 285 deletions.
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

- [#14](https://github.com/green-code-initiative/ecoCode-javascript/pull/14) Create SonarQube plugin
- [#12](https://github.com/green-code-initiative/ecoCode-javascript/issues/12) Pack ESLint plugin into SonarQube plugin
- [#16](https://github.com/green-code-initiative/ecoCode-javascript/pull/16) Use centralized rules specifications
- Backport all existing rules into SonarQube plugin
- [#207](https://github.com/green-code-initiative/ecoCode/issues/207) Add release tag analyzis on SonarCloud

Expand Down
Binary file not shown.
23 changes: 19 additions & 4 deletions eslint-plugin/docs/rules/no-import-all-from-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ This rule aims to reduce weight of programs by using only needed modules. Many l
default, but some of them are exporting ES modules or submodules. We should use them to select more precisly needed
modules and avoid unnecessarily overloading files weight.

![Example with lodash](https://raw.githubusercontent.com/green-code-initiative/ecoCode-linter/main/eslint-plugin/docs/images/no-import-all-from-library.jpg)

*Example with the well-known [lodash](https://lodash.com/) library, if you only need "isEmpty" method.*

## Options

You can externally add your own libraries to be checked.
Expand Down Expand Up @@ -48,6 +44,15 @@ import * as lodash from "lodash";
import _ from "underscore";
```

**Size of your bundle, if you use the whole lodash library:**

* **index.js - 531.46 KB**
* node_modules/lodash - 531.35 KB
* lodash.js - 531.35 KB
* index.js - 112 B

---

Examples of **compliant** code for this rule:

```js
Expand All @@ -58,3 +63,13 @@ import intersect from "lodash/intersect";
// Example with underscore (uses esm modules)
import map from "underscore/modules/map.js";
```

Size of your bundle, if you use only the "isEmpty" method:

* **index.js - 24.42 KB**
* node_modules/lodash - 24.31 KB
* isEmpty - 1.95 KB
* _nodeUtil.js - 995 B
* isArrayLike.js - 830 B
* ...
* index.js - 110 B
8 changes: 8 additions & 0 deletions sonar-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>

<ecocode-rules-specifications.version>0.0.1</ecocode-rules-specifications.version>
<sonarqube.version>9.4.0.54424</sonarqube.version>
<sonar-javascript.version>9.13.0.20537</sonar-javascript.version>
<sonar-packaging.version>1.21.0.505</sonar-packaging.version>
Expand All @@ -64,6 +65,13 @@

<dependencies>

<dependency>
<groupId>io.ecocode</groupId>
<artifactId>ecocode-rules-specifications</artifactId>
<version>${ecocode-rules-specifications.version}</version>
<classifier>javascript</classifier>
</dependency>

<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit ea5096c

Please sign in to comment.