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

Switch from jshint to eslint #885

Merged
merged 10 commits into from
Sep 24, 2017
Merged

Switch from jshint to eslint #885

merged 10 commits into from
Sep 24, 2017

Conversation

paulmelnikow
Copy link
Member

@paulmelnikow paulmelnikow commented Apr 21, 2017

This is using eslint:recommended, which provides a bunch of mostly style-agnostic rules (look for the ✔️'s). Plus a couple extra whitespace rules, and strict mode. no-console is turned off for tests and examples to avoid needing a bunch of overrides. It's a moderately large diff, primarily on account of a mass of unused variables in test_intercept.js.

There's not much changing of substance though.

I've got one failing unit test. It's been passing erroneously because scope.done() on line 161 causes a ReferenceError. (scope is not defined.) It's not immediately clear how to fix it.

I ran the .jshintrc through polyjuice. Some of the rules it generated would have produced large diffs, so I added them to eslintrc but left them commented out. We can turn them back on in subsequent passes. We may also want to look for a shared config.

For #868


Summary

Switch from jshint to eslint

  • Remove pre-commit hooks
  • Fix a broken unit test (bug caught by lint)
  • Minor lint and style cleanup

Closes #868

@paulmelnikow
Copy link
Member Author

Hi there, any update on this? To avoid conflicts, would be great to get it merged before much else goes in.

@paulmelnikow
Copy link
Member Author

Still have a failing unit test here, in test_back.js. It's been passing erroneously because scope.done() on line 161 211 causes a ReferenceError. (scope is not defined.) It's not immediately clear how to fix it.

Do you understand what the assertion is supposed to be doing?

@@ -208,7 +208,6 @@ tap.test('nockBack dryrun tests', function (nw) {
try {
done();
t.false(exists(fixtureLoc));
scope.done();
Copy link
Member Author

Choose a reason for hiding this comment

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

^^ Since scope is not defined, this line caused a ReferenceError, which erroneously caused the test to pass.

Copy link
Member

@gr2m gr2m Sep 22, 2017

Choose a reason for hiding this comment

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

I’ve looked into the test, and they try/catch doesn’t make any sense to me, so I’ll just remove it ¯\_(ツ)_/¯ 58c120c

.travis.yml Outdated
script:
- npm run lint
- npm run coverage
- npm run integration
Copy link
Member

Choose a reason for hiding this comment

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

how about we put npm run lint into a "pretest" script or "posttest" script in package.json, so it automatically gets run with tests? That’s what I usually do

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense to me! I didn't realize it wasn't in there. It should definitely get run with npm run test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like it is getting run with npm test!

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see it now. But we should probably add npm run unit to the list?

And move npm run coverage to after_success?

Copy link
Member Author

Choose a reason for hiding this comment

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

npm run unit: we sure should! Hahaha.

I'm inclined to run npm run coverage in after_script rather than after_success. Coverage data is still useful, even if a couple unit tests fail or a lint rule fails.

Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

great work 👍

@gr2m
Copy link
Member

gr2m commented Sep 23, 2017

Hey @paulmelnikow thanks for helping out with answering issues and reviewing Pull Request! I’d be happy to make you part of the maintainers team if you like? That would allow you to actually review & merge pull requests and create your own pull requests from branches instead of forks

@paulmelnikow
Copy link
Member Author

@gr2m I'd be down! I depend on nock for shields, and feel it's an important dependency for so much of the community. I've dug into it before and am glad to keep doing that. While I'm not sure how consistently I'll be able to help, I'm glad to do it when I can!

@gr2m
Copy link
Member

gr2m commented Sep 23, 2017

No worries, there are no expectations, it’s all volunteer work and life happens. Just keep us posted :) And us know if you have any ideas on how to move the project forward towards a more open, contributor friendly project :)

I’ve invited you, you should see the notification on https://github.com/node-nock

@gr2m
Copy link
Member

gr2m commented Sep 23, 2017

looks like it’s currently failing due to a linting error :)

@paulmelnikow
Copy link
Member Author

Huh. Most strange. That most recent test build ran on the previous commit, not my last commit. Lint is clean. 🤷‍♂️

screen shot 2017-09-23 at 8 04 49 pm

screen shot 2017-09-23 at 8 04 57 pm

@coveralls
Copy link

coveralls commented Sep 24, 2017

Coverage Status

Coverage decreased (-0.02%) to 92.686% when pulling d16dc40 on paulmelnikow:eslint into b1e8787 on node-nock:master.

@paulmelnikow
Copy link
Member Author

  "pre-commit": [
    "jshint",
    "coverage"
  ],

This seems way excessively frequently to run these and they slow down my workflow a bunch. I end up using --no-verify all the time, but that also means I can't make commits in the graphical Git tool I also use.

Frankly I'm inclined to move lint to pre-push and let coverage (i.e. unit tests) be handled in CI. Thoughts?

@gr2m
Copy link
Member

gr2m commented Sep 24, 2017

the current lint errors are legit, I’m looking into it. Let’s keep it in CI, but there are ways to speed things up that we can look into later :)

@coveralls
Copy link

coveralls commented Sep 24, 2017

Coverage Status

Coverage decreased (-0.02%) to 92.686% when pulling 5ab4443 on paulmelnikow:eslint into b1e8787 on node-nock:master.

@paulmelnikow
Copy link
Member Author

Ah, I'm not suggesting removing anything from CI, rather removing unit tests from the pre-commit hook, and moving lint from pre-commit to pre-push.

@gr2m
Copy link
Member

gr2m commented Sep 24, 2017

ah got it, only seen the pre-commit hook, it doesn’t work for me anyway. I’d remove all the commit hooks, I’ve seen people had so many struggle with them, it’s not worth the pain

@coveralls
Copy link

coveralls commented Sep 24, 2017

Coverage Status

Coverage decreased (-0.02%) to 92.686% when pulling 8cd6d9d on paulmelnikow:eslint into b1e8787 on node-nock:master.

@coveralls
Copy link

coveralls commented Sep 24, 2017

Coverage Status

Coverage decreased (-0.02%) to 92.686% when pulling d42fb3b on paulmelnikow:eslint into b1e8787 on node-nock:master.

@gr2m
Copy link
Member

gr2m commented Sep 24, 2017

good to go from my side :) :shipit:

Maybe squash the commits when merging

@paulmelnikow paulmelnikow merged commit 2af1b88 into nock:master Sep 24, 2017
@paulmelnikow paulmelnikow deleted the eslint branch September 24, 2017 00:43
@lock
Copy link

lock bot commented Sep 13, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

@lock lock bot unassigned ianwsperber Sep 13, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants