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

Bump ESLint and related dependencies #254

Merged
merged 2 commits into from
Nov 6, 2024
Merged

Bump ESLint and related dependencies #254

merged 2 commits into from
Nov 6, 2024

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Nov 4, 2024

ESLint 8 and the legacy config format are EOL. In this PR I've updated ESLint to v9, and bumped all related dependencies (ESLint configs, Prettier, auto-changelog), and rewritten the config to use the flat config format.

@Mrtenz Mrtenz requested a review from a team as a code owner November 4, 2024 12:15
Copy link

socket-security bot commented Nov 4, 2024

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

Package New capabilities Transitives Size Publisher
npm/@es-joy/[email protected] None 0 121 kB brettz9
npm/@eslint-community/[email protected] None 0 378 kB eslint-community-bot, michaeldeboey
npm/@eslint-community/[email protected] None 0 473 kB eslint-community-bot, michaeldeboey
npm/@eslint/[email protected] None 0 113 kB eslintbot
npm/@eslint/[email protected] None 0 36.3 kB eslintbot
npm/@eslint/[email protected] filesystem, unsafe Transitive: environment +4 1.44 MB eslintbot
npm/@eslint/[email protected] None 0 14.6 kB eslintbot
npm/@eslint/[email protected] None 0 55.5 kB eslintbot
npm/@eslint/[email protected] None 0 76.5 kB eslintbot, openjsfoundation
npm/@humanfs/[email protected] None 0 72.7 kB nzakas
npm/@humanfs/[email protected] None +1 89.5 kB nzakas
npm/@humanwhocodes/[email protected] None 0 64.7 kB nzakas
npm/@metamask/[email protected] None 0 211 kB metamaskbot
npm/@metamask/[email protected] None 0 12.2 kB metamaskbot
npm/@metamask/[email protected] unsafe 0 98.4 kB metamaskbot
npm/@metamask/[email protected] None 0 22.7 kB metamaskbot
npm/@metamask/[email protected] unsafe 0 130 kB metamaskbot
npm/@nolyfill/[email protected] unsafe 0 2.71 kB sukkaw
npm/@pkgr/[email protected] None 0 8.54 kB jounqin
npm/@shikijs/[email protected] None 0 107 kB antfu
npm/@shikijs/[email protected] None 0 10.2 kB antfu
npm/@shikijs/[email protected] None 0 648 kB antfu
npm/@shikijs/[email protected] None 0 60.6 kB antfu
npm/@shikijs/[email protected] None 0 126 kB antfu
npm/@types/[email protected] None 0 25.8 kB types
npm/@types/[email protected] None 0 9.7 kB types
npm/@types/[email protected] None 0 31.7 kB types
npm/@types/[email protected] None 0 29.4 kB types
npm/@typescript-eslint/[email protected] None 0 2.69 MB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] None 0 18.8 kB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] None 0 606 kB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] None 0 122 kB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] None 0 173 kB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] None 0 591 kB jameshenry
npm/@typescript-eslint/[email protected] None 0 284 kB bradzacher, jameshenry
npm/@typescript-eslint/[email protected] None +1 51.5 kB bradzacher, jameshenry
npm/@ungap/[email protected] None 0 26.2 kB webreflection
npm/[email protected] None 0 547 kB marijn
npm/[email protected] None 0 13.6 kB joshuakgoldberg
npm/[email protected] None 0 7.34 kB wooorm
npm/[email protected] None 0 11.4 kB wooorm
npm/[email protected] None 0 9.14 kB wooorm
npm/[email protected] None 0 9.97 kB wooorm
npm/[email protected] None 0 366 kB yavorskiys
npm/[email protected] None 0 14.2 kB lukeed
npm/[email protected] None 0 22 kB wooorm
npm/[email protected] unsafe 0 212 kB evilebottnawi
npm/[email protected] None 0 413 kB feedic
npm/[email protected] None 0 90.9 kB guybedford
npm/[email protected] filesystem 0 53.1 kB ota-meshi
npm/[email protected] None 0 20.8 kB lydell
npm/[email protected] None 0 46.8 kB jounqin
npm/[email protected] None 0 54.6 kB benmosher, jfmengels, ljharb
npm/[email protected] None 0 409 kB eslint-community-bot
npm/[email protected] None 0 684 kB jounqin
npm/[email protected] filesystem 0 349 kB aaronabramov, jeysal, jsonp, ...6 more
npm/[email protected] filesystem +2 2.1 MB gajus
npm/[email protected] None 0 446 kB eslint-community-bot, weiran.zsd
npm/[email protected] None 0 34.3 kB jounqin
npm/[email protected] None 0 77.7 kB eslint-community-bot
npm/[email protected] None 0 152 kB eslintbot
npm/[email protected] None 0 36.1 kB eslintbot
npm/[email protected] environment +1 3.34 MB eslintbot
npm/[email protected] None +1 1.07 MB michaelficarra
npm/[email protected] filesystem 0 96.7 kB mrmlnc
npm/[email protected] filesystem 0 16 kB jaredwray
npm/[email protected] filesystem 0 29.3 kB jaredwray
npm/[email protected] None 0 40.3 kB webreflection
npm/[email protected] filesystem 0 105 kB hirokiosame
npm/[email protected] None 0 176 kB byk, lo1tuma, nzakas, ...1 more
npm/[email protected] environment, filesystem 0 32.5 kB isaacs
npm/[email protected] None +1 78.4 kB wooorm
npm/[email protected] None 0 11.8 kB wooorm
npm/[email protected] None 0 6.9 kB wooorm
npm/[email protected] None 0 53.6 kB kael
npm/[email protected] None 0 11.7 kB sunset_techuila
npm/[email protected] None 0 245 kB jsdoc-type-pratt-parser
npm/[email protected] None 0 5.4 kB dominictarr
npm/[email protected] None 0 27.8 kB jaredwray
npm/[email protected] None +1 68.6 kB vitaly
npm/[email protected] None 0 767 kB vitaly
npm/[email protected] None 0 125 kB wooorm
npm/[email protected] None 0 37.5 kB vitaly
npm/[email protected] None 0 33.1 kB wooorm
npm/[email protected] None 0 6.42 kB wooorm
npm/[email protected] None 0 16.1 kB wooorm
npm/[email protected] None 0 37.5 kB wooorm
npm/[email protected] None 0 36.7 kB wooorm
npm/[email protected] environment 0 435 kB isaacs
npm/[email protected] None 0 6.72 kB styfle
npm/[email protected] None 0 63.4 kB antfu
npm/[email protected] None 0 39.1 kB tomeraberbach
npm/[email protected] environment, filesystem, unsafe 0 7.7 MB prettier-bot
npm/[email protected] None 0 105 kB wooorm
npm/[email protected] None 0 33.5 kB google-wombot
npm/[email protected] None 0 513 kB slevithan
npm/[email protected] None 0 15 kB hirokiosame
npm/[email protected] None 0 95.8 kB npm-cli-ops
npm/[email protected] None 0 10.1 MB antfu, octref, orta, ...1 more
npm/[email protected] None 0 26 kB chrisackerman
npm/[email protected] None 0 7.75 kB wooorm
npm/[email protected] None 0 5.46 kB quietshu
npm/[email protected] None 0 23.8 kB wooorm
npm/[email protected] environment 0 59.8 kB jounqin
npm/[email protected] None 0 46.9 kB sokra
npm/[email protected] None 0 7.49 kB wooorm
npm/[email protected] None 0 1.19 MB joshuakgoldberg
npm/[email protected] None 0 90.4 kB typescript-bot
npm/[email protected] None +1 2.45 MB typedoc-bot
npm/[email protected] None 0 101 kB jameshenry
npm/[email protected] None 0 27.1 kB wooorm
npm/[email protected] None 0 12.8 kB wooorm
npm/[email protected] None 0 13.2 kB wooorm
npm/[email protected] None 0 32.9 kB wooorm
npm/[email protected] None 0 28.5 kB wooorm
npm/[email protected] None 0 22.3 kB wooorm
npm/[email protected] None 0 122 kB wooorm
npm/[email protected] None 0 13.8 kB wooorm

