Skip to content

Commit

Permalink
created script and workflow to ensure static styles don't contain the…
Browse files Browse the repository at this point in the history
…meColor() calls
  • Loading branch information
myxmaster committed Nov 25, 2023
1 parent e4d59f2 commit 3bba480
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ This pull request is categorized as a:
- [ ] Code refactor
- [ ] Configuration change
- [ ] Locales update
- [ ] Quality assurance
- [ ] Quality assurance
- [ ] Other

## Checklist
- [ ] I’ve run `yarn run tsc` and made sure my code compiles correctly
- [ ] I’ve run `yarn run lint` and made sure my code didn’t contain any problematic patterns
- [ ] I’ve run `yarn run prettier` and made sure my code is formatted correctly
- [ ] I’ve run `yarn run test` and made sure all of the tests pass
- [ ] I’ve run `yarn run check-styles` and made sure all of the static styles don't contain themeColor() calls

## Testing

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/check-styles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check styles
on:
push:
branches:
- "master"
pull_request:
branches:
- "*"
jobs:
check-styles:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
- run: yarn run check-styles
7 changes: 7 additions & 0 deletions check-styles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
filesContainingInvalidStyles="`grep -lrPazo --include '*.tsx' --exclude-dir 'node_modules' '(?s)\n[^\s][^\n]+StyleSheet\.create\(\{.*themeColor\(' .`"
if [ $? -eq 0 ]
then
echo "The following files contain static StyleSheets with themeColor() calls. This is not allowed because the color then will not be updated when theme is changed."
echo "$filesContainingInvalidStyles"
exit 1
fi
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"gen-proto": "pbjs -t static-module --keep-case -w es6 --force-long -o proto/lightning.js proto/*.proto proto/*/*.proto && pbts -o proto/lightning.d.ts proto/lightning.js",
"gradlew": "cd android && ./gradlew",
"android:clean": "yarn gradlew clean",
"fetch-libraries": "bash fetch-libraries.sh"
"fetch-libraries": "bash fetch-libraries.sh",
"check-styles": "bash check-styles.sh"
},
"dependencies": {
"@keystonehq/bc-ur-registry": "0.4.2",
Expand Down

0 comments on commit 3bba480

Please sign in to comment.