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

Run stricter linter to cleanup problems and force ES6 usage #566

Merged
merged 2 commits into from Apr 10, 2018
Merged

Conversation

RyanZim
Copy link
Collaborator

@RyanZim RyanZim commented Apr 9, 2018

I started work to use rest/spread operators, since they're supported in Node 6+. Along the way, I discovered and fixed a few more problems, like regular functions being used instead of arrow functions, missing 'use strict' statements, using let instead of const, a switch where if/else does the job fine, etc.

write()'s promise implementation in lib/fs/index.js required heavy refactoring to avoid using arguments, please review this carefully.

I also discovered that we're still using our own ponyfill for Object.assign(), despite the fact it's now well supported in Node. So I removed that, and refactored lib/index.js while I was at it.

@RyanZim RyanZim added this to the 6.0.0 milestone Apr 9, 2018
@coveralls
Copy link

coveralls commented Apr 9, 2018

Coverage Status

Coverage decreased (-0.4%) to 86.303% when pulling d8fd7a0 on lint into a631c53 on v6-dev.

Copy link
Collaborator

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

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

One thing to improve, but the rest looks good


const argv = require('minimist')(process.argv.slice(2))

const mochaOpts = assign({
const mochaOpts = Object.assign({
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about:

const mochaOpts = {
  ...argv,
  ui: 'bdd',
  reporter: 'dot',
  timeout: 30000
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JPeer264 That's object spread properties; which are only supported in Node 8+, so we can't use those yet. Someday, though...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh dang! I guess I am using too much babel in my projects. Good to know though ;)

lib/fs/index.js Outdated
return fs.write(fd, buffer, a, b, c, callback)
exports.write = function (fd, buffer, ...args) {
if (typeof args[args.length - 1] === 'function') {
return fs.write(fd, buffer, ...args)
}

// Check for old, depricated fs.write(fd, string[, position[, encoding]], callback)
if (typeof buffer === 'string') {
return new Promise((resolve, reject) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This here is actually code duplication now, and this return is not any different than to the other one.

I think we can leave that if, because here it does not make the difference if there are two or three arguments. Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right; will fix.

@JPeer264 JPeer264 dismissed their stale review April 9, 2018 18:43

Requested Node 8+ features

@RyanZim RyanZim requested a review from JPeer264 April 9, 2018 18:48
Copy link
Collaborator

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@manidlou manidlou left a comment

Choose a reason for hiding this comment

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

LGTM!

@RyanZim RyanZim merged commit 20c82ab into v6-dev Apr 10, 2018
@RyanZim RyanZim deleted the lint branch April 10, 2018 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants