created test to ensure static styles don't contain themeColor() calls, use node 18 in workflows
This commit is contained in:
@@ -11,7 +11,7 @@ This pull request is categorized as a:
|
||||
- [ ] Code refactor
|
||||
- [ ] Configuration change
|
||||
- [ ] Locales update
|
||||
- [ ] Quality assurance
|
||||
- [ ] Quality assurance
|
||||
- [ ] Other
|
||||
|
||||
## Checklist
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user