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

Use centralized rules specifications #16

Merged
merged 3 commits into from
Jul 20, 2023
Merged
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

- [#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

### Changed
Expand Down
Binary file not shown.
23 changes: 19 additions & 4 deletions eslint-plugin/docs/rules/no-import-all-from-library.md
utarwyn marked this conversation as resolved.
Show resolved Hide resolved
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.