Skip to content
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

BREAKING: Bump ESLint to ^9.11.1, bump related ESLint dependencies, and rewrite configs to use flat configs #370

Merged
merged 29 commits into from
Sep 25, 2024

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Sep 22, 2024

ESLint 8 will be end-of-life from 2024-10-05. ESLint 8 introduced a new config format, which is now the default in ESLint 9, and only opt-out through an environment flag. We could enable that flag and keep the current configs, but it's better to just update the configs now and be done with it.

I've updated all configs to use the new format. The most notable changes are:

  • All ESLint-related dependencies are now on the latest version.
  • All configs now use ESM, as this is now supported out-of-the-box in ESLint 9.
  • I've updated the default ECMAScript version to 2022, which is in line with what the MetaMask extension supports.
  • Each config now includes a TypeScript declaration file to support type-checking.

Closes #362.

Breaking changes

All configs

  • All packages are now pure ESM, and cannot be imported from a CJS configuration.
    • ESLint 9 supports ESM configurations out of the box.
  • The minimum ESLint version is now ^9.11.0, and all configs were updated to use the flat config format.
  • All dependencies have been updated, so some rules have been replaced or removed.

@metamask/eslint-config-typescript

  • @typescript-eslint/parser and @typescript-eslint/eslint-plugin are replaced with typescript-eslint@^8.6.0, which is now a peer dependency.
  • For proper linting using type information, languageOptions.parserOptions.tsconfigRootDir must be set to the current directory, e.g., using import.meta.dirname.

Copy link

