Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Fix Lint Errors for TravisCI #601

Merged
merged 6 commits into from
Mar 24, 2017
Merged

Conversation

davidmsibley
Copy link
Contributor

Broad but hopefully thin changeset for fixing the Lint errors we should fix, and being warned about the ones that we can fix as we go. The goal is to stay as close to Google's eslint standards as we can. Rule Overrides will be documented as line comments in the pull request.


Contributor License Agreement adherence:

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3644792 on davidmsibley:master into ** on UW-Madison-DoIT:master**.

@ChristianMurphy
Copy link
Contributor

📓 resolves #599

Copy link
Contributor

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

LGTM

@davidmsibley
Copy link
Contributor Author

I can't seem to find the comment, but I got the email, @ChristianMurphy, about eslint tooling, and dang do I wish I knew about https://github.com/IanVS/eslint-nibble before this! I had a watch running eslint every two minutes, and a live-server continually refreshing the results of the run. Kinda hacky but it worked for this.

I had linter running in Atom though, which made fixing the individual errors much easier.

@@ -102,24 +102,35 @@
],
"rules": {
"angular/angularelement": "error",
"angular/di": "error",
"angular/di-order": "error",
"angular/di": "warn",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Google's standard is to use function syntax rather than array syntax for dependency injection. However, IIRC function syntax was not always available, and I'm guessing that we kept using array syntax due to momentum.

We believe that eventually we'd like to switch to function syntax to comply with Google's standard. We should backlog a discussion about this. @ChristianMurphy mentioned that array syntax is actually useful for minifiers to be able to minify DI variables.

"angular/di": "error",
"angular/di-order": "error",
"angular/di": "warn",
"angular/di-order": "warn",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mostly stylistic, so it can stand to be a warning for now. We intend to bite the bullet at some point and flip this back to error.

"angular/di-unused": "error",
"angular/document-service": "error",
"angular/log": "error",
"angular/module-dependency-order": "error",
"angular/no-service-method": "error",
"angular/no-services": "error",
"angular/no-services": "warn",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We ran into a legacy usage of $q.all() and determined it was outside the scope of this pull request to fix it. We should backlog that fix and flip this back to error as soon as it's done.

package.json Outdated
"max-len": [
"error",
{
"code": 120,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one's my own subjective opinion, I welcome a challenge to this. I feel that a line length of 80 is far too short for programming today. In recent years we've shifted to value descriptive function and variable names. Combine that with the base level of indentation in files, and I believe this rule becomes unnecessarily restrictive to developers. I feel that upping the line length by 40 to 120 gives developers room to breathe, but keeps files to a reasonable width.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd favor not making an exception around line length. descriptive function and variable names are good -- and refactoring to better abstractions when 80 characters feels restrictive is good too.

I agree it's a question of style. The meta-value in not making exceptions about style is high. The first rule of code-style-club is don't talk about code-style-club. -0.9.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good enough for me. This was one of the first rules I changed to drop the number of errors I had to contend with. I'm going to drop it back down to 80 locally and see if fixing that is feasible now that I fixed everything else.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm in favor of the expanded line width. Given the size of modern monitors, and the fact that we don't code on punch cards anymore - my .02 is that an 80 character limit feels archaic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm willing to put in a little extra effort to adhere closely to the Google spec now. If we feel it's a hindrance in the future, we'll be better informed to make that decision then.

package.json Outdated
"no-new-symbol": "off",
"no-this-before-super": "off",
"no-invalid-this": "off",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a rule in base eslint:recommended that causes some trouble when used with Angular. It's common practice to use this within the controller function.

Copy link
Contributor

@ChristianMurphy ChristianMurphy Mar 23, 2017

Choose a reason for hiding this comment

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

Interesting I wasn't aware the project is using the this controller convention.
the angular/controller-as rule in eslint-plugin-angular might be a good addition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I jumped the gun on that. @thevoiceofzeke any thoughts on this? A quick ctrl-f seems to imply we assign scope variables in controllers far more often than we use this

Copy link
Contributor

@thevoiceofzeke thevoiceofzeke Mar 24, 2017

Choose a reason for hiding this comment

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

It's a mixed bag throughout the project. My personal preference is to use controllerAs: 'vm' and var vm = this, avoiding $scope and this entirely (something I picked up from the johnpapa Angular style guide. This project is a long, long way from that though.

In general I'm in favor of avoiding this inside angular controllers.

Copy link
Contributor

Choose a reason for hiding this comment

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

@davidmsibley @thevoiceofzeke @apetro
If you are targeting johnpapa's styleguide I would recommend removing all the custom angular configuration I put in place and instead add eslint-config-angular.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd be up for that, but possibly as its own effort. I dropped that in to my local and it looks like we're about 350 errors away from johnpapa's ideal.

package.json Outdated
"no-var": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"require-jsdoc": "error",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is standard, but I added it here to show the difference between just having JSDoc comments, and making sure JSDoc comments are perfect.

Copy link
Contributor

Choose a reason for hiding this comment

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

personally I prefer to keep the rules section set only with rules that are being customized, but thats just me. 🤷‍♂️

package.json Outdated
"no-var": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"require-jsdoc": "error",
"valid-jsdoc": "warn",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having correct, well formatted docs is a goal of ours, but outside the scope of this pull request. I wasn't confident in my ability to comment the code correctly. We should work on cleaning up the comments bit by bit, and flip this back to error.

Copy link
Contributor

Choose a reason for hiding this comment

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

@davidmsibley If complete and accurate JSDocs are a goal, eslint-plugin-jsdoc can offer some additional suggestions past what ESLint offers by default.

@ChristianMurphy
Copy link
Contributor

ChristianMurphy commented Mar 23, 2017

I can't seem to find the comment, but I got the email, @ChristianMurphy, about eslint tooling, and dang do I wish I knew about https://github.com/IanVS/eslint-nibble before this! I had a watch running eslint every two minutes, and a live-server continually refreshing the results of the run. Kinda hacky but it worked for this.

@davidmsibley I deleted the comment after I realized all the work was already done.
I posted a bit too late for this PR, sorry about that. 😞

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 29.91% when pulling 96040c1 on davidmsibley:master into ccadb66 on UW-Madison-DoIT:master.

@apetro
Copy link
Contributor

apetro commented Mar 23, 2017

@ChristianMurphy wrt #601 (comment) , it's just as much that we (and I'll take responsibility, I) communicated too late about the intention to do this work as it is you posted your solution too late.

I think there's going to be a learning curve, a transition period in how tactical plans are created and communicated as we all learn to treat AngularJS-portal more like a community open source product and less only as a MyUW team product. That's going to be a little messy and that's going to have to be okay. This PR, besides being an important step forward on its substantive merits, also is a meta-reminder of the opportunities in continuing to evolve how AngularJS-portal is developed.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.9%) to 29.789% when pulling 0df3aef on davidmsibley:master into ccadb66 on UW-Madison-DoIT:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.9%) to 29.789% when pulling 0df3aef on davidmsibley:master into ccadb66 on UW-Madison-DoIT:master.

@davidmsibley davidmsibley merged commit bac2104 into uPortal-Attic:master Mar 24, 2017
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.

7 participants