-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): generate default config with readonly and as const #2542
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files☔ View full report in Codecov by Sentry. |
c42ec3c
to
cea1241
Compare
findFilesInTree, | ||
} from '@o3r/schematics'; | ||
|
||
const regexp = /translations\s*:\s*(?:Readonly<)?([A-Z][\w]*)(?:>)?\s*=\s*({[^;]+})\s*(as\s*const)?\s*;/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To handle different linter rule guidelines it can be an easy fix to turn the ;
non-mandatory :
const regexp = /translations\s*:\s*(?:Readonly<)?([A-Z][\w]*)(?:>)?\s*=\s*({[^;]+})\s*(as\s*const)?\s*;/g; | |
const regexp = /translations\s*:\s*(?:Readonly<)?([A-Z][\w]*)(?:>)?\s*=\s*({[^;]+})\s*(as\s*const)?\s*;?/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more difficult to detect the end of the object then
;
is used before in the regexp for that ({[^;]+})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I propose:
/translations\s*:\s*(?:Readonly<)?([A-Z][\w]*)(?:>)?\s*=\s*({(?:[^:]+:\s*(?:".*"|'.*'|\s*,\s*))*\s*})\s*(as\s*const)?\s*;?/g
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not work for complex object like the one in this example
https://regex101.com/r/2HTPCa/1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed but it is working for localisation, which is what you want to parse, don't you?
(And it does support ;
within the translation key even if I am not sure we do support it farer in the extractor 😅)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes my point was that I have the same issue (and same regexp, expect the starting point) for configuration
Related issues
🐛 Fix #2530