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
Upgrade Eslint from 3.18.0 to 4.19.0 #4820
Conversation
Update Fork
Update Fork
Update Fork
Update Fork
Update Fork
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.
Thanks!
Hi @seanlip! Since the indent rule became more strict, a number of files had to be fixed although all indentation parameters are still the same. We can continue to use the 3.X indent rule by
Therefore I have fixed all such indent errors occurring with the new indent rule. |
@seanlip: I found out that |
So, I found out that |
Codecov Report
@@ Coverage Diff @@
## develop #4820 +/- ##
===========================================
+ Coverage 44.71% 44.74% +0.03%
===========================================
Files 385 387 +2
Lines 23478 23515 +37
Branches 3794 3799 +5
===========================================
+ Hits 10498 10522 +24
- Misses 12980 12993 +13
Continue to review full report at Codecov.
|
Hi @apb7, I believe this was done for future implementation of this feature. It's using the default rules and is activated in Lines 5 to 8 in 3b1df68
If you are having trouble, did the migration guide help? |
Hi @kevinlee12! I did follow the migration guide. The problem is one of the dependencies, ajv is obsolete and therefore the html plugin does not install. The Travis log was:. |
Hi @seanlip and @kevinlee12! We need to update |
I have no objection. We can delete the Travis cache whenever you like.
… |
Okay, got it! I will try clearing the cache once. |
@seanlip: I found a way around it. Instead of clearing cache, I have added the required dependencies to the Travis environment. OnceTravis caches these dependencies, I will remove these statements. |
Hello @seanlip! Is this good to merge now? |
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.
Hi @apb7 -- I just took a quick look and noticed a few more things. Comments inline! Sorry for not bringing them up earlier.
@@ -54,7 +54,7 @@ oppia.factory('CollectionCreationService', [ | |||
}, function() { | |||
$rootScope.loadingMessage = ''; | |||
} | |||
); | |||
); |
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 seems weird. Why is it indented at this level?
EDIT: Ah, it's because that's where the left paren opens. In this case move this to the end of the previous line.
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.
Okay, got it!
ratingValue < $scope.stars[i].value - 0.75 ? 'fa-star-o' : | ||
ratingValue < $scope.stars[i].value - 0.25 ? 'fa-star-half-o' : | ||
'fa-star'); | ||
ratingValue < $scope.stars[i].value - 0.75 ? 'fa-star-o' : |
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.
Is there a way to force indent to happen only after "(", "[" and "{", but not be triggered by ":" or "?" or "&&", or ...?
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.
Looking into this!
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 did look into this. Eslint does not provide any such option to force indent.
Thanks!
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.
Sorry -- what I meant was more along the lines of, preventing additional indenting after ":", "?", etc. I'm not sure it makes sense for those things to start a "new scope", as brackets do.
Did this behaviour change recently with eslint? Is it worth writing a custom rule?
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 found out that there exists an option for ternary expressions, flatTernaryExpresions
which is false by default. I have set it to true now. This would fix this problem.
@@ -148,7 +148,7 @@ oppia.factory('StateGraphLayoutService', [ | |||
if (numBacktrackingCalls <= MAX_BACKTRACKING_CALLS) { | |||
for (var i = 0; i < adjacencyLists[currentNodeId].length; i++) { | |||
if (currentPath.indexOf( | |||
adjacencyLists[currentNodeId][i]) === -1) { | |||
adjacencyLists[currentNodeId][i]) === -1) { |
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.
Would be nice to have custom rule that indents this additionally by 2 (since the if clause spans a continuation line), similar to Python. OK to do this in a separate pass.
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.
Sure, I have added it to my draft :)
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.
@seanlip: I tried this out but the present indent rule raises an error if we indent L151 further by 2 spaces. Since consistency is still maintained throughout the codebase, we can adopt these indent settings. How does this sound?
Thanks!
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.
If there isn't a way to enforce the "additional indent by 2" (similar to https://legacy.python.org/dev/peps/pep-0008/#indentation for python) then I'm fine with the new convention.
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 offers indent-legacy
rule but at the same time, their official documentation states:
The indent-legacy rule is deprecated and will not receive bugfixes or improvements in the future, so you should eventually switch back to the indent rule.
To address: We recommend upgrading without changing your indent configuration, and fixing any new indentation errors that appear in your codebase.
Therefore I think it would be better if we adopted the new convention.
Thanks!
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.
OK, happy to defer to your call. Thanks for the explanation!
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.
Great! Let's go ahead with the new convention then. Thanks :)
expect(testOutcome3.isConfusing(currentState)).toBe(false); | ||
expect(testOutcome4.isConfusing(currentState)).toBe(true); | ||
expect(testOutcome5.isConfusing(currentState)).toBe(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.
See above - can we avoid having } come above ) with the same level of indentation? Looks weird. If this is needed, move ) to the end of the previous line instead.
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 am presently moving ) to the previous line. I'll look for a solution for it.
@@ -25,19 +25,19 @@ describe('Outcome object factory', function() { | |||
|
|||
it('should correctly determine if an outcome is confusing given a ' + |
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.
Probably should break after '(' since the contents of the paren span more than one line?
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.
We currently do not have any rule implemented for this. I am working on a custom rule to take care of this. I will make a separate PR for it. :)
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.
In the meantime shall we break it? Odd for the function() two lines below to have the same indentation level as it().
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.
Yes, that sounds greate! I will take care of it.
text: 'Weighted', | ||
option: 'isWeighted' | ||
}]; | ||
{ |
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.
Woah. What happened here?
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 very weird! Looking into such indentations (I found a few above too). I am not too sure why this is occurring unless it is a false positive.
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.
@seanlip: I tried out various 4.X versions, namely 4.7.0, 4.18.0, 4.18.1, 4.18.2 but the indent
rule seems to produce the same result. The indent-legacy
rule works perfectly fine though. What should we do here then?
Thanks!
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 have shifted { to the next line. This fixes the indentation (as suggested in Issue #10106 by the Eslint team).
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 read their response differently. I think you're missing some kind of config option. The following should be valid and we need to find a way to make it so.
$scope.graphOptions = [{
text: 'Labeled',
option: 'isLabeled'
},
{
text: 'Directed',
option: 'isDirected'
},
{
text: 'Weighted',
option: 'isWeighted'
}];
Also, the following should be valid (and is preferable due to compactness):
$scope.graphOptions = [{
text: 'Labeled',
option: 'isLabeled'
}, {
text: 'Directed',
option: 'isDirected'
}, {
text: 'Weighted',
option: 'isWeighted'
}];
So some linter changes are needed in that regard.
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.
Yes, you're right. There must be some way to get around that configuration. I'll look through the existing rules once. Thanks!
@@ -54,7 +54,7 @@ oppia.factory('CollectionCreationService', [ | |||
}, function() { | |||
$rootScope.loadingMessage = ''; | |||
} | |||
); | |||
); |
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.
Okay, got it!
ratingValue < $scope.stars[i].value - 0.75 ? 'fa-star-o' : | ||
ratingValue < $scope.stars[i].value - 0.25 ? 'fa-star-half-o' : | ||
'fa-star'); | ||
ratingValue < $scope.stars[i].value - 0.75 ? 'fa-star-o' : |
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.
Looking into this!
@@ -148,7 +148,7 @@ oppia.factory('StateGraphLayoutService', [ | |||
if (numBacktrackingCalls <= MAX_BACKTRACKING_CALLS) { | |||
for (var i = 0; i < adjacencyLists[currentNodeId].length; i++) { | |||
if (currentPath.indexOf( | |||
adjacencyLists[currentNodeId][i]) === -1) { | |||
adjacencyLists[currentNodeId][i]) === -1) { |
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.
Sure, I have added it to my draft :)
@@ -25,19 +25,19 @@ describe('Outcome object factory', function() { | |||
|
|||
it('should correctly determine if an outcome is confusing given a ' + |
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.
We currently do not have any rule implemented for this. I am working on a custom rule to take care of this. I will make a separate PR for it. :)
expect(testOutcome3.isConfusing(currentState)).toBe(false); | ||
expect(testOutcome4.isConfusing(currentState)).toBe(true); | ||
expect(testOutcome5.isConfusing(currentState)).toBe(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.
I am presently moving ) to the previous line. I'll look for a solution for it.
{ | ||
id: 'q456', | ||
status: 'processing' | ||
}]; |
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.
Ditto!
{ | ||
id: 'q456', | ||
status: 'processing' | ||
}]; |
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.
Ditto!
{ | ||
id: 'q456', | ||
status: 'processing' | ||
}]; |
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.
Same weird indent!
text: 'Weighted', | ||
option: 'isWeighted' | ||
}]; | ||
{ |
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 very weird! Looking into such indentations (I found a few above too). I am not too sure why this is occurring unless it is a false positive.
Talk to the eslint folks perhaps? Not sure if this behaviour is intentional
on their end.
Worst case, we could write our own lint check.
|
Hi @seanlip! I have made the review changes. Can you please review this once again? |
$filter('convertUnicodeToHtml')(fragment.data) : | ||
'<oppia-parameter>' + fragment.data + | ||
$filter('convertUnicodeToHtml')(fragment.data) : | ||
'<oppia-parameter>' + fragment.data + |
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.
Not sure I understand the indentation logic here.
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.
Looking into the ternary operators. Thanks!
@@ -25,19 +25,19 @@ describe('Outcome object factory', function() { | |||
|
|||
it('should correctly determine if an outcome is confusing given a ' + |
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.
In the meantime shall we break it? Odd for the function() two lines below to have the same indentation level as it().
expect(successHandler).not.toHaveBeenCalled(); | ||
expect(failHandler).toHaveBeenCalledWith(jasmine.objectContaining( | ||
{data : 'Error loading dashboard IDs data.'})); | ||
} |
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.
move ) below to end of this line?
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.
Got it, thanks!
@@ -234,7 +234,7 @@ describe('Testing filters', function() { | |||
expect(filter(897978581123)).toEqual('898.0B'); | |||
expect(filter(476678)).toEqual('476.7K'); | |||
} | |||
)); | |||
)); |
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.
Ditto (and please check elsewhere too)
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.
Sure, got it!
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.
Hi @seanlip! I have noted down the review changes. I'm planning to close this PR and create a new one since I need to make changes to the existing rules. Does this sound good?
Thanks!
text: 'Weighted', | ||
option: 'isWeighted' | ||
}]; | ||
{ |
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.
Yes, you're right. There must be some way to get around that configuration. I'll look through the existing rules once. Thanks!
Sure, not a problem. Not sure I understand why you need to create a new PR, but I'm happy either way. (Also, you don't really need to ask permission for things like this -- in general, feel free to handle PRs as you see fit. Thanks!) |
Most of the files have to be checked and fixed once again since the rules have to be modified though we can reset the changes but I think a PR on a fresh branch would be more easy. |
Explanation
This PR upgrades Eslint to the latest version so that new rules available in the 4.X versions can be utilized. The major change occurs in the indentation. All indentation errors have been fixed.
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.