Add ignoreDefaultParamAssign option to space-infix-ops
See original GitHub issueWhat rule do you want to change?
space-infix-ops
Does this change cause the rule to produce more or fewer warnings? Fewer!
How will the change be implemented? (New option, new default behavior, etc.)?
A new option called ignoreDefaultParamAssign
that will relax the rule when it comes to assigning defaults for function parameters.
Please provide some example code that this change will affect:
// Currently not allowed:
function fun(value, multiplier=1, callback, setting=false) {
value = 3+4;
....
}
// Currently allowed:
function fun(value, multiplier = 1, callback, setting = false) {
value = 3 + 4;
....
}
// Not allowed with proposed option:
function fun(value, multiplier=1, callback, setting=false) {
value = 3+4;
....
}
// Allowed with proposed option:
function fun(value, multiplier=1, callback, setting=false) {
value = 3 + 4;
....
}
What does the rule currently do for this code? A dev team could argue that assigning a single primitive value as a default for a function parameter would be more readable in a list of other parameters, because it couples the name and value together whilst separating it from the other variables by spaces.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
Top Results From Across the Web
space-infix-ops - ESLint - Pluggable JavaScript Linter
This rule is aimed at ensuring there are spaces around infix operators. Options. This rule accepts a single options argument with the following...
Read more >space-infix-ops | typescript-eslint
Require spacing around infix operators. Some problems reported by this rule are automatically fixable by the --fix ESLint command line option. This rule ......
Read more >Rules - JavaScript Standard Style
This is a summary of the standard JavaScript rules. The best way to learn about standard is to just install it and give...
Read more >Configuration · Scalafmt - Scalameta
This group of parameters allows overriding which infix operators, and in which context, are eligible to be exempted from this, with indentation omitted....
Read more >How to pass optional parameters while omitting some other ...
But to get around this you can change your params to be an interface: ... I'd rather this options because allows me to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Glad you’re on board on this one!
And yes, we should camelCase the name of course! I happened to forget that the rule names with dashes and the options are camelCase. Edited my issue.
Sounds good to me. I know this is similar to the equivalent style guidelines for Python, so there’s a decent chance people would use this option.
I think we could bikeshed on the option name a bit- for example, it could be camelcase (e.g.,
ignoreDefaultParamAssign
) to save some typing in some config file formats. But putting that aside for the moment, I’m 👍 to this enhancement.