-
Notifications
You must be signed in to change notification settings - Fork 146
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 to v8 #3984
Upgrade ESLint to v8 #3984
Conversation
Sadly, we seem blocked by the ESLint config for this project (-dev deps).I think it is because we enable the browser env in our config. Not all ESlint plugins support v8 yet. I am wondering if we could fix our config to avoid relying on some browser (e.g. react) plugins. |
That has been fixed. We don't prevent the installation of some (useless) packages but they are not loaded so there won't be any error, except some npm warnings about peer deps. It is fine, we use a shared config to avoid requiring/updating too many packages in too many repos. |
|
"rules":{ | ||
"no-console": 0, | ||
// Inherited from airbnb via eslint-config-amo | ||
"function-paren-newline": 0 |
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 (and always was) part of the base config.
"function-paren-newline": 0 | ||
"rules": { | ||
// This project uses `console.log()`. | ||
"no-console": "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 find off
a bit easier to understand than 0
. I thought we didn't need this rule but we do so I added 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.
👌 I also prefer the more explicit "off"
"extends": ["amo"], | ||
"parser": "babel-eslint", | ||
"extends": ["amo/base"], | ||
"parser": "@babel/eslint-parser", |
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.
Ha, yeah. That babel-eslint
parser is no longer maintained and it has moved to the babel monorepo. That shouldn't change anything except that we use a maintained version of the same parser.
"@mdn/browser-compat-data": "4.0.7", | ||
"addons-moz-compare": "1.2.0", | ||
"addons-scanner-utils": "5.0.0", | ||
"addons-scanner-utils": "6.1.0", |
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.
Needed to configure ESLint with ES 2022.
"babel-gettext-extractor": "4.1.3", | ||
"babel-jest": "27.3.1", | ||
"babel-loader": "8.2.3", | ||
"codecov": "3.8.3", | ||
"comment-json": "4.1.1", | ||
"doctoc": "2.1.0", | ||
"eslint-config-amo": "4.11.0", | ||
"eslint-config-amo": "5.1.0", |
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.
Needed to use amo/base
instead of amo
.
"expect", | ||
"sinon.assert.*", | ||
"assertHasMatchingError", | ||
"checkMinNodeVersion", |
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 thought I'd go ahead and mute some more warnings. We only have 3 warnings (due to excluded files) 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.
ah, Thank you for taking care of this! ❤️
I did notice those warnings not long time ago and they were kind of bothering me but didn't had the time to look into them.
@@ -2978,11 +2978,13 @@ describe('ManifestJSONParser', () => { | |||
]; | |||
|
|||
for (const invalidUrl of testInvalidUrls) { | |||
// eslint-disable-next-line jest/expect-expect |
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 didn't update the eslint config for these test cases because testHomepageUrl
is fairly specific to this describe
block.
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.
sgtm
// See: https://github.com/tc39/proposal-class-fields | ||
// eslint-disable-next-line jest/no-disabled-tests | ||
it.skip('should support public class fields', async () => { | ||
it('should support public class fields', async () => { |
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.
🔥
@@ -681,7 +681,7 @@ describe('Linter.textOutput()', () => { | |||
addonLinter.textOutput(uselesslyTinyTerminalWidth); | |||
expect(addonLinter.output.summary.errors).toEqual(1); | |||
} catch (e) { | |||
// eslint-disable-next-line jest/no-conditional-expect, jest/no-try-expect | |||
// eslint-disable-next-line jest/no-conditional-expect |
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 filed an issue for that: mozilla/eslint-plugin-no-unsanitized#185 |
@rpl I know |
I looked the PR and it looks in a pretty good shape.
Yesterday I give it a very quick try to that locally before going afk, eslint-plugin-no-unsanitized tests were failing while running on eslint v8, but I haven't looked closely yet to the failures. |
"eslint-plugin-async-await": "0.0.0", | ||
"eslint-plugin-promise": "5.1.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.
not used it seems?
Edit: it is used for the tests actually, and it is likely coming from addons-frontend, see: https://github.com/mozilla/addons-frontend/issues/2065. I'll revert this change.
package.json
Outdated
"babel-gettext-extractor": "4.1.3", | ||
"babel-jest": "27.3.1", | ||
"babel-loader": "8.2.3", | ||
"comment-json": "4.1.1", | ||
"doctoc": "2.1.0", | ||
"eslint-config-amo": "4.11.0", | ||
"eslint-config-amo": "5.1.0", | ||
"eslint-plugin-async-await": "0.0.0", |
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 questioning the usefulness of this plugin: I don't think it is used in most of the other projects and we do use async/await everywhere now. I would like to remove this dev dependency: WDYT?
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.
@willdurand it looks that it does only provides two "code formatting" rules, which I would guess that prettier may also be taking care of. Also the package version is v0.0.0 and last release 5 years ago, definitely 👍 on my side on getting rid of it.
Codecov Report
@@ Coverage Diff @@
## master mozilla/addons-frontend#3984 +/- ##
=======================================
Coverage 98.71% 98.71%
=======================================
Files 52 52
Lines 2652 2652
Branches 799 799
=======================================
Hits 2618 2618
Misses 34 34 Continue to review full report at Codecov.
|
The last commit about removing Removing Apart from that, I'd like to remove |
re-requesting a review not for the review itself but to make sure you see the last comment. |
I switched to v4.0.0 of the |
@rpl for when you have time, this is ready for a review with two caveats:
I am not sure when |
100% agree on For |
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.
@willdurand lgtm, just one detail related to @babel/eslint-parser being listed as a dependency instead of a dev dependency. Everything else looks good to me as is.
I moved the babel parser to the list of dev dependencies and removed the async-await eslint plugin. I also filed an issue for the eslint-plugin-promise: #4016 |
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!
Fixes #3985
Fixes #3062
Fixes #3741
Fixes #3960
This PR upgrades
eslint
to v8, which will allow us to support the 2022 syntax.TODO
addons-scanner-utils
when it supports ESLint v8eslint-config-amo
when it supports ESLint v8