Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 add EC522 rule documentation for javascript #321

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- [#315](https://github.com/green-code-initiative/ecoCode/pull/315) Add rule EC530 for javascript
- [#321](https://github.com/green-code-initiative/ecoCode/pull/321) Add rule EC522 for javascript (avoid brightness override)

### Changed

Expand Down
10 changes: 1 addition & 9 deletions ecocode-rules-specifications/src/main/rules/EC522/EC522.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
"func": "Constant\/Issue",
"constantCost": "20min"
},
"tags": [
"sobriety",
"environment",
"ecocode",
"android",
"ios",
"eco-design"
],
"ecoScore": "0.4",
"defaultSeverity": "Minor"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tags": [
"sobriety",
"environment",
"ecocode",
"android",
"eco-design"
]
}
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>
);
}
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"
]
utarwyn marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tags": [
"sobriety",
"environment",
"ecocode",
"ios",
"eco-design"
]
}
Loading