Skip to content

Commit 1cb9478

Browse files
authored
Add EC522 to javascript (#321)
1 parent 370ffc1 commit 1cb9478

6 files changed

Lines changed: 63 additions & 9 deletions

File tree

CHANGELOG.md

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

1212
- [#315](https://github.com/green-code-initiative/ecoCode/pull/315) Add rule EC530 for javascript
13+
- [#321](https://github.com/green-code-initiative/ecoCode/pull/321) Add rule EC522 for javascript (avoid brightness override)
1314

1415
### Changed
1516

ecocode-rules-specifications/src/main/rules/EC522/EC522.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
"func": "Constant\/Issue",
77
"constantCost": "20min"
88
},
9-
"tags": [
10-
"sobriety",
11-
"environment",
12-
"ecocode",
13-
"android",
14-
"ios",
15-
"eco-design"
16-
],
179
"ecoScore": "0.4",
1810
"defaultSeverity": "Minor"
19-
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tags": [
3+
"sobriety",
4+
"environment",
5+
"ecocode",
6+
"android",
7+
"eco-design"
8+
]
9+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
:!sectids:
2+
3+
== Why is this an issue?
4+
5+
To avoid draining the battery, iOS and Android devices adapt the brightness of the screen depending on the environment light.
6+
7+
For some reasons, developers may disable this feature programmatically.
8+
9+
This feature was introduced to improve battery life, be careful when deactivating it.
10+
11+
Hence, keeping forcing the screen brightness on should be avoided, unless it is absolutely necessary.
12+
13+
== Example of non compliant code
14+
15+
```js
16+
// Example with expo-brightness (Expo framework library)
17+
import React, { useEffect } from 'react';
18+
import { View, Text } from 'react-native';
19+
import * as Brightness from 'expo-brightness';
20+
21+
export default function App() {
22+
useEffect(() => {
23+
(async () => { Brightness.setSystemBrightnessAsyn(1); })(); // Brightness is forced here
24+
}, []);
25+
return (
26+
<View>
27+
<Text>Brightness Module Example</Text>
28+
</View>
29+
);
30+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"tags": [
3+
"sobriety",
4+
"environment",
5+
"ecocode",
6+
"react-native",
7+
"eco-design"
8+
],
9+
"compatibleLanguages": [
10+
"JAVASCRIPT",
11+
"TYPESCRIPT"
12+
]
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tags": [
3+
"sobriety",
4+
"environment",
5+
"ecocode",
6+
"ios",
7+
"eco-design"
8+
]
9+
}

0 commit comments

Comments
 (0)