socket-security bot commented Sep 22, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@ampproject/remapping@2.2.1 None 0 76 kB jridgewell
npm/@babel/plugin-syntax-jsx@7.22.5 None 0 4.13 kB nicolo-ribaudo
npm/@babel/plugin-syntax-typescript@7.22.5 None 0 6.86 kB nicolo-ribaudo
npm/@es-joy/jsdoccomment@0.48.0 None 0 121 kB brettz9
npm/@eslint-community/regexpp@4.11.1 None 0 446 kB eslint-community-bot
npm/@eslint/config-array@0.18.0 None 0 113 kB eslintbot
npm/@eslint/eslintrc@3.1.0 filesystem, unsafe 0 668 kB eslintbot
npm/@eslint/js@9.11.0 None 0 14.2 kB eslintbot, openjsfoundation
npm/@eslint/object-schema@2.1.4 None 0 55.5 kB eslintbot
npm/@eslint/plugin-kit@0.2.0 None 0 76.7 kB eslintbot
npm/@humanwhocodes/retry@0.3.0 None 0 44.3 kB nzakas
npm/@types/eslint__js@8.42.3 None 0 3.17 kB types
npm/@types/eslint@9.6.1 None 0 196 kB types
npm/@types/json-schema@7.0.15 None 0 31.7 kB types
npm/@types/node@22.5.5 None 0 2.2 MB types
npm/@typescript-eslint/eslint-plugin@8.6.0 None 0 2.63 MB bradzacher, jameshenry
npm/@typescript-eslint/parser@8.6.0 None 0 18.7 kB jameshenry
npm/@typescript-eslint/scope-manager@8.6.0 None 0 602 kB jameshenry
npm/@typescript-eslint/type-utils@8.6.0 None 0 121 kB jameshenry
npm/@typescript-eslint/types@8.6.0 None 0 171 kB jameshenry
npm/@typescript-eslint/typescript-estree@8.6.0 None 0 588 kB jameshenry
npm/@typescript-eslint/utils@8.6.0 None 0 282 kB jameshenry
npm/@typescript-eslint/visitor-keys@8.6.0 None 0 19.5 kB bradzacher, jameshenry
npm/acorn@8.12.1 None 0 538 kB marijn
npm/browserslist@4.23.3 environment, filesystem 0 63 kB ai
npm/caniuse-lite@1.0.30001662 None 0 2.1 MB ai, beneb, caniuse-lite
npm/debug@4.3.7 environment 0 42.1 kB qix
npm/electron-to-chromium@1.5.27 None 0 148 kB kilianvalkhof
npm/enhanced-resolve@5.17.1 unsafe 0 212 kB evilebottnawi
npm/es-module-lexer@1.5.4 None 0 90.9 kB guybedford
npm/eslint-config-prettier@9.1.0 None 0 20.8 kB lydell
npm/eslint-plugin-import-x@4.3.0 None 0 683 kB jounqin
npm/eslint-plugin-jest@28.8.3 filesystem 0 349 kB aaronabramov, jeysal, jsonp, ...6 more
npm/eslint-plugin-jsdoc@50.2.4 None 0 2.08 MB gajus
npm/eslint-plugin-n@17.10.3 None 0 437 kB eslint-community-bot, weiran.zsd
npm/eslint-plugin-prettier@5.2.1 None 0 34.3 kB jounqin
npm/eslint-plugin-promise@7.1.0 None 0 77.7 kB eslint-community-bot
npm/eslint-scope@8.0.2 None 0 148 kB eslintbot
npm/eslint@9.11.0 environment 0 3.3 MB eslintbot
npm/espree@10.1.0 None 0 76.5 kB eslintbot
npm/esquery@1.6.0 None 0 1.04 MB michaelficarra
npm/file-entry-cache@8.0.0 filesystem 0 16 kB jaredwray
npm/flat-cache@4.0.1 filesystem 0 29.3 kB jaredwray
npm/flatted@3.3.1 None 0 40.3 kB webreflection
npm/get-tsconfig@4.8.1 filesystem 0 105 kB hirokiosame
npm/globals@15.9.0 None 0 174 kB sindresorhus
npm/globby@13.2.2 None 0 25.1 kB sindresorhus
npm/graceful-fs@4.2.11 environment, filesystem 0 32.5 kB isaacs
npm/ignore@5.3.2 None 0 53.6 kB kael
npm/jsdoc-type-pratt-parser@4.1.0 None 0 245 kB jsdoc-type-pratt-parser
npm/json-buffer@3.0.1 None 0 5.4 kB dominictarr
npm/keyv@4.5.4 None 0 27.8 kB jaredwray
npm/ms@2.1.3 None 0 6.72 kB styfle
npm/node-gyp@10.2.0 environment, shell 0 1.85 MB nodejs-foundation
npm/parse-imports@2.2.1 None 0 39.1 kB tomeraberbach
npm/prettier-plugin-packagejson@2.5.2 None 0 5.55 kB matzkoh
npm/prettier@3.3.3 environment, filesystem, unsafe 0 7.7 MB prettier-bot
npm/slashes@3.0.12 None 0 26 kB chrisackerman
npm/socks@2.8.3 network 0 156 kB joshglazebrook
npm/sort-package-json@2.10.1 None 0 33.3 kB keithamus
npm/stable-hash@0.0.4 None 0 5.46 kB quietshu
npm/synckit@0.9.1 environment 0 55.7 kB jounqin
npm/tapable@2.2.1 None 0 46.9 kB sokra
npm/tslib@2.7.0 None 0 86.2 kB typescript-bot
npm/typescript-eslint@8.6.0 None 0 99.5 kB jameshenry

🚮 Removed packages: npm/@eslint-community/regexpp@4.10.0, npm/@eslint/eslintrc@3.0.2, npm/@eslint/js@8.57.0, npm/@humanwhocodes/config-array@0.11.14, npm/@humanwhocodes/object-schema@2.0.2, npm/@typescript-eslint/eslint-plugin@8.7.0, npm/@typescript-eslint/parser@8.7.0, npm/@typescript-eslint/scope-manager@7.12.0, npm/@typescript-eslint/types@7.12.0, npm/@typescript-eslint/typescript-estree@7.12.0, npm/@typescript-eslint/utils@7.12.0, npm/@typescript-eslint/visitor-keys@7.12.0, npm/acorn@8.11.3, npm/debug@4.3.4, npm/escalade@3.1.1, npm/eslint-plugin-import-x@0.5.1, npm/eslint-plugin-jest@27.9.0, npm/eslint-plugin-n@16.6.2, npm/eslint-plugin-promise@6.1.1, npm/eslint-visitor-keys@4.0.0, npm/eslint@8.57.0, npm/espree@10.0.1, npm/esquery@1.5.0, npm/flat-cache@3.0.4, npm/flatted@3.2.6, npm/get-tsconfig@4.7.5, npm/globals@15.0.0, npm/graceful-fs@4.2.10, npm/ignore@5.3.1, npm/ms@2.1.2, npm/node-gyp@10.1.0, npm/prettier-plugin-packagejson@2.5.0, npm/semver@7.6.2, npm/socks@2.8.1, npm/sort-package-json@2.10.0, npm/synckit@0.9.0, npm/tslib@2.6.2

