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: improve js linter #5638

Merged
merged 1 commit into from
Apr 15, 2016
Merged

tools: improve js linter #5638

merged 1 commit into from
Apr 15, 2016

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Mar 10, 2016

Pull Request check-list

Please make sure to review and check all of these items:

  • Does make -j8 test (UNIX) or vcbuild test nosign (Windows) pass with
    this change (including linting)?
  • Is the commit message formatted according to CONTRIBUTING.md?
  • If this change fixes a bug (or a performance problem), is a regression
    test (or a benchmark) included?
  • Is a documentation update included (if this change modifies
    existing APIs, or introduces new ones)?

Affected core subsystem(s)

  • tools

Description of change

This commit switches from the eslint command-line tool to a custom tool that uses eslint programmatically in order to perform linting in parallel and to display linting results incrementally instead of buffering them until the end. There is also now a progress indicator similar to that of make test.

Additionally, there is a new lint-ci rule that disables the progress indicator. I guess the command used on the linter Jenkins node will need to be changed internally as I couldn't find where it's configured to use what command.

Fixes: #5596

@mscdex mscdex added the tools Issues and PRs related to the tools directory. label Mar 10, 2016
@jbergstroem
Copy link
Member

We currently do gmake lint; so I'll change that to gmake lint-ci at some stage then?

@jbergstroem
Copy link
Member

@mscdex btw, it's on my agenda to – at some stage – get tap output from the linter so we can post feedback to github. It acts differently than the test suite since lint only reports errors and we'd have an "error count"; but it's still better than no output at all. This may or may not affect your current work but I thought I'd just bring it up.

You can find my work and playing around here: jbergstroem#1

@jbergstroem
Copy link
Member

@mscdex the problem with switching what command the linter should run is that we need to merge that commit to all branches and have it sit there for a while before we can switch in CI; otherwise it would call a command that wouldn't exist. My plan to address this was introducing placeholders and let them sit around for a while. I obviously forgot about it.

@mscdex
Copy link
Contributor Author

mscdex commented Mar 10, 2016

@jbergstroem Does the tap output have to all be in one single group of results (e.g. only one TAP header in the output file) or does it not matter?

@jbergstroem
Copy link
Member

@mscdex I recall globbing files ("collect *.tap") working just fine.

@mscdex
Copy link
Contributor Author

mscdex commented Mar 10, 2016

Ok, I've updated it to allow output to file and selecting the formatter.

@silverwind
Copy link
Contributor

Nice work, seems to run slightly faster too:

Before: make jslint 15.72s user 0.82s system 106% cpu 15.565 total
After: make jslint 33.02s user 2.56s system 287% cpu 12.388 total

@Fishrock123
Copy link
Contributor

Is that faster or slower?

@silverwind
Copy link
Contributor

3s faster, but a lot more cpu intensive.

@mscdex
Copy link
Contributor Author

mscdex commented Mar 10, 2016

I am getting ~7s improvement on my machine with the current list of files we lint.

I also just bumped up the max load per worker and that seemed to decrease times a tad more.

It will use more cpu time if you have multiple cores though.

@jbergstroem
Copy link
Member

I again just want to make the note that we can't land this as-is seeing how we rely on make lint from ci (just want this here in case of LGTM's starting to roll in). Few options:

  1. New PR with make lint-ci calling make lint, merge it and wait a few months before landing this
  2. Env logic (since its easy for us to add env stuff through jenkins) for make lint -- this is how we usually get around handling multiple versions of Makefile.
  3. I had something in mind but forgot while writing the other two :) will revisit when awake.

@bnoordhuis
Copy link
Member

LGTM although there are a few conflicts. @jbergstroem What needs to happen before this can land?

@jbergstroem
Copy link
Member

@bnoordhuis I suggest we do the first path; create placeholders in Makefile and make sure we get that commit into all branches we want to cover in CI, then land this.

@Trott
Copy link
Member

