`space-infix-ops`: add option for PEP8-style default parameters?
See original GitHub issueWould it be possible to add an option to space-infix-ops
to allow or enforce assignment without spaces for ES6 default parameters?
The use case for the rule - what is it trying to prevent or flag?
As of ESLint 1.2.0, space-infix-ops
also applies to assignments. As such, developers who prefer to enforce spaces around assignments as per other ops but wish to omit them only in default function parameters will now receive an unwanted warning or error.
Whether the rule is trying to prevent an error or is purely stylistic
Purely stylistic, but intended to remove a false positive.
Why you believe this rule is generic enough to be included
Default parameter value assignments are different from other types of variable assignments, in that they are part of a function’s definition. This has different implications for how you read them as you scan through code. As such, developers may wish to apply different formatting rules to them according to their preferred style.
For an example from a community where this feature already exists, Python’s Style Guide (PEP8) recommends spaces around all binary operators except for when assigning default parameter values. It’s likely that developers with Python experience who are using default parameters will already be using this style.
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Reactions:6
- Comments:36 (21 by maintainers)
Sigh, I should start working on this as a new rule as agreed above:
space-ops
. I’m a bit swamped but I think this belongs to core.With ESLint 1.3.1:
Config (via eslint-config-standard):
Code (where the function is defined on line 14):
Current error message:
Naming things, that will required a sleep and/or a shower 😄 How about
compactDefaultParams
as an initial suggestion?