-
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.
- Loading branch information
Showing
11 changed files
with
117 additions
and
17 deletions.
There are no files selected for viewing
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
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
9 changes: 9 additions & 0 deletions
9
ecocode-rules-specifications/src/main/rules/EC522/java/EC522.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,9 @@ | ||
{ | ||
"tags": [ | ||
"sobriety", | ||
"environment", | ||
"ecocode", | ||
"android", | ||
"eco-design" | ||
] | ||
} |
30 changes: 30 additions & 0 deletions
30
ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.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,30 @@ | ||
:!sectids: | ||
|
||
== Why is this an issue? | ||
|
||
To avoid draining the battery, iOS and Android devices adapt the brightness of the screen depending on the environment light. | ||
|
||
For some reasons, developers may disable this feature programmatically. | ||
|
||
This feature was introduced to improve battery life, be careful when deactivating it. | ||
|
||
Hence, keeping forcing the screen brightness on should be avoided, unless it is absolutely necessary. | ||
|
||
== Example of non compliant code | ||
|
||
```js | ||
// Example with expo-brightness (Expo framework library) | ||
import React, { useEffect } from 'react'; | ||
import { View, Text } from 'react-native'; | ||
import * as Brightness from 'expo-brightness'; | ||
|
||
export default function App() { | ||
useEffect(() => { | ||
(async () => { Brightness.setSystemBrightnessAsyn(1); })(); // Brightness is forced here | ||
}, []); | ||
return ( | ||
<View> | ||
<Text>Brightness Module Example</Text> | ||
</View> | ||
); | ||
} |
13 changes: 13 additions & 0 deletions
13
ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.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" | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.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,9 @@ | ||
{ | ||
"tags": [ | ||
"sobriety", | ||
"environment", | ||
"ecocode", | ||
"ios", | ||
"eco-design" | ||
] | ||
} |
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
9 changes: 9 additions & 0 deletions
9
ecocode-rules-specifications/src/main/rules/EC530/java/EC530.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,9 @@ | ||
{ | ||
"tags": [ | ||
"sobriety", | ||
"environment", | ||
"ecocode", | ||
"android", | ||
"eco-design" | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.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,21 @@ | ||
== Why is this an issue? | ||
|
||
Turning on the torch mode programmatically with `react-native-torch` must absolutely be avoided because the flashlight is one of the most energy-intensive component. | ||
|
||
## Non compliant Code Example | ||
|
||
[source,js,data-diff-id="2",data-diff-type="noncompliant"] | ||
---- | ||
import Torch from 'react-native-torch'; // Non-compliant | ||
---- | ||
|
||
[source,js,data-diff-id="2",data-diff-type="compliant"] | ||
---- | ||
import axios from 'axios'; // Compliant | ||
---- | ||
|
||
== Resources | ||
|
||
=== Documentation | ||
|
||
- [CNUMR best practices mobile](https://github.com/cnumr/best-practices-mobile) - Torch free |
13 changes: 13 additions & 0 deletions
13
ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.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" | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.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,9 @@ | ||
{ | ||
"tags": [ | ||
"sobriety", | ||
"environment", | ||
"ecocode", | ||
"ios", | ||
"eco-design" | ||
] | ||
} |