created test to ensure static styles don't contain themeColor() calls, use node 18 in workflows

This commit is contained in:
myxmaster
2023-11-27 23:16:06 +01:00
parent e4d59f2678
commit a2ed49db7d
7 changed files with 48 additions and 6 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ This pull request is categorized as a:
- [ ] Code refactor
- [ ] Configuration change
- [ ] Locales update
- [ ] Quality assurance
- [ ] Quality assurance
- [ ] Other
## Checklist
+1 -1
View File
@@ -14,6 +14,6 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'
- run: yarn install --frozen-lockfile
- run: yarn run lint
+1 -1
View File
@@ -14,6 +14,6 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'
- run: yarn install --frozen-lockfile
- run: yarn run prettier
+1 -1
View File
@@ -14,6 +14,6 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'
- run: yarn install --frozen-lockfile
- run: yarn run test
+3
View File
@@ -108,6 +108,9 @@ ZEUS is proud to be integrated on the following platforms:
**Don't trust, verify** the code with your own two eyes. Then when ready proceed to the steps below based on your platform.
### Prerequisites
1. Node.js (minimum version: 18.17)
### Android
1. install and setup react-native and its related dependencies under **"Building Projects with Native Code"** on
[react-native's Getting Started page](https://reactnative.dev/docs/environment-setup)
+38
View File
@@ -0,0 +1,38 @@
import * as fs from 'fs';
import * as path from 'path';
describe('static style sheets', () => {
it('must not contain themeColor() calls', () => {
const dirs = fs
.readdirSync('.', { withFileTypes: true })
.filter((e) => e.isDirectory() && e.name !== 'node_modules')
.map((e) => e.name);
dirs.push('.');
const tsxFiles = dirs.flatMap((dir) =>
fs
.readdirSync(dir, { recursive: dir !== '.' })
.filter(
(file) =>
typeof file === 'string' &&
!file.startsWith('node_modules/') &&
file.toLowerCase().endsWith('.tsx')
)
.map((file) => path.join(dir, file as string))
);
const regExp = new RegExp(
/\n[^\s][^\n]+StyleSheet\.create\(\{.*themeColor\(/,
's'
);
const invalidFiles = tsxFiles.filter((file) =>
fs.readFileSync(file).toString('utf8').match(regExp)
);
if (invalidFiles.length > 0) {
throw new Error(
'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.\n' +
invalidFiles.join('\n')
);
}
});
});
+3 -2
View File
@@ -9,7 +9,8 @@
],
"transformIgnorePatterns": [
"node_modules/(?!(react-native|@react-native|react-native-blob-util|react-native-randombytes)/)"
]
],
"testPathIgnorePatterns": ["check-styles.test.ts"]
},
"scripts": {
"start": "react-native start",
@@ -18,7 +19,7 @@
"postinstall": "rn-nodeify --install --hack & npx jetify & yarn run patch & react-native setup-ios-permissions & yarn run fetch-libraries & pod-install",
"test": "jest",
"tsc": "tsc",
"lint": "eslint --ext .js,.ts,.tsx \"*.@(js|ts|tsx)\" .",
"lint": "eslint --ext .js,.ts,.tsx \"*.@(js|ts|tsx)\" . && yarn run test check-styles.test.ts --testPathIgnorePatterns=",
"prettier": "prettier --check \"**/*.ts*\"",
"prettier-write": "prettier --check --write \"**/*.ts*\"",
"patch": "git apply patches/react-native-camera-kit.patch && git apply patches/rnqli-build.gradle.patch",