Skip to content

Commit 049e839

Browse files
utarwynDESKTOP-J99B7TH\Gilbert
and
DESKTOP-J99B7TH\Gilbert
authored
Porting GCI505 rule to JavaScript (#372)
Signed-off-by: utarwyn <[email protected]> Co-authored-by: DESKTOP-J99B7TH\Gilbert <[email protected]>
1 parent a315c2d commit 049e839

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- [#333](https://github.com/green-code-initiative/creedengo-rules-specifications/pull/333) Add JS variant of rule GCI505 - Idleness: Keep Screen On (addFlags)
13+
1214
### Changed
1315

1416
- [#320](https://github.com/green-code-initiative/creedengo-rules-specifications/pull/320) Doc improvement : some method calls are legitimate in a for loop expression.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
:!sectids:
2+
3+
== Why is this an issue?
4+
5+
To avoid draining the battery, an Android device that is left idle quickly falls asleep.
6+
Hence, keeping the screen on should be avoided, unless it is absolutely necessary.
7+
8+
== Example of non compliant code
9+
10+
```js
11+
export default function KeepAwakeExample() {
12+
useKeepAwake(); // Non compliant
13+
return (
14+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
15+
<Text>This screen will never sleep!</Text>
16+
</View>
17+
);
18+
}
19+
```
20+
21+
```js
22+
_activate = () => {
23+
activateKeepAwake(); // Non-compliant
24+
alert('Activated!');
25+
};
26+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tags": [
3+
"idleness",
4+
"environment",
5+
"creedengo",
6+
"react-native",
7+
"eco-design"
8+
],
9+
"compatibleLanguages": ["JAVASCRIPT", "TYPESCRIPT"]
10+
}

0 commit comments

Comments
 (0)