From cd3623ea5020704f03e11ab83acdd3bd5d91dacb Mon Sep 17 00:00:00 2001 From: myxmaster Date: Sat, 25 Nov 2023 13:30:26 +0100 Subject: [PATCH] created script and workflow to ensure static styles don't contain themeColor() calls --- .github/workflows/check-styles.yml | 18 ++++++++++++++++++ check-styles.sh | 7 +++++++ package.json | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-styles.yml create mode 100644 check-styles.sh diff --git a/.github/workflows/check-styles.yml b/.github/workflows/check-styles.yml new file mode 100644 index 0000000000..1e37631850 --- /dev/null +++ b/.github/workflows/check-styles.yml @@ -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 diff --git a/check-styles.sh b/check-styles.sh new file mode 100644 index 0000000000..2436fad991 --- /dev/null +++ b/check-styles.sh @@ -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 diff --git a/package.json b/package.json index fc1100ee7e..fe85655ee7 100644 --- a/package.json +++ b/package.json @@ -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",