-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove dot in generic types #2643
Comments
This fix removes dot characters present in generic types. Issue shaka-project#2643
This fix removes dot characters present in generic types (nonNull). Issue shaka-project#2643
This fix removes dot characters present in generic types (mayBeNull). Issue google#2643
I have recently read the styleguide and if I understand correctly, I assume this change should apply to every type. If the previous assumption is correct, then the fix can be achieved using regular expressions globally. If that outcome is what this issue is trying to achieve, I would assume the best course of action would be running a regex find-and-replace by a trusted maintainer instead of reviewing an extremely big pull request from an outside contributor, so here is what I used in my approach: // fix general
'find': ([a-zA-Z]+)\.<([a-zA-Z]+)
'replace': $1<$2
// fix nonNull
'find': ([a-zA-Z]+)\.<!([a-zA-Z]+)
'replace': $1<!$2
// fix mayBeNull
'find': ([a-zA-Z]+)\.<\?([a-zA-Z]+)
'replace': $1<?$2
I have tested this in my personal fork @nbcl/shaka-player:feat-2643 to a resulting 1,226 additions and 1,226 deletions in 198 files, without creating any issues in I really hope this can be of use @joeyparrish! |
Yes, I think a mass search-and-replace is in order. But ideally, we would also convince eslint to enforce the new style at the same time. Without enforcement, we will definitely slip into old habits. |
@nbcl, if you can figure out if eslint has a rule for this, and enable it, we would love to receive a PR with the changes. Thanks! |
Unfortunately, I was not able to find an official ESLint rule for this change, but I have several insights that I think could be of help to point towards the right direction. Initially, I discovered that none of the different options in the They do, however, recommend an alternative.
I have tested it in my personal fork, @nbcl/shaka-player:feat-2643-eslint under multiple settings, but the following seem to be the ideal. 'settings': {
'jsdoc': {
'preferredTypes': {
'.<>': '<>',
},
'mode': 'closure',
},
}, The plugin managed to correctly detect 1245 problems, which appear to be the total amount of incorrect instances. This is more that the 1226 detected in my previous comment, as I now learned my proposed regular expressions where not able to find instances of the following structure:
I find this new plugin to be a good approach, however, it has the following downsides.
Although I was not able to come up with the solution, at least we now appear to know the total amount of incorrect instances and a plugin that seems to achieve something similar to the needed outcome. I really hope this information can be of help to find an ideal solution to this issue! |
Google Style for JavaScript no longer favors a dot in generic types. For example, where we currently have
Array.<string>
, the latest style guide says we should now useArray<string>
.The text was updated successfully, but these errors were encountered: