| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
lgtm |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
This is truly only temporary from being used to ES5, it does go away but… I've been thinking about the issue of arrow function parens a bit recently and I think there's a good case for a middle ground. Perhaps consider this instead:
Having more than one argument messes up terseness/simplicity of single line arrows anyway. Also found you're far more likely to need to add multiple args for something that's already a multi-line function, so this pre-empts that and removes annoying need to add parens around just because you're adding one argument. So trivial things like this remain nice and terse: items.map(item => item.price)but adding a second arg messes the terseness of a single line up even before using the arg in a function body: items.map((item, index) => item.price)Instead, the proposed option would force a multi-line structure for multi-args, like so: items.map((item, index) => {
return item.price
})Not sure if there's a rule for this in eslint. |
Sorry, something went wrong.
|
LGTM. |
Sorry, something went wrong.
|
lgtm |
Sorry, something went wrong.
|
LGTM, but I'm also ok with @timoxley proposal. |
Sorry, something went wrong.
There was a problem hiding this comment.
nit: no spaces inside braces.
Sorry, something went wrong.
There was a problem hiding this comment.
and technically the quotes are optional but we don't have consistent use of them in this file...
Sorry, something went wrong.
There was a problem hiding this comment.
Interesting, I wasn't aware that quotes are optional in most cases YAML. I'll investigate if we can remove all quotes.
Sorry, something went wrong.
|
LGTM. Definitely agree on this |
Sorry, something went wrong.
|
So, am I the only one who finds parens around a single argument arrow function ugly? |
Sorry, something went wrong.
|
Nope. I am with you on that @bnoordhuis. |
Sorry, something went wrong.
|
Better to have less options here for the sake of new people who will inevitably become confused by the like 5 different cases of style for arrow functions. LGTM |
Sorry, something went wrong.
|
Personally, I prefer to only use arrow functions in the single line, paren free style, and with short argument names. The needing to explicitly return in multi line arrow functions but not single line ones is super confusing to new people, so I'd avoid that style entirely. |
Sorry, something went wrong.
Sure, but chances are we'll care more about the speed of the context capturing vs bind() over style. |
Sorry, something went wrong.
Sorry, something went wrong.
|
CI failures look unrelated. There are more than enough signoffs to land but given the discussion it may be worth while holding this one open for another day. |
Sorry, something went wrong.
|
@bnoordhuis ... I personally find arrow functions ugly in general along with the parens, but I'd rather we had consistency |
Sorry, something went wrong.
|
going to mark this one as do not land in v4 tho... can revisit that if folks feel strongly about it tho |
Sorry, something went wrong.
|
@jasnell If we do not backport linter rules, landing code which follow this would be difficult in the future, no? |
Sorry, something went wrong.
|
yes, if those rules are less restrictive or change an existing rule. In this case, not adding this rule shouldn't impact anything (tho I could be wrong) |
Sorry, something went wrong.
Yes, but I am thinking of a very rare case. Let's say we land a fix which is specific to 4.x and if that doesn't follow this rule, then we will have two slightly different style systems and it wouldn't be consistent, right? |
Sorry, something went wrong.
|
Yeah, you're right.
|
Sorry, something went wrong.
There was a problem hiding this comment.
There's no Arrow Functions category in http://eslint.org/docs/rules/. Can you structure the rules like in that list?
Sorry, something went wrong.
|
I'm with @bnoordhuis writing e => e.text is nicer than (e) => e.text. The language lets us omit these because it is a simple one parameter case. As a data point - linters for C# (like ReSharper's rules) raise a warning (by default) if you include the ()s in a single parameter. If I remember correctly (please correct me) so do Java IDEs like IntelliJ (for ->) and Scala. |
Sorry, something went wrong.
|
@jasnell thoughts on landing this now? The nice thing about disabling or loosening a lint rule in the future is that it doesn't require going back and fixing the code again. |
Sorry, something went wrong.
This commit enables the following rules: * arrow-parens - requires parens around arrow function arguments * arrow-spacing - ensures a space on each side of the => * no-arrow-condition - prevents accidental use of => in cases where the user really intends to use <= PR-URL: #4813 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This commit applies new arrow function linting rules across the codebase. As it turns out, the only offenders were in the test directory. PR-URL: #4813 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This commit enables the following rules: * arrow-parens - requires parens around arrow function arguments * arrow-spacing - ensures a space on each side of the => * no-arrow-condition - prevents accidental use of => in cases where the user really intends to use <= PR-URL: nodejs#4813 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This commit applies new arrow function linting rules across the codebase. As it turns out, the only offenders were in the test directory. PR-URL: nodejs#4813 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
| Back | FazBrowse Home | New Git URL |
This PR enforces the following linting rules:
where the user really intends to use <=
The only code that violated these rules existed in the test directory.
R= @rvagg