-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
numeric-separators-style
: Add onlyIfContainsSeparator
option
#916
numeric-separators-style
: Add onlyIfContainsSeparator
option
#916
Conversation
I'm not sure if we should add this option, but you didn't test |
Considering it has a separator, I think the entire number should be checked, to be more consistent. Do you want me to add a test for more "complicated" numbers? I did not do any because the option short-circuits the whole check so it will never get to the decimal and exponential part.
No problem, I did not know if I should wait for a "help-wanted" label, so I just did it anyway 😄 Don't hesitate to close the PR if you don't think it should be added. |
While I wouldn't personally use this option, I can see how it would be useful if you want to enforce "correctness", but not style. We could use it in, for example, the unopinionated preset (#896). |
👍 |
Co-authored-by: Sindre Sorhus <[email protected]>
Co-authored-by: Sindre Sorhus <[email protected]>
@fisker Are you ok with merging this? |
Yes, I'm fine with this, but I think the option can have a better name, like And do we want a top level one to easier set for all? Also, need more tests on different options, and seperator in different position of |
…tps://github.com/noftaly/eslint-plugin-unicorn into numeric-separators-style-check-only-if-separator
👍 |
Alternatively: |
👍 |
Just to be sure, do you want only one at the top level, or one for each types and a "master" setting at the top level that overrides other settings if set? |
Both, if top one is set, all default to it. |
Doesn't it add too many complexity and redundancy? I thought of doing that too but I think it might confuse the user and clutter the options... |
{
onlyIfContainsSeparator: false, // default, can be omitted
binary: {
onlyIfContainsSeparator: true
}
} {
onlyIfContainsSeparator: true,
binary: {
onlyIfContainsSeparator: false
}
} Pretty clear to me, think this way you can set |
Okay, I'll do that then 👍🏼 |
Just curious about the actions, why do the lint errors appear in the build job and not in the lint job? (cf my last failing commit) |
|
I changed the logic a little bit, ebf5aee, I think this is more reasonable. |
…arator # Conflicts: # test/numeric-separators-style.js
numeric-separators-style
: Add checkOnlyIfSeparator
optionnumeric-separators-style
: Add onlyIfContainsSeparator
option
Added an option for each literal type, named
checkOnlyIfSeparator
.As explained in the docs, it:
Check if the group sizes are valid only if there are groups, separated with an
_
.Example:
This option is disabled by default.
Closes #868