Skip to content
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

tools: lint for function argument alignment #6390

Closed
wants to merge 2 commits into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Apr 26, 2016

Checklist
  • tests and code linting passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

tools test

Description of change

In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

myFunction(a, b,
  c, d);

The following code will not be flagged as an error by the linter:

myFunction(a, b,
           c, d);

@Trott Trott added test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory. labels Apr 26, 2016
@jasnell
Copy link
Member

jasnell commented Apr 26, 2016

LGTM

In preparation for a lint rule enforcing function argument alignment,
adjust function arguments to be aligned.
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);
@Trott
Copy link
Member Author

Trott commented Apr 27, 2016

@jbergstroem
Copy link
Member

LGTM

@Trott
Copy link
Member Author

Trott commented Apr 28, 2016

Only CI failure is the current problematic tick processor test on OS X. Unrelated.

@Trott
Copy link
Member Author

Trott commented Apr 28, 2016

/bump @nodejs/collaborators I'd like to land this, but I definitely would like a few more opinions before doing so.

@mscdex
Copy link
Contributor

mscdex commented Apr 28, 2016

LGTM

1 similar comment
@imran-iq
Copy link
Contributor

LGTM

// For now, don't bother trying to validate potentially complicating things
// like closures. Different people will have very different ideas and it's
// probably best to implement configuration options.
if (args.some((node) => { return ignoreTypes.indexOf(node.type) !== -1; })) {
Copy link
Member

@bnoordhuis bnoordhuis Apr 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (args.some((node) => ignoreTypes.includes(node.type))) {?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for the moment, that will break on CI. For faster results, the VM that runs the linter uses the system Node.js (currently 5.x) and doesn't compile from source. 5.x does not have Array.prototype.includes().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I could get rid of the braces and return keyword... is "no braces for arrow functions where they can be omitted" a style we want to standardize on? ESLint has a built-in rule for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the short form because why many words when can terse, right? @jbergstroem Are there any downsides to upgrading the node that runs the linter to v6?

@bnoordhuis
Copy link
Member

LGTM with a suggestion.

@rmg
Copy link
Contributor

rmg commented Apr 28, 2016

LGTM

Trott added a commit to Trott/io.js that referenced this pull request Apr 28, 2016
In preparation for a lint rule enforcing function argument alignment,
adjust function arguments to be aligned.

PR-URL: nodejs#6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
Trott added a commit to Trott/io.js that referenced this pull request Apr 28, 2016
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);

PR-URL: nodejs#6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
@Trott
Copy link
Member Author

Trott commented Apr 28, 2016

Landed in 8f56958 and ded3aea

@Trott Trott closed this Apr 28, 2016
Trott added a commit to Trott/io.js that referenced this pull request Apr 28, 2016
If braces are not required for an arrow function body, omit them.

Refs: nodejs#6390 (diff)
Fishrock123 pushed a commit that referenced this pull request May 4, 2016
In preparation for a lint rule enforcing function argument alignment,
adjust function arguments to be aligned.

PR-URL: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
Fishrock123 pushed a commit that referenced this pull request May 4, 2016
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);

PR-URL: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
@MylesBorins
Copy link
Contributor

@Trott you know the drill 📦

@Trott Trott mentioned this pull request Jun 2, 2016
2 tasks
@Trott
Copy link
Member Author

Trott commented Jun 2, 2016

@thealphanerd #7100

Trott added a commit to Trott/io.js that referenced this pull request Jun 4, 2016
In preparation for a lint rule enforcing function argument alignment,
adjust function arguments to be aligned.

PR-URL: nodejs#7100
Refs: nodejs#6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
Trott added a commit to Trott/io.js that referenced this pull request Jun 4, 2016
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);

PR-URL: nodejs#7100
Refs: nodejs#6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jun 6, 2016
In preparation for a lint rule enforcing function argument alignment,
adjust function arguments to be aligned.

PR-URL: #7100
Refs: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jun 6, 2016
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);

PR-URL: #7100
Refs: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
In preparation for a lint rule enforcing function argument alignment,
adjust function arguments to be aligned.

PR-URL: #7100
Refs: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);

PR-URL: #7100
Refs: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
In preparation for a lint rule enforcing function argument alignment,
adjust function arguments to be aligned.

PR-URL: #7100
Refs: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);

PR-URL: #7100
Refs: #6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
@Trott Trott deleted the align-again branch January 13, 2022 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants