Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 1.06 KB

avoid-keep-awake.md

File metadata and controls

40 lines (28 loc) · 1.06 KB

Avoid screen keep awake (@creedengo/avoid-keep-awake)

⚠️ This rule warns in the ✅ recommended config.

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.

Note: This rule currently only supports detecting expo-keep-awake package usage. Support for other keep-awake packages may be added in future versions.

import { useKeepAwake } from "expo-keep-awake";

export default function KeepAwakeExample() {
  useKeepAwake(); // Non compliant
  return (
    <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
      <Text>This screen will never sleep!</Text>
    </View>
  );
}
import { activateKeepAwake } from "expo-keep-awake";

_activate = () => {
  activateKeepAwake(); // Non-compliant
  alert("Activated!");
};

Resources

Documentation