Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:

strategy:
matrix:
node-version: [18.x, 24.x]
java-version: [11]
node-version: [22.x, 24.x]
java-version: [17]

steps:
- name: Checkout
Expand Down Expand Up @@ -78,11 +78,11 @@ jobs:
with:
node-version: 24.x

- name: Use JDK 11
- name: Use JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Install dependencies
run: yarn install --immutable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions:

env:
NODE_VERSION: 24.x
JDK_VERSION: 11
JDK_VERSION: 17

jobs:
release:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Editors & OS
.DS_Store
.idea
.vscode
.project
.settings/
bin/
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eslint.workingDirectories": ["./eslint-plugin", "./test-project"]
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- [#99](https://github.com/green-code-initiative/creedengo-javascript/pull/99) Add SonarQube Community 25.12+ and SonarQube 2025.6+ support

### Removed

- [#99](https://github.com/green-code-initiative/creedengo-javascript/pull/99) Remove ESLint v7/v8 support
- [#99](https://github.com/green-code-initiative/creedengo-javascript/pull/99) Remove ESLint flat-specific configuration
- [#99](https://github.com/green-code-initiative/creedengo-javascript/pull/99) Remove SonarQube Community < 25.12, SonarQube < 2025.6 support
- [#99](https://github.com/green-code-initiative/creedengo-javascript/pull/99) Remove Node.js < 22 support

## [2.2.0] - 2026-01-15

### Added
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ clean:
cd sonar-plugin && mvn clean

build: clean
cd sonar-plugin && mvn package -DskipTests
cd sonar-plugin && mvn package

compile: clean
cd sonar-plugin && mvn compile
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ The standalone version of the ESLint plugin is available from [npmjs](https://np

## 🧩 Compatibility

| Plugins Version | SonarQube version | ESLint version |
| --------------- | ----------------- | -------------- |
| 2.2+ | 9.9.+ LTA to 25.8 | 7.x, 8.x, 9.x |
| 2.0, 2.1 | 9.9.+ LTA to 25.8 | 7.x, 8.x |
| 1.4, 1.5 | 9.9.+ LTA to 10.7 | 7.x, 8.x |
| Plugins Version | SonarQube Community version | SonarQube Server version | ESLint version |
| --------------- | --------------------------- | ------------------------ | -------------- |
| 3+ | 25.12+ | 2025.6+ | 9.x |
| 2.2 | 9.9 to 25.8 | 9.9 to 2025.4 LTA | 7.x, 8.x, 9.x |
| 2.0, 2.1 | 9.9 to 25.8 | 9.9 to 2025.4 LTA | 7.x, 8.x |

## 🤝 Contribution

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: sonarqube_creedengo_javascript

services:
sonar:
image: sonarqube:25.8.0.112029-community
image: sonarqube:26.1.0.118079-community
container_name: sonar_creedengo_javascript
ports:
- "9000:9000"
Expand Down
25 changes: 19 additions & 6 deletions eslint-plugin/.eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
/*
* creedengo JavaScript plugin - Provides rules to reduce the environmental footprint of your JavaScript programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

"use strict";

/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
configEmoji: [["flat/recommended", "✅"]],
postprocess: (doc) => {
return doc.replace(/✅\s*✅/gu, "✅");
},
};
const config = {};

module.exports = config;

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion eslint-plugin/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.9.1.cjs
yarnPath: .yarn/releases/yarn-4.12.0.cjs
75 changes: 23 additions & 52 deletions eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An ESLint plugin which provides JavaScript and TypeScript rules of the Creedengo

### Installation

You'll need to install [ESLint](https://eslint.org/) (v7+) and this plugin:
You'll need to install [ESLint](https://eslint.org/) v9 and this plugin:

```sh
# yarn
Expand All @@ -34,33 +34,19 @@ npm install -D eslint @green-code-initiative/creedengo-eslint-plugin

### Enable plugin with recommended configuration

#### ESLint Flat Configuration (`eslint.config.js`)

Add `@creedengo` **"flat/recommended"** configuration to your `eslint.config.js`:
Add `@creedengo` **"recommended"** configuration to your `eslint.config.js`:

```js
import creedengo from "@creedengo/eslint-plugin";

export default [
/* other eslint configurations */
creedengo.configs["flat/recommended"],
creedengo.configs.recommended,
];
```

#### ESLint deprecated legacy configuration (`.eslintrc`)

For legacy ESLint versions using the deprecated `.eslintrc` file, add the `@creedengo` **"recommended"** configuration to the `extends` array :

```json
{
"extends": ["plugin:@creedengo/recommended"]
}
```

### Enable specific rules

#### ESLint Flat configuration (`eslint.config.js`)

Add the `creedengo` plugin configuration to your `eslint.config.js` and select the rules to activate:

```js
Expand All @@ -77,27 +63,13 @@ export default [
];
```

#### ESLint deprecated legacy configuration (`.eslintrc`)

If your project uses a legacy ESLint version, it may use as well the now deprecated `.eslintrc` file. In such case, add `@creedengo` to the `plugins` array, potentially followed by rules specific configurations:

```jsonc
{
"plugins": ["@creedengo"],
"rules": {
"@creedengo/no-multiple-access-dom-element": "error",
},
}
```

## ⚙ Configs

<!-- begin auto-generated configs list -->

| | Name |
| :- | :----------------- |
| ✅ | `flat/recommended` |
| ✅ | `recommended` |
| | Name |
| :- | :------------ |
| ✅ | `recommended` |

<!-- end auto-generated configs list -->

Expand All @@ -106,26 +78,25 @@ If your project uses a legacy ESLint version, it may use as well the now depreca
<!-- begin auto-generated rules list -->

⚠️ Configurations set to warn in.\
✅ Set in the `flat/recommended` configuration.\
✅ Set in the `recommended` configuration.

| Name | Description | ⚠️ |
| :--------------------------------------------------------------------------------------------- | :-------------------------------------------------------- | :-- |
| [avoid-autoplay](docs/rules/avoid-autoplay.md) | Avoid autoplay for videos and audio content | ✅ |
| [avoid-brightness-override](docs/rules/avoid-brightness-override.md) | Should avoid to override brightness | ✅ |
| [avoid-css-animations](docs/rules/avoid-css-animations.md) | Avoid usage of CSS animations | ✅ |
| [avoid-high-accuracy-geolocation](docs/rules/avoid-high-accuracy-geolocation.md) | Avoid using high accuracy geolocation in web applications | ✅ |
| [avoid-keep-awake](docs/rules/avoid-keep-awake.md) | Avoid screen keep awake | ✅ |
| [limit-db-query-results](docs/rules/limit-db-query-results.md) | Should limit the number of returns for a SQL query | ✅ |
| [no-empty-image-src-attribute](docs/rules/no-empty-image-src-attribute.md) | Disallow usage of image with empty source attribute | ✅ |
| [no-import-all-from-library](docs/rules/no-import-all-from-library.md) | Should not import all from library | ✅ |
| [no-multiple-access-dom-element](docs/rules/no-multiple-access-dom-element.md) | Disallow multiple access of same DOM element | ✅ |
| [no-multiple-style-changes](docs/rules/no-multiple-style-changes.md) | Disallow multiple style changes at once | ✅ |
| [no-torch](docs/rules/no-torch.md) | Should not programmatically enable torch mode | ✅ |
| [prefer-collections-with-pagination](docs/rules/prefer-collections-with-pagination.md) | Prefer API collections with pagination | ✅ |
| [prefer-lighter-formats-for-image-files](docs/rules/prefer-lighter-formats-for-image-files.md) | Prefer lighter formats for image files | ✅ |
| [prefer-shorthand-css-notations](docs/rules/prefer-shorthand-css-notations.md) | Encourage usage of shorthand CSS notations | ✅ |
| [provide-print-css](docs/rules/provide-print-css.md) | Enforce providing a print stylesheet | ✅ |
| Name | Description | ⚠️ |
| :--------------------------------------------------------------------------------------------- | :-------------------------------------------------------- | :- |
| [avoid-autoplay](docs/rules/avoid-autoplay.md) | Avoid autoplay for videos and audio content | ✅ |
| [avoid-brightness-override](docs/rules/avoid-brightness-override.md) | Should avoid to override brightness | ✅ |
| [avoid-css-animations](docs/rules/avoid-css-animations.md) | Avoid usage of CSS animations | ✅ |
| [avoid-high-accuracy-geolocation](docs/rules/avoid-high-accuracy-geolocation.md) | Avoid using high accuracy geolocation in web applications | ✅ |
| [avoid-keep-awake](docs/rules/avoid-keep-awake.md) | Avoid screen keep awake | ✅ |
| [limit-db-query-results](docs/rules/limit-db-query-results.md) | Should limit the number of returns for a SQL query | ✅ |
| [no-empty-image-src-attribute](docs/rules/no-empty-image-src-attribute.md) | Disallow usage of image with empty source attribute | ✅ |
| [no-import-all-from-library](docs/rules/no-import-all-from-library.md) | Should not import all from library | ✅ |
| [no-multiple-access-dom-element](docs/rules/no-multiple-access-dom-element.md) | Disallow multiple access of same DOM element | ✅ |
| [no-multiple-style-changes](docs/rules/no-multiple-style-changes.md) | Disallow multiple style changes at once | ✅ |
| [no-torch](docs/rules/no-torch.md) | Should not programmatically enable torch mode | ✅ |
| [prefer-collections-with-pagination](docs/rules/prefer-collections-with-pagination.md) | Prefer API collections with pagination | ✅ |
| [prefer-lighter-formats-for-image-files](docs/rules/prefer-lighter-formats-for-image-files.md) | Prefer lighter formats for image files | ✅ |
| [prefer-shorthand-css-notations](docs/rules/prefer-shorthand-css-notations.md) | Encourage usage of shorthand CSS notations | ✅ |
| [provide-print-css](docs/rules/provide-print-css.md) | Enforce providing a print stylesheet | ✅ |

<!-- end auto-generated rules list -->

Expand Down
22 changes: 11 additions & 11 deletions eslint-plugin/docs/rules/avoid-autoplay.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Avoid autoplay for videos and audio content (`@creedengo/avoid-autoplay`)
# @creedengo/avoid-autoplay

⚠️ This rule _warns_ in the following configs: ✅ `flat/recommended`, ✅ `recommended`.
📝 Avoid autoplay for videos and audio content.

⚠️ This rule _warns_ in the ✅ `recommended` config.

<!-- end auto-generated rule header -->

Expand All @@ -17,13 +19,13 @@ browsers not to preload anything by setting the `preload` attribute to `none`.

```jsx
return (
<>
<video src="video.mp4" autoplay/> // Non-compliant
<video src="video.mp4" preload="auto"/> // Non-compliant
<video src="video.mp4" autoplay preload="auto"/> // Non-compliant
<video src="video.mp4" preload="none"/> // Compliant
</>
)
<>
<video src="video.mp4" autoplay /> // Non-compliant
<video src="video.mp4" preload="auto" /> // Non-compliant
<video src="video.mp4" autoplay preload="auto" /> // Non-compliant
<video src="video.mp4" preload="none" /> // Compliant
</>
);
```

This rule is build for [React](https://react.dev/) and JSX.
Expand All @@ -40,5 +42,3 @@ This rule is build for [React](https://react.dev/) and JSX.
Preload in HTML
- [W3C](https://w3c.github.io/sustyweb/star.html#UX16-1) - Autoplay attribute
- [RGESN](https://www.arcep.fr/mes-demarches-et-services/entreprises/fiches-pratiques/referentiel-general-ecoconception-services-numeriques.html) - Reference Rule 4.1


33 changes: 18 additions & 15 deletions eslint-plugin/docs/rules/avoid-brightness-override.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Should avoid to override brightness (`@creedengo/avoid-brightness-override`)
# @creedengo/avoid-brightness-override

⚠️ This rule _warns_ in the following configs: ✅ `flat/recommended`, ✅ `recommended`.
📝 Should avoid to override brightness.

⚠️ This rule _warns_ in the ✅ `recommended` config.

<!-- end auto-generated rule header -->

Expand All @@ -12,25 +14,26 @@ For some reasons, developers may disable this feature programmatically.

This feature was introduced to improve battery life, be careful when deactivating it.

Hence, keeping forcing the screen brightness on should be avoided, unless it is absolutely necessary.

Hence, keeping forcing the screen brightness on should be avoided, unless it is absolutely necessary.

## Example of non compliant code

```js
// Example with expo-brightness (Expo framework library)
import React, { useEffect } from 'react';
import { View, Text } from 'react-native';
import * as Brightness from 'expo-brightness';
import React, { useEffect } from "react";
import { View, Text } from "react-native";
import * as Brightness from "expo-brightness";

export default function App() {
useEffect(() => {
(async () => { Brightness.setSystemBrightnessAsync(1); })(); // Brightness is forced here
}, []);
return (
<View>
<Text>Brightness Module Example</Text>
</View>
);
useEffect(() => {
(async () => {
Brightness.setSystemBrightnessAsync(1);
})(); // Brightness is forced here
}, []);
return (
<View>
<Text>Brightness Module Example</Text>
</View>
);
}
```
6 changes: 4 additions & 2 deletions eslint-plugin/docs/rules/avoid-css-animations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Avoid usage of CSS animations (`@creedengo/avoid-css-animations`)
# @creedengo/avoid-css-animations

⚠️ This rule _warns_ in the following configs: ✅ `flat/recommended`, ✅ `recommended`.
📝 Avoid usage of CSS animations.

⚠️ This rule _warns_ in the ✅ `recommended` config.

<!-- end auto-generated rule header -->

Expand Down
Loading