Trott commented Mar 23, 2016

I don't think the make lint-ci job is working correctly. If I modify .eslintrc in the root directory (say, remove the option fromcomma-dangle so that it is just 2), make jslint correctly flags errors but make lint-ci reports 0 errors.

@mscdex
Copy link
Contributor Author

mscdex commented Mar 26, 2016

@Trott That message is from cpplint, not jslint-ci.

@jbergstroem What would that kind of initial change look like? I'd like to get the placeholders in sooner than later.

@jbergstroem
Copy link
Member

@mscdex I'll do a PR.

@Trott
Copy link
Member

Trott commented Mar 26, 2016

@mscdex Ah, yes, you are correct, of course. The errors are showing up just fine in the tap file.

const secs = padString(elapsed % 60, 2, '0');
const passed = padString(successes, 6, ' ');
const failed = padString(failures, 6, ' ');
var pct = Math.ceil(((totalPaths - paths.length) / totalPaths) * 100);
Copy link
Contributor

Choose a reason for hiding this comment

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

pct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Percent complete

@Fishrock123
Copy link
Contributor

@mscdex could you comment-document the new jslint proxy tool more? I just want to make sure this isn't something we have to fight with much in the future. :)

@mscdex
Copy link
Contributor Author

mscdex commented Apr 9, 2016

@Fishrock123 more comments added

@jbergstroem
Copy link
Member

By "update" I just meant look at merging; sorry. I've changed targets in ci now -- this might imply that old jobs that hasn't been rebased as of late will likely fail; so lets try and keep track of that. Failed lint jobs aren't common, so it should be pretty easy to spot. LGTM.

@jbergstroem
Copy link
Member

Actually; hold off passing -J in test-ci for now. I'd like to add it similar to how its done in #6208.

This commit switches from the eslint command-line tool to a custom
tool that uses eslint programmatically in order to perform linting
in parallel and to display linting results incrementally instead of
buffering them until the end.

Fixes: nodejs#5596
PR-URL: nodejs#5638
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
@jbergstroem
Copy link
Member

(Still LGTM after you added -j)

@mscdex mscdex merged commit 81fd458 into nodejs:master Apr 15, 2016
@mscdex mscdex deleted the tools-improve-linter branch April 15, 2016 04:51
@jbergstroem
Copy link
Member

FYI: Went from spending >50sec to <30sec in our CI on linting as a result of this PR 🎉

MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
This commit switches from the eslint command-line tool to a custom
tool that uses eslint programmatically in order to perform linting
in parallel and to display linting results incrementally instead of
buffering them until the end.

Fixes: #5596
PR-URL: #5638
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
@MylesBorins MylesBorins mentioned this pull request Apr 20, 2016
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
This commit switches from the eslint command-line tool to a custom
tool that uses eslint programmatically in order to perform linting
in parallel and to display linting results incrementally instead of
buffering them until the end.

Fixes: #5596
PR-URL: #5638
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
@MylesBorins
Copy link
Contributor

@mscdex do you think we should backport this to v4?

@mscdex
Copy link
Contributor Author

mscdex commented Apr 21, 2016

@thealphanerd AFAIK it should work as long as a2ca347 is also applied.

MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
This commit switches from the eslint command-line tool to a custom
tool that uses eslint programmatically in order to perform linting
in parallel and to display linting results incrementally instead of
buffering them until the end.

Fixes: #5596
PR-URL: #5638
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
jasnell pushed a commit that referenced this pull request Apr 26, 2016
This commit switches from the eslint command-line tool to a custom
tool that uses eslint programmatically in order to perform linting
in parallel and to display linting results incrementally instead of
buffering them until the end.

Fixes: #5596
PR-URL: #5638
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
@MylesBorins
Copy link
Contributor

I'm going to mark this as do not land for lts right now

@mscdex feel free to prepare a backport of this change if you think it would be beneficial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request: tools: show linting progress / parallelize linting
7 participants