View full report↗︎

Copy link

socket-security bot commented Sep 22, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: npm/eslint-plugin-jest@28.8.3, npm/node-gyp@10.2.0

View full report↗︎

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

@Mrtenz Mrtenz changed the title Bump ESLint to ^9.11.1, bump related ESLint dependencies, and rewrite configs to use flat configs BREAKING: Bump ESLint to ^9.11.1, bump related ESLint dependencies, and rewrite configs to use flat configs Sep 22, 2024
@Mrtenz Mrtenz changed the base branch from main to mrtenz/drop-nodejs-16-support September 23, 2024 09:35
Base automatically changed from mrtenz/drop-nodejs-16-support to main September 23, 2024 09:57
@Mrtenz Mrtenz mentioned this pull request Sep 23, 2024
@Mrtenz
Copy link
Member Author

Mrtenz commented Sep 23, 2024

@SocketSecurity ignore npm/agentkeepalive@4.5.0
@SocketSecurity ignore npm/make-fetch-happen@10.2.1

Network access expected.

@SocketSecurity ignore npm/@npmcli/fs@2.1.2
@SocketSecurity ignore npm/nopt@6.0.0
@SocketSecurity ignore npm/npmlog@6.0.2
@SocketSecurity ignore npm/unique-slug@3.0.0

New author is ok.

@SocketSecurity ignore npm/gauge@4.0.4
@SocketSecurity ignore npm/@npmcli/move-file@2.0.1
@SocketSecurity ignore npm/are-we-there-yet@3.0.1

Deprecated is ok.

@SocketSecurity ignore npm/eslint-plugin-jest@28.8.3

Seems like a false positive.

Copy link
Member Author

Choose a reason for hiding this comment

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

This script doesn't have the same functionality as the previous script. It's a bit hard to follow what exactly it was doing, so for the time being, this script simply checks and writes snapshots.

@Mrtenz Mrtenz marked this pull request as ready for review September 23, 2024 12:33
@Mrtenz Mrtenz requested review from a team as code owners September 23, 2024 12:33
tsconfig.json Outdated Show resolved Hide resolved
@@ -6,38 +6,50 @@
"type": "git",
"url": "https://github.com/MetaMask/eslint-config.git"
},
"type": "module",

Choose a reason for hiding this comment

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

Is this safe because consumers always use this package as a devDep? Are we sure this doesn't affect downstream CJS packages?

Choose a reason for hiding this comment

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

Looking at the eslint v9 migrate guide, looks like we only need to worry about CJS configurations importing from our repo, and that shouldn't be a problem for long since eslint is now set up to use ESM by default?

Copy link
Member Author

Choose a reason for hiding this comment

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

Consumers can add it and use it even if they use type: commonjs, as long as the config is a .mjs file. I figured we might as well update all places where we consume the libraries since we have to rewrite the majority of the configs anyway.

@MajorLift
Copy link

@metamaskbot publish-preview

package.json Outdated Show resolved Hide resolved
@Mrtenz
Copy link
Member Author

Mrtenz commented Sep 24, 2024

@SocketSecurity ignore npm/node-gyp@10.2.0

New author is ok.

Copy link

@MajorLift MajorLift left a comment

Choose a reason for hiding this comment

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

LGTM! Confirmed that the updated config packages can be installed and are functional downstream. IMO any further fixes that may or may not be needed can be handled in separate PRs.

@Mrtenz Mrtenz merged commit ff9780d into main Sep 25, 2024
13 checks passed
@Mrtenz Mrtenz deleted the mrtenz/eslint-9 branch September 25, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESLint config format is deprecated
2 participants