-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add avoid-keep-awake asciidoc and json
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
:!sectids: | ||
|
||
== Why is this an issue? | ||
|
||
To avoid draining the battery, an Android device that is left idle quickly falls asleep. | ||
Hence, keeping the screen on should be avoided, unless it is absolutely necessary. | ||
|
||
== Example of non compliant code | ||
|
||
```js | ||
export default function KeepAwakeExample() { | ||
useKeepAwake(); // Non compliant | ||
return ( | ||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | ||
<Text>This screen will never sleep!</Text> | ||
</View> | ||
); | ||
} | ||
``` | ||
|
||
```js | ||
_activate = () => { | ||
activateKeepAwake(); // Non-compliant | ||
alert('Activated!'); | ||
}; | ||
``` |
13 changes: 13 additions & 0 deletions
13
ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"tags": [ | ||
"sobriety", | ||
"environment", | ||
"ecocode", | ||
"react-native", | ||
"eco-design" | ||
], | ||
"compatibleLanguages": [ | ||
"JAVASCRIPT", | ||
"TYPESCRIPT" | ||
] | ||
} |