-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[naming-convention] Allow multiple underscore #1712
Comments
It's a pattern people use for protected members as well. |
Also React's |
I want to comment here as well, as I would love to see this. I tried doing a custom regex filter, so if anything started with double leading underscores, it wouldn't error: const propertySetting = {
selector: 'property',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
filter: {
regex: '^(__|_)([0-9A-Za-z]+)$',
match: false,
},
}; No such luck, giving me errors. If anyone has a secret sauce here that does work, please share! Also, another option to think about is allowing optionalPrefixes instead? if I do prefix with a blank string, eslint throws. |
@ScottAwesome I got your filter to work, when the ONLY rule was the one you posted ( |
For those looking for a
Good:
|
…ouble`, `allowSingleOrDouble` options for underscores Fixes #1712 I chose not to add an unbounded `allowMultiple` for now. I don't think that it's a commonly used pattern. Single and double I've seen, but I don't believe I've ever seen more than that.
…ouble`, `allowSingleOrDouble` options for underscores Fixes #1712 I chose not to add an unbounded `allowMultiple` for now. I don't think that it's a commonly used pattern. Single and double I've seen, but I don't believe I've ever seen more than that.
This doesn’t solve for the fact I only want certain formats otherwise though, does it? See my previous example where it won’t work if other rules are being applied |
What I found to be working is a {
selector: 'property',
prefix: ['__'],
format: ['camelCase']
}, However, for some reason (not sure if it's a bug) I had to restrict the normal {
selector: 'property',
filter: '^(?!__)',
format: […]
}, |
Repro
Hey ho 👋, this is a feature request. What do you think of allowing multiple leading or trailing underscores? There are some libraries that use double underscore (
__
) to avoid name clashes. Probably the most popular one is GraphQL where you can specify a__typename
(see here).Personally, I want to use camelCase or PascalCase and I'm ok with people pre- or postfixing names with underscores. We could introduce a 4th value for the
leadingUnderscore
andtrailingUnderscore
option that is calledallowMultiple
, like this:The text was updated successfully, but these errors were encountered: