question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ignoreDefaultParamAssign option to space-infix-ops

See original GitHub issue

What 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kasvtvcommented, May 25, 2018

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.

1reaction
platinumazurecommented, May 25, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found