Skip to content

Implement ESLint with eslint-config-edx#75

Merged
bjacobel merged 26 commits into
masterfrom
bjacobel/eslint
Jul 1, 2016
Merged

Implement ESLint with eslint-config-edx#75
bjacobel merged 26 commits into
masterfrom
bjacobel/eslint

Conversation

@bjacobel
Copy link
Copy Markdown
Contributor

@bjacobel bjacobel commented Jun 20, 2016

Install ESLint, and adopt our new styleguide.

If you have comments about the ESLint rules that are responsible for suggesting these changes, you can make them here: edx/eslint-config-edx#1. The ruleset/styleguide is not released/finalized yet, but will be 1.0 soon, so hurry! eslint-config-edx is now 1.0 on NPM

Testing Checklist

N/A

Non-testing Checklist

  • Consider any documentation your change might need, and which users will be affected by this change.

Post-review

  • Squash commits into discrete sets of changes with descriptive commit messages.
  • 🚨 TODO before merge: update package.json version of eslint-config-edx to NPM 1.0 🚨

Reviewers

If you've been tagged for review, please check your corresponding box once you've given the 👍.

We'll also automatically suggest reviewers for this PR based on the code it touches.

@mention-bot
Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @andy-armstrong, @dsjen and @dan-f to be potential reviewers

Comment thread gulp/tasks/lint.js Outdated
var eslint = require('gulp-eslint'),
gulp = require('gulp'),
paths = {
lint: [
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.

Do we need both this and the .eslintignore? Maybe this can just be **/*.js and let the exceptions be handled in the ignore file.

@andy-armstrong
Copy link
Copy Markdown
Contributor

@bjacobel It looks like you have a leftover call to the old jscs gulp task.

Comment thread gulp/tasks/doc.js
(function() {
'use strict';

var renameAsMarkdown, generateDocFor;
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.

I guess the convention has been to declare variables in alphabetical order unless declarations get messed up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't see us following this convention anywhere very frequently. Is it something you feel strongly about starting to enforce? We can look into if there's an eslint rule for it.

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.

I wasn't aware of that convention. I tend to declare them in the order I'm going to use them.

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.

I tend to declare them in the order I'm going to use, too.

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.

I'm with @andy-armstrong and @alisan617, I declare them in the order used. Alphabetical could be complicated if var aardvark relies on var zoo.

Comment thread package.json Outdated
"css-loader": "~0.23.1",
"del": "~2.2.0",
"edx-pattern-library": "~0.12.5",
"eslint-config-edx": "bjacobel/eslint-config-edx#bjacobel/feedback",
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.

Isn't this supposed to be edx/eslint-config-edx 0.0.1 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The 0.0.1 that's on NPM right now was released last Friday so it's a little stale, but I'm going to release a 1.0.0 to NPM after edx/eslint-config-edx#1 merges and then this can be updated to point there.

@bjacobel bjacobel changed the title Implement ESLint with eslint-config-edx (WIP) Implement ESLint with eslint-config-edx Jun 27, 2016
@bjacobel
Copy link
Copy Markdown
Contributor Author

bjacobel commented Jun 27, 2016

This has no more linter issues and is ready for review.

(There's some issue by which the coverage percentage dropped... I'll look into that.)

@coveralls
Copy link
Copy Markdown

coveralls commented Jun 27, 2016

Coverage Status

Coverage decreased (-0.02%) to 94.439% when pulling d774f77 on bjacobel/eslint into 9755c73 on master.

@bjacobel
Copy link
Copy Markdown
Contributor Author

}
}
withData = function(data, func) {
Object.keys(data).forEach(function(key) {
Copy link
Copy Markdown
Contributor Author

@bjacobel bjacobel Jun 27, 2016

Choose a reason for hiding this comment

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

Note to reviewers: for (... in ...) is banned by Airbnb ESLint because a) it has performance issues in some browsers and b) it loops over all enumerable properties, not just array members and object keys (e.g., toString).

It also wasn't a particularly good choice here anyway, because data was an Object, not an Array. So I swapped it out for Object.keys.forEach.

PS: In ES6 we can use for (... of ...) to do what for (... in ...) looks like it does.

@bjacobel
Copy link
Copy Markdown
Contributor Author

this coveralls build: 883 of 935 relevant lines covered
latest master build: 886 of 938 relevant lines covered

So there's three less lines covered, and three less lines overall... according to Coveralls that's a build failure. Wat.

@bjacobel
Copy link
Copy Markdown
Contributor Author

Hi folks! Would love to get this merged in this week, if we can - that's when I said we'd be turning it on in my email to edx-code.

@dsjen and @andy-armstrong have already done an initial review, mind giving final signoff if I've addressed all comments? @AlasdairSwan and @alisan617, would love to hear your feedback too.

Haven't figured out a good way to address the coveralls failure yet. Wish there was something analogous to [skip ci] commit comments to skip a Travis build. Any ideas?

@alisan617
Copy link
Copy Markdown
Contributor

LGTM 👍

Comment thread gulp/.eslintrc.json
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": "off"
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.

@bjacobel I quite like this rule, forcing people to merge cleaner code. Is there a reason we would want console.log statements in the codebase? I would be fine keeping warn or error if it is needed but vote to get rid of debugging statements from the code.

Copy link
Copy Markdown
Contributor Author

@bjacobel bjacobel Jun 30, 2016

Choose a reason for hiding this comment

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

ESLint allows per-directory configs, so this only applies to scripts in the gulp folder. I decided to allow console in Gulp scripts because 1) console is always defined in Node [*] and 2) console.log is pretty common in our gulp scripts as a means of feedback.

[*]: one of the arguments in favor of having no-console enabled in our browser code is that console is not implemented in IE9 and below; in Node this shouldn't ever be a problem

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.

Cool, thanks for the explanation.

@coveralls
Copy link
Copy Markdown

coveralls commented Jun 30, 2016

Coverage Status

Coverage decreased (-0.02%) to 94.439% when pulling e9f9f31 on bjacobel/eslint into 9755c73 on master.

@AlasdairSwan
Copy link
Copy Markdown
Contributor

👍

2 similar comments
@dsjen
Copy link
Copy Markdown
Contributor

dsjen commented Jun 30, 2016

👍

@andy-armstrong
Copy link
Copy Markdown
Contributor

👍

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 1, 2016

Coverage Status

Coverage increased (+0.2%) to 94.67% when pulling 1ffa8e0 on bjacobel/eslint into 9755c73 on master.

@bjacobel bjacobel merged commit d0378bb into master Jul 1, 2016
@bjacobel bjacobel deleted the bjacobel/eslint branch July 1, 2016 19:31
@andy-armstrong
Copy link
Copy Markdown
Contributor

@bjacobel Awesome find with the sinon bug! Great coverage improvements too.

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.

7 participants