-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1870 from myxmaster/fix-theme-change
Fix updating colors on theme change
- Loading branch information
Showing
17 changed files
with
207 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.