-
Notifications
You must be signed in to change notification settings - Fork 3.4k
chore(eslint): Configure ESLint Fixes #9261 #10824
Conversation
|
|
| "wrap-regex": "off", | ||
| "yield-star-spacing": "error", | ||
| "yoda": "off", | ||
| "no-unused-vars": "off", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to turn this off because there's loads of these!
| "jasmine": true | ||
| }, | ||
| "rules": { | ||
| "no-native-reassign": "off", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are you guys doing 🤕
| @@ -1,6 +1,6 @@ | |||
| describe('MdTabsPaginationService', function() { | |||
|
|
|||
| const TAB_WIDTH = 100; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice try at ES2015 support.
You should configure babel properly and use let/const for everything if you're going to use them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgol re: the es6 flag es2015 constructs are banned ^
| case 'layout-margin' : | ||
| case 'layout-fill' : | ||
| case 'layout-wrap' : | ||
| case 'layout-nowrap' : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?????????
| self[colorType + 'Color'] = function() { | ||
| var args = Array.prototype.slice.call(arguments); | ||
| // eslint-disable-next-line no-console | ||
| console.warn('$mdThemingProviderTheme.' + colorType + 'Color() has been deprecated. ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use probably use:
$injector.invoke(['$log', function($log) {
$log.warn(...);
});7648e85 to
1988972
Compare
|
|
||
| self[colorType + 'Color'] = function() { | ||
| var args = Array.prototype.slice.call(arguments); | ||
| // eslint-disable-next-line no-console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want no-console in tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look like a test. We always want no-console because Angular provides a log service
| $scope.currentNavItem = 'page1'; | ||
|
|
||
| $scope.goto = function(page) { | ||
| console.log("Goto " + page); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave console.logs as they are outside of source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's bad form to recommend use of globals that Angular provides injectables for. It leads to the spreading of bad habits
.eslintrc.json
Outdated
| @@ -0,0 +1,271 @@ | |||
| { | |||
| "env": { | |||
| "es6": true | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why enable es6? I think ES5 should be enforced which also means parserOptions.ecmaVersion needs to be set to 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh pretty sure this flag doesn't do anything anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How so? It defines ES2015 globals like Set or Promise. Wed don't want that here as some of our supported environments don't have those globals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well I'm going to remove it anyway
|
I added some comments. At a very first sight this looks good but someone from the Material team should verify, especially with regards to concrete rules defined. cc @ThomasBurleson @EladBezalel |
|
@mgol I auto-generated the rules, it's based on what rules from eslint recommended already pass |
angular-material could definitely do with switching to a stricter styleguide, it's got a lot of inconsistent and redundant stuff in. |
|
I'm confused, #10826 seems to have lots of unrelated commits. Single PRs should be about a single thing as otherwise it's hard to review. There should be one PR for ESLint setup, then another for any |
| @@ -0,0 +1,268 @@ | |||
| { | |||
| "extends": "eslint:recommended", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not extend any built-in preset as they can change. We should define our own rules ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgol eslint:recommended is a very carefully managed preset, and any changes to it are signaled via semver.
|
@ThomasBurleson can I get a review here or #10826 please? |
|
@ThomasBurleson rebased over conflicts |
| options.hideBackdrop = function hideBackdrop($destroy) { | ||
| if (options.backdrop) { | ||
| if ( !!$destroy ) options.backdrop.remove(); | ||
| if ( $destroy ) options.backdrop.remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESLint says that !! should be replaced by Boolean($destroy) for this rule. Is there a reason that you don't think that guidance applies here and in the other instances of this replacement in the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was autofixed. It's because there's no need to coerce with if ( ... )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also no-implicit-coercion is not enabled in eslint:recommended https://eslint.org/docs/rules/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the rule that applied in this location: https://eslint.org/docs/rules/no-extra-boolean-cast
|
Is there an associated issue or forum thread where adding ESLint to the project was discussed? |
Splaktar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good start to me.
|
@Splaktar there's stuff in the merge queue from back in March when are you expecting to actually merge them? |
|
@graingert PRs with the |
|
Needs rebase |
|
@andrewseguin done |
|
@Splaktar how did presubmit go? |
|
Please rebase again |
😡 |
|
@andrewseguin rebased. Can you merge this one in before the others, otherwise I have to fix everyone else's eslint violations each time. |
|
@graingert sorry for the delay and the ordering of the merges, doh. Glad that we got this in though. Thank you! |
No description provided.