-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add support for listing redundant whitelist entries #649
Add support for listing redundant whitelist entries #649
Conversation
18ee8bf
to
50a7430
Compare
@@ -48,6 +48,19 @@ To prevent that from happening you can configure a `whitelist`, which accepts an | |||
array of regular expressions that will be checked when looking for unused | |||
translations. | |||
|
|||
### `errorOnUnusedWhitelistEntries` |
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.
I think it's nice to make the exit code dependent on unused whitelist entries as well. However, I chose to leave this as a config option, so that current users aren't affected by this change. Alternative is just not having this config option and still error, but this might block applications after upgrading. Also, if this feature contains a bug that I overlooked, it's easy to turn it off.
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.
I think we will keep it opt in for now, and see how it goes and that it is working well, then i think for the next Major version i think i will have this on by default.
|
||
if (isKeyMissing && isKeyAllowed) { | ||
if (!isKeyMissing) continue; |
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.
Little performance improvement here; if the key wasn't missing, it would still be looked up in the whitelist, which is useless.
if (!isKeyMissing) continue; | ||
|
||
const whitelistKey = whitelist.find(regex => regex.test(keyTrimmed)); | ||
const isKeyWhitelisted = whitelistKey != null; |
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.
I find it easier to follow when called isKeyWhitelisted
as opposed to isKeyAllowed
f74de25
to
c150f43
Compare
Implements #645.