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",