-
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
Allow regex patterns in ignore lists #19
Comments
|
@edvardchen Is there a way to allow regular expressions in Like this: { ignoreCallee: [/foo.*/, 'bar'] } or like this: { ignoreCallee: [RegExp('foo.*'), 'bar'] } ? Or is this a limitation of the eslint config parser? Any way of workaround this? |
@ivan-aksamentov The other option is we can treat string as { ignoreCallee: ["foo.*", 'bar'] } Sure, then we can skip function call like But this would violate current behavior. For example in /*eslint i18next/no-literal-string: ["error", { "ignoreCallee": ["yourI18n.method"] }]*/
const bar = yourI18n.method('bar'); And users don't expect the plugin to skip |
@edvardchen Yes, I understand the issues with treating the strings as regexes. Although if you are willing to implement it as it a breaking change (in version 4), then we could declare all strings regexes. So that when transitioning to version 4 users would have to escape their dots and other special characters. Some popular plugins do treat strings as regexes: https://github.com/benmosher/eslint-plugin-import#importignore
Given the complications with strings-as-regexes, why not? Eslint and plugins support filename wildcards in some places (which probably requires using some library or a custom parser), so I don't see how regexes are fundamentally different. See for example eslint's own I've no idea how that works, but just want to understand the reasoning here. |
@ivan-aksamentov You misunderstood me. What I said was that I wouldn't support JS type RegExp. I agree that we can make a breaking change to treat |
This is how I understood it and then asked why :) |
Forget it. Actually this plugin would already have support it while supporting regexp-in-strings Because |
allow user to ignore strings or callee by regular expression BREAKING CHANGE: all patterns in ignoreCallee would be treated as regular expression fix #19
@ivan-aksamentov plz see the following added test case is enough or not // valid
{
code: 'foo.bar("taa");',
options: [
{
ignoreCallee: [/foo.+/]
}
]
}, |
allow user to ignore strings or callee by regular expression BREAKING CHANGE: all patterns in ignoreCallee would be treated as regular expression fix #19
@edvardchen Yes. Thanks so much! |
try version v4 |
Add capability to add regex patterns along with strings in ignore lists.
For example, if I want to ignore all functions starting with "foo" (e.g. "foo()", "foo1()", "fooTwo()") and a function "bar()", I would add:
This would allow non-exhaustive checks, that is, to ignore a list of items where elements are not known in advance (or tedious to enumerate).
Related to #18 (the code will probably be shared)
The text was updated successfully, but these errors were encountered: