Skip to content

Commit 134cd96

Browse files
Merge pull request #86 from OpenDTU-App/52-implement-inverter-info
2 parents 2904796 + 3e0b66b commit 134cd96

File tree

119 files changed

+4221
-868
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+4221
-868
lines changed

.eslintrc.json

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
"node": true,
44
"react-native/react-native": true
55
},
6+
"overrides": [
7+
{
8+
// Test files only
9+
"files": ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
10+
"extends": ["plugin:testing-library/react"]
11+
}
12+
],
613
"extends": [
714
"eslint:recommended",
815
"plugin:import/recommended",
@@ -34,11 +41,16 @@
3441
"react-native",
3542
"react-hooks",
3643
"prettier",
37-
"import"
44+
"import",
45+
"simple-import-sort"
3846
],
3947
"rules": {
4048
"import/no-named-as-default-member": "off",
4149
"import/no-named-as-default": "off",
50+
"import/first": "error",
51+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
52+
"import/newline-after-import": "error",
53+
"import/no-duplicates": "error",
4254
"import/extensions": [
4355
"error",
4456
"never",
@@ -72,7 +84,6 @@
7284
"disallowTypeAnnotations": true
7385
}
7486
],
75-
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
7687
"no-console": 0,
7788
"indent": "off",
7889
"quotes": [
@@ -108,21 +119,24 @@
108119
"bracketSpacing": true,
109120
"arrowParens": "avoid",
110121
"bracketSameLine": false,
111-
"endOfLine": "lf",
112-
"importOrder": [
113-
"^react",
114-
"^react-native$",
115-
"^@/slices",
116-
"^@/types",
117-
"^@/components",
118-
"^@/hooks",
119-
"^@/utils",
120-
"^@/assets",
121-
"^[./]",
122-
"^@/"
123-
],
124-
"importOrderSeparation": true
122+
"endOfLine": "lf"
125123
}
126-
]
124+
],
125+
"simple-import-sort/imports": ["error", {
126+
"groups": [
127+
["^react"],
128+
["^react-native$"],
129+
["^\\w"],
130+
["^@/slices"],
131+
["^@/types"],
132+
["^@/components"],
133+
["^@/hooks"],
134+
["^@/utils"],
135+
["^@/assets"],
136+
["^@/"],
137+
["^[./]"]
138+
]
139+
}],
140+
"simple-import-sort/exports": "error"
127141
}
128142
}

.githooks/pre-commit

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
#!/bin/bash
2-
# Get latest git tag
3-
latest_tag=$(git describe --tags --abbrev=0)
4-
latest_tag_without_v=${latest_tag#"v"}
5-
version_from_tag=$(echo "$latest_tag_without_v" | grep -P '^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')
2+
# This script is ./pre-commit
3+
# Execute all scripts in ./pre-commit.d in order (0-foo before 10-bar)
64

7-
# Get the version from package.json
8-
version=$(jq -r '.version' package.json)
5+
# Get the directory of this script
6+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
error=0
98

10-
echo "Latest tag: $latest_tag_without_v"
11-
echo "Version from tag: $version_from_tag"
12-
echo "Version from package.json: $version"
9+
echo "Running pre-commit hooks in $DIR/pre-commit.d"
1310

14-
# Check if the version from the tag and package.json are the same
15-
if [ "$version" != "$version_from_tag" ]; then
16-
echo "Version in package.json and tag are not the same"
17-
exit 1
18-
fi
11+
# Run all scripts in ./pre-commit.d
12+
for script in $DIR/pre-commit.d/*; do
13+
if [ -x $script ]; then
14+
echo "> Running $script"
15+
$script
16+
err=$?
17+
if [ $err -ne 0 ]; then
18+
echo "Error in $script: $err"
19+
if [ $error -eq 0 ]; then
20+
error=$err
21+
fi
22+
fi
23+
printf "\n"
24+
fi
25+
done
1926

20-
echo "Version in package.json and tag are the same"
27+
exit $error
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
conflicts=$(git diff --cached --name-only -G"<<<<<|=====|>>>>>")
3+
4+
if [[ -n "$conflicts" ]]; then
5+
echo "Unresolved merge conflicts in these files:"
6+
7+
for conflict in $conflicts; do
8+
echo "$conflict"
9+
done;
10+
11+
exit 1;
12+
fi
13+
14+
exit 0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Get latest git tag
3+
latest_tag=$(git describe --tags --abbrev=0)
4+
latest_tag_without_v=${latest_tag#"v"}
5+
version_from_tag=$(echo "$latest_tag_without_v" | grep -P '^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')
6+
7+
# Get the version from package.json
8+
version=$(jq -r '.version' package.json)
9+
10+
echo "Latest tag: $latest_tag_without_v"
11+
echo "Version from tag: $version_from_tag"
12+
echo "Version from package.json: $version"
13+
14+
# Check if the version from the tag and package.json are the same
15+
if [ "$version" != "$version_from_tag" ]; then
16+
echo "Version in package.json and tag are not the same"
17+
exit 1
18+
fi
19+
20+
echo "Version in package.json and tag are the same"

.github/workflows/testing.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Continuous Integration
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68
branches: [ '*' ]
79

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/install-git-hooks.js b/install-git-hooks.js
2+
index 62723526d054b2da4ec7fa418f9125bdc59c14be..a21d9dde0b0d78cb327787fabc6ac40b1aeaa871 100644
3+
--- a/install-git-hooks.js
4+
+++ b/install-git-hooks.js
5+
@@ -54,7 +54,7 @@ function copyDir(src, dest) {
6+
};
7+
8+
function copy(src, dest) {
9+
- fs.copyFileSync(src, dest);
10+
+ fs.cpSync(src, dest);
11+
};
12+
13+
module.exports = installGitHooks;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @format
3+
*/
4+
/* eslint-env jest */
5+
6+
jest.mock('@react-native-clipboard/clipboard', () => {
7+
return {
8+
addListener: jest.fn(),
9+
removeAllListeners: jest.fn(),
10+
};
11+
});

__tests__/App.test.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
/**
22
* @format
33
*/
4-
// Note: import explicitly to use the types shipped with jest.
5-
import { it } from '@jest/globals';
6-
7-
import React from 'react';
8-
import 'react-native';
9-
// Note: test renderer must be required after react-native.
10-
import renderer from 'react-test-renderer';
4+
/* eslint-env jest */
115

126
import App from '@/App';
137

8+
import { it } from '@jest/globals';
9+
import { render } from '@testing-library/react-native';
10+
1411
it('renders correctly', () => {
15-
renderer.create(<App />);
12+
render(<App />);
1613
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<resources>
2-
<string name="app_name">opendtu-react-native</string>
2+
<string name="app_name">OpenDTU</string>
33
</resources>

app.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"name": "opendtu-react-native",
3-
"displayName": "opendtu-react-native"
2+
"name": "opendtu-react-native"
43
}

0 commit comments

Comments
 (0)