mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.38k stars 9.97k forks source link

Upgrade `eslint` to version 9.0.0 #17928

Open timvandermeij opened 6 months ago

timvandermeij commented 6 months ago

We should upgrade to ESLint 9 now that it's officially released. The changelog, including the breaking changes that should be audited, can be found at https://github.com/eslint/eslint/releases/tag/v9.0.0. Note that this upgrade is currently blocked on the ESLint plugins that we use indicating support for ESLint 9 in their package.json ranges first, so this is mostly a tracking issue at the moment.

wojtekmaj commented 6 months ago

Let's make it a tracking issue then :D

Plugins

Plugin name Update status Development status Issue Comments
eslint-plugin-import ✅ 78bf5287d17311e61bbeae23d281dbaf4da1925a ✅ Implemented https://github.com/import-js/eslint-plugin-import/issues/2948 Worth considering a switch to eslint-plugin-import-x, much more reasonably maintained alternative
eslint-plugin-jasmine ✅ 764e67e861704484423a9ce3051acb98553992e7 ✅ Implemented https://github.com/tlvince/eslint-plugin-jasmine/commit/f9e079811252185304761e402fee28d1678986db
eslint-plugin-json ✅ Implemented https://github.com/azeemba/eslint-plugin-json/issues/80 Update blocked by eslint-plugin-mozilla support for v4.0.0
eslint-plugin-no-unsanitized ✅ ae13b4a01571c73c6d451cb36bc66b21f6d996d2 ✅ Implemented https://github.com/mozilla/eslint-plugin-no-unsanitized/issues/234 Released in v4.1.0
eslint-plugin-sort-exports ❓ Unknown n/a
eslint-plugin-unicorn ✅ d7f2bc044aaa25376d68ec35696561497d0aa50e ✅ Implemented https://github.com/sindresorhus/eslint-plugin-unicorn/pull/2250
timvandermeij commented 5 months ago

In commit d7f2bc044aaa25376d68ec35696561497d0aa50e eslint-plugin-unicorn got upgraded to version 53.0.0 which contains support for ESLint 9, so we can cross that one off the list.

nicolo-ribaudo commented 5 months ago

If you haven't already seen https://eslint.org/blog/2024/05/eslint-compatibility-utilities/, it might be useful for this. It provides wrappers to run ESLint 8 plugins in ESLint 9.

mozfreddyb commented 4 months ago

I can comment for eslint-plugin-no-unsanitized: It's planned but blocked on dependencies (heh) https://github.com/mozilla/eslint-plugin-no-unsanitized/issues/241

timvandermeij commented 4 months ago

eslint-plugin-json 4.0.0 is now released and contains ESLint 9 support (see https://github.com/azeemba/eslint-plugin-json/commit/0ff302cadbd6a995089be756c5f8660001e45f29), but we can't update to it yet because eslint-plugin-mozilla has not indicated support for version 4.0.0 in package.json yet:

npm error While resolving: eslint-plugin-mozilla@3.7.4
npm error Found: eslint-plugin-json@4.0.0
npm error node_modules/eslint-plugin-json
npm error   dev eslint-plugin-json@"^4.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer eslint-plugin-json@"^3.1.0" from eslint-plugin-mozilla@3.7.4
npm error node_modules/eslint-plugin-mozilla
npm error   dev eslint-plugin-mozilla@"^3.7.4" from the root project
npm error
npm error Conflicting peer dependency: eslint-plugin-json@3.1.0
npm error node_modules/eslint-plugin-json
npm error   peer eslint-plugin-json@"^3.1.0" from eslint-plugin-mozilla@3.7.4
npm error   node_modules/eslint-plugin-mozilla
npm error     dev eslint-plugin-mozilla@"^3.7.4" from the root project
timvandermeij commented 4 months ago

In commit c77dbe04966111b8b80383e8befa8d4f9438a346 eslint-plugin-jasmine got updated to version 4.2.0 which contains support for ESLint 9, so we can cross that one off the list.

timvandermeij commented 2 months ago

In PR #18571 the idea came up of trying to remove eslint-plugin-mozilla given that we only used three rules from it and after that PR we are down to two: one at https://github.com/mozilla/pdf.js/blob/master/extensions/chromium/.eslintrc#L19 and one at https://github.com/mozilla/pdf.js/blob/master/.eslintrc#L47. The latter is already covered by an existing unicorn rule, and the former may be removed in favor of explicitly documenting the remaining globals we have left. Note that when eslint-plugin-mozilla was introduced in https://github.com/mozilla/pdf.js/commit/2e9ae50a3a9c1f4fa0b9d8166445ebd89d3a450f there were more occurrences than nowadays, mainly because we don't have Firefox extension files in this repository anymore and we eliminated most globals usage.

We should check if this is possible since it would unblock the eslint-plugin-json update and that combined with the removal of eslint-plugin-mozilla would bring us two steps closer to ESLint 9. Note that we can't actually upgrade eslint-plugin-json yet because that version only supports ESLint 9 and isn't backwards compatible with ESLint 8, but it would remove the blocker.

timvandermeij commented 2 months ago

In commit https://github.com/mozilla/pdf.js/commit/be93d530deab4a1d9a4ad795ee0c80b7fa9ae119 eslint-plugin-mozilla got removed, so we also can cross that one off the list.

mozfreddyb commented 1 month ago

no-unsanitized now supports eslint 9. We just released a new version earlier in the week.

timvandermeij commented 2 weeks ago

In commit https://github.com/mozilla/pdf.js/pull/18708/commits/ae13b4a01571c73c6d451cb36bc66b21f6d996d2 eslint-plugin-no-unsanitized got updated to version 4.1.0 which contains support for ESLint 9, so we can cross that one off the list.

timvandermeij commented 2 weeks ago

In commit https://github.com/mozilla/pdf.js/commit/78bf5287d17311e61bbeae23d281dbaf4da1925a eslint-plugin-import got updated to version 2.31.0 which contains support for ESLint 9, so we can cross that one off the list.

timvandermeij commented 3 days ago

In the PRs above we removed obsolete plugins and replaced eslint-plugin-sort-exports, which should have removed the final blocker for the upgrade here.