🚮 Removed packages: npm/@es-joy/[email protected], npm/@eslint-community/[email protected], npm/@eslint-community/[email protected], npm/@eslint/[email protected], npm/@eslint/[email protected], npm/@humanwhocodes/[email protected], npm/@humanwhocodes/[email protected], npm/@metamask/[email protected], npm/@metamask/[email protected], npm/@metamask/[email protected], npm/@metamask/[email protected], npm/@metamask/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Copy link

socket-security bot commented Nov 4, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Manifest confusion npm/[email protected] ⚠︎

View full report↗︎

Next steps

What is manifest confusion?

This package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.

Packages with inconsistent metadata may be corrupted or malicious.

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/[email protected] or ignore all packages with @SocketSecurity ignore-all

.prettierrc.mjs Show resolved Hide resolved
eslint.config.mjs Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that the createConfig function was already released and published. However, I can't help but wonder whether it will, in the long run, make our ESLint configurations unnecessarily difficult to understand and debug. ESLint already provides recommendations for combining configuration objects (and exporting configs so they can be properly combined), and these are what plugins like eslint-plugin-import-x, eslint-plugin-jsdoc, and eslint-plugin-prettier follow in switching to the flat config format.

Upon switching to ESLint 9, I would expect the config file to look like the following:

import baseConfigs from '@metamask/eslint-config';
import typescriptConfigs from '@metamask/eslint-config-typescript';
import nodejsConfigs from '@metamask/eslint-config-nodejs';
import jestConfigs from '@metamask/eslint-config-jest';

export default [
  ...baseConfigs,
  {
    ignores: ['dist/', 'docs/', '.yarn/'],
  },
  {
    languageOptions: {
      sourceType: 'module'
    },
    settings: {
      'import-x/extensions': ['.js', '.mjs'],
    },
  },
  ...typescriptConfigs.map((config) => ({
    files: ['**/*.ts'],
    languageOptions: {
      parserOptions: {
        tsconfigRootDir: import.meta.dirname,
        project: ['./tsconfig.json'],
      },
    },
  }}),
  ...nodeJsConfigs.map((config) => ({
    ...config,
    files: ['**/*.js', '**/*.cjs'],
    languageOptions: {
      sourceType: 'script',
    },
  })),
  ...nodeJsConfigs.map((config) => ({
    ...config,
    files: ['**/*.test.ts', '**/*.test.js'],
    languageOptions: {
      sourceType: 'script',
    },
  })),
  ...jestConfigs.map((config) => ({
    ...config,
    files: ['**/*.test.ts', '**/*.test.js'],
  })),
];

While using map is a bit more verbose, I think it's very clear that we are creating objects to add to the flat array that we are ultimately exporting. I am not sure that is so clear with the createConfig utility.

What are your thoughts on this? I believe there are also further improvements we can make to the ESLint packages so that we can streamline this file, but I will leave that for a future comment.

Copy link
Member Author

@Mrtenz Mrtenz Nov 4, 2024

Choose a reason for hiding this comment

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

I considered this, and after talking about it with @rekmarks, we decided to create a simple util function that handles it for you. I don't think it changes so much in understandability of the config, and because it's less verbose, I feel like it's easier to read.

The function is based on typescript-eslint's config function, so it's not like we're the only ones doing this.

Upon switching to ESLint 9, I would expect the config file to look like the following:

[...]

This gets very verbose if you actually want to override some rules or other settings. For example:

...typescript.map((config) => {
  ...config,
  rules: {
    ...config.rules,
    'some-rule': 'off',
  },

  languageOptions: {
    ...config.languageOptions,
    parserOptions: {
      ...config.languageOptions.parserOptions,
      ecmaVersion: 2023,
    }
  }
});

Of course we could use some deep merge function, but that's essentially what createConfig does, but easier.

I can't help but wonder whether it will, in the long run, make our ESLint configurations unnecessarily difficult to understand and debug.

I don't think this will be any more of a problem with createConfig compared to map and spreading the config. Either way it's quite easy to log the object to see what's going on.

Copy link
Member

@rekmarks rekmarks Nov 5, 2024

Choose a reason for hiding this comment

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

I find ESLint's recommendations—i.e. the map() syntax—to be completely unreadable, and much prefer the utility function. In fact, during the migration of our monorepo to ESLint 9, not using the createConfig() function was more difficult and bug-prone, as opposed to the reverse.

Copy link
Contributor

@mcmire mcmire Nov 5, 2024

Choose a reason for hiding this comment

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

Thanks for the replies. That helps me understand the reasoning better.

I do wish it were more obvious that an object with extends actually represents multiple objects; that seems to diverge from the central ideas behind flat config. But, if it succeeds in helping us write the config files we want to write, then perhaps it doesn't matter.

@Mrtenz Mrtenz merged commit aaf5357 into main Nov 6, 2024
20 checks passed
@Mrtenz Mrtenz deleted the mrtenz/eslint-9 branch November 6, 2024 09:46
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.

5 participants