diff --git a/ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.asciidoc b/ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.asciidoc new file mode 100644 index 00000000..05f67795 --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.asciidoc @@ -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 ( + + This screen will never sleep! + + ); +} +``` + +```js +_activate = () => { + activateKeepAwake(); // Non-compliant + alert('Activated!'); + }; +``` \ No newline at end of file diff --git a/ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.json b/ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.json new file mode 100644 index 00000000..936cf1cc --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.json @@ -0,0 +1,13 @@ +{ + "tags": [ + "sobriety", + "environment", + "ecocode", + "react-native", + "eco-design" + ], + "compatibleLanguages": [ + "JAVASCRIPT", + "TYPESCRIPT" + ] + } \ No newline at end of file