Skip to content

Update eslint, @guardian/eslint-config and switch to flat config#15864

Merged
Jakeii merged 9 commits into
mainfrom
jlk/flat-updated-eslint-config
May 15, 2026
Merged

Update eslint, @guardian/eslint-config and switch to flat config#15864
Jakeii merged 9 commits into
mainfrom
jlk/flat-updated-eslint-config

Conversation

@Jakeii
Copy link
Copy Markdown
Member

@Jakeii Jakeii commented May 14, 2026

What does this change?

  • Switch from @guardian/eslint-config-typescript to @guardian/eslint-config
  • Upgrade eslint to version 9 (@guardian/eslint-config is not on 10 yet)
  • Switch to new flat eslint config
  • Update other eslint plugins and configs

Some new rules have been introduced to the recommended configs for typescript-eslint and react-hooks, I've set them to warn (from default error) for now.

Some other rules have been renamed/replaced.

The flat config now requires plugins to be direct dependencies (they were previously picked up as transients of @guardian/eslint-config-typescript`)

A new formatting rule has been introduced forcing single line if statements without a block to use a block, which has increased the surface area of this PR a bit.

Other code changes from autofix or manual updating include, use of Record type and removing/adding eslint-disable where needed.

dropped eslint-plugin-jsx-expressions it doesn't work with eslint 9 and it's rules are covered by others now I believe.

Why?

Keep up to date with eslint, this also helps unblock upgrading typescript.

@Jakeii Jakeii added the maintenance Departmental tracking: maintenance work, not a fix or a feature label May 14, 2026
This was linked to issues May 14, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

@Jakeii Jakeii changed the title Update eslint and switch to flat config Update eslint and guardian/eslint and switch to flat config May 14, 2026
@Jakeii Jakeii changed the title Update eslint and guardian/eslint and switch to flat config Update eslint, @guardian/eslint-config and switch to flat config May 14, 2026
webpackFinal: async (config) => {
// Get project specific webpack options
config = webpackConfig(config);
const newConfig = webpackConfig(config);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to silence eslint/no-param-reassign

},
{
filepath: 'package.json',
pattern: /^\t+"@types\/node"\: "(.+)",$/m,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

unneccessary escape

files: ['**/**.tsx'],
rules: {
'@typescript-eslint/no-restricted-types': [
'warn',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this warn version of @typescript-eslint/no-restricted-types was being overridden by the error one below, I've just removed it as there isn't a way to have separate warn and error types for this rule, and there' still quite a lot of use of JSX.Element

@Jakeii Jakeii added the run_chromatic Runs chromatic when label is applied label May 14, 2026
@github-actions github-actions Bot removed the run_chromatic Runs chromatic when label is applied label May 14, 2026
@Jakeii Jakeii marked this pull request as ready for review May 14, 2026 14:10
@Jakeii Jakeii requested review from a team as code owners May 14, 2026 14:10
@github-actions
Copy link
Copy Markdown

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

Copy link
Copy Markdown
Member

@arelra arelra left a comment

Choose a reason for hiding this comment

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

Great work @Jakeii 🎉

We should review the rules we currently have and convert outstanding warns to errors. But that can be done as a follow up.

@Jakeii Jakeii merged commit f07a052 into main May 15, 2026
32 checks passed
@Jakeii Jakeii deleted the jlk/flat-updated-eslint-config branch May 15, 2026 10:43
@gu-prout
Copy link
Copy Markdown

gu-prout Bot commented May 15, 2026

Seen on PROD (merged by @Jakeii 10 minutes and 23 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature Seen-on-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linting is broken Upgrade To ESLint 9

2 participants