Skip to content

chore: switch to eslint#504

Merged
ariporad merged 4 commits intomasterfrom
chore-use-eslint
Aug 7, 2016
Merged

chore: switch to eslint#504
ariporad merged 4 commits intomasterfrom
chore-use-eslint

Conversation

@nfischer
Copy link
Copy Markdown
Member

@nfischer nfischer commented Aug 6, 2016

Closes #317

This switches us to using eslint instead of jshint, based off the airbnb style guide for es5.

Note: Most of the changes were created by eslint --fix.

I disabled linting rules whenever I encountered too many places where they would need fixing. Here are the rules I disabled (which we can go back and re-enable at our convenience):

    "quote-props": 0,
    "no-underscore-dangle": 0,
    "max-len": 0,
    "no-use-before-define": 0,
    "no-empty": 0,
    "no-else-return": 0,
    "no-throw-literal": 0,
    "newline-per-chained-call": 0,
    "consistent-return": 0,
    "no-mixed-operators": 0,
    "no-prototype-builtins": 0,

Any other refactors that I did manually should be mostly semantically equivalent to the way the code was before. Feel free to take your time reviewing, since there's the potential for things to change.

  • Any for (key in obj) loop was changed to Object.keys(obj).forEach(function (key) { (which I believe is slightly different semantically, but shouldn't have an effect on the intended usage).
  • I fixed some of the no-else-return errors, but ultimately disabled the rule.
  • I changed the nested ternary expression in src/uniq.js to be an else-if ladder for clarity.
  • I fixed some of the consistent-return errors, but ultimately disabled the rule (since common.error() actually does implicitly return a value).
  • I removed unnecessary character escaping (like \@ in generate-docs.js).
  • I added a default case to a switch statement in chmod() because it didn't have one.

Make sure there's no semantic changes in the test files (I don't remember doing any intentionally).

src/chmod.js Outdated
OWNER_READ: base.READ << 6,

// Literal octal numbers are apparently not allowed in "strict" javascript. Using parseInt is
// the preferred way, else a jshint warning is thrown.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two things:

  1. It might be good to note that they've been added back in ES6, for future reference.
  2. Maybe change the reference to jshint to eslint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll fix the reference to jshint. The part about octals was around previously, so I think we can just fix that in a new PR

@ariporad
Copy link
Copy Markdown
Contributor

ariporad commented Aug 6, 2016

I went through and added some comments, one thing in perticular that I think we should change is this:

// This is OK without curly braces, because it's just a guard statement:
if (whatever) return doFoo();

// This is NOT OK, because it might be confusing in the future:
if (whatever)
    return doFoo(); // Note the newline.

// This is OK, because there is braces:
if (whatever) {
    return doFoo();
}

@nfischer
Copy link
Copy Markdown
Member Author

nfischer commented Aug 6, 2016

@ariporad do you know the eslint rule for that?

@nfischer
Copy link
Copy Markdown
Member Author

nfischer commented Aug 6, 2016

@ariporad just updated. Your comments should be addressed. I left the section about octal numbers, since it isn't really relevant to updating linting rules.

@ariporad
Copy link
Copy Markdown
Contributor

ariporad commented Aug 7, 2016

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants