Skip to content
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

keepRemoved doesn't work with specified array of patterns #1017

Open
Mormen opened this issue Jun 26, 2024 · 1 comment
Open

keepRemoved doesn't work with specified array of patterns #1017

Mormen opened this issue Jun 26, 2024 · 1 comment

Comments

@Mormen
Copy link

Mormen commented Jun 26, 2024

🐛 Bug Report

I'm using i18next-parser and I would like to remove unused keys, but exclude some patterns.

To Reproduce

  • With boolean value, it works. But when I try to use regex pattern, it fails.
    keepRemoved: ["\binterval\w*\b"],

  • It throws error
    [error] TypeError: pattern.test is not a function

From docs
keepRemoved: false, // Keep keys from the catalog that are no longer in code // You may either specify a boolean to keep or discard all removed keys. // You may also specify an array of patterns: the keys from the catalog that are no long in the code but match one of the patterns will be kept. // The patterns are applied to the full key including the namespace, the parent keys and the separators.

Your Environment

  • runtime version: i.e. node v16.15.1
  • i18next version: i.e. 20.3.2
  • os: Linux
@McFixitMan
Copy link

Try using a regular expression literal instead of putting your pattern inside a string, e.g.
keepRemoved: [/\binterval\w*\b/]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants