From e734aab04b844c611b5bdb9ffcf02dcf7dbc80a0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-J99B7TH\\Gilbert" Date: Thu, 30 May 2024 14:36:20 +0200 Subject: [PATCH] Add avoid-keep-awake asciidoc and json --- .../rules/EC505/javascript/EC505.asciidoc | 26 +++++++++++++++++++ .../main/rules/EC505/javascript/EC505.json | 13 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.asciidoc create mode 100644 ecocode-rules-specifications/src/main/rules/EC505/javascript/EC505.json 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