Skip to content

chore: Migrate to ESLint flat configuration#21287

Merged
sdrozdsap merged 9 commits intodevelopfrom
chore/migrate-eslint-flat-config
Apr 7, 2026
Merged

chore: Migrate to ESLint flat configuration#21287
sdrozdsap merged 9 commits intodevelopfrom
chore/migrate-eslint-flat-config

Conversation

@sdrozdsap
Copy link
Copy Markdown
Contributor

@sdrozdsap sdrozdsap commented Mar 26, 2026

Migrate to ESLint flat configuration

This PR migrates from the old .eslintrc.json format to the new ESLint flat config (eslint.config.mjs). The old format is deprecated and will eventually stop being supported, so this is something we needed to do sooner or later.

Some ESLint-related packages were updated and redundant sub-packages removed since they're now bundled.

Issues found along the way

After the migration, linting started failing for 7 projects: storefrontlib, core, order, opf, cpq-quote, setup, and storefrontapp. After investigating each failure, here's what was going on:

no-console was silently broken before. Turns out the old config had a bug where legacy-ng-cli-compat.json was quietly overriding our strict no-console: "error" with a broad allow list that included "log". So console.log was effectively allowed everywhere, even though it wasn't supposed to be. The flat config now correctly enforces the intended behaviour. I removed a few leftover debug console.logs from spec files and added eslint-disable where console usage is intentional (test assertions like expect(console.warn), a mock logger, and the build-time env log in storefrontapp/esbuild/plugins.ts).

Nx workspace rule names changed format. In the old config rules were named like @nx/workspace/rule-name, but flat config registers them as @nx/workspace-rule-name (with a dash). Some eslint-disable comments in core referenced the old names, so those were updated.
For details see

A bunch of eslint-disable comments became unnecessary. Rules like max-len, no-bitwise, import/no-deprecated etc. are no longer active in the new config, so their disable directives were just noise. Cleaned those up

Also deleted tools/eslint-plugins/legacy-ng-cli-compat.json and legacy-ng-cli-compat--formatting-add-on.json. I couldn't find any reason to keep them around.

QA

ci-scripts/validate-lint.sh

Also you can manually break some linting rule and check if your IDE highlights it

@github-actions github-actions Bot marked this pull request as draft March 26, 2026 14:54
@sdrozdsap sdrozdsap force-pushed the chore/migrate-eslint-flat-config branch from 0550794 to bf4731e Compare April 2, 2026 09:00
@sdrozdsap sdrozdsap marked this pull request as ready for review April 2, 2026 09:01
@sdrozdsap sdrozdsap requested review from a team as code owners April 2, 2026 09:01
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@cypress
Copy link
Copy Markdown

cypress Bot commented Apr 2, 2026

spartacus    Run #52644

Run Properties:  status check passed Passed #52644  •  git commit 478dc88b3b ℹ️: Merge ebb15ccdf8b0d6635c74367ab73128c755a571a0 into 96062566bce7cf1b0a2140790069...
Project spartacus
Branch Review chore/migrate-eslint-flat-config
Run status status check passed Passed #52644
Run duration 04m 27s
Commit git commit 478dc88b3b ℹ️: Merge ebb15ccdf8b0d6635c74367ab73128c755a571a0 into 96062566bce7cf1b0a2140790069...
Committer sdrozdsap
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 3
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 101
View all changes introduced in this branch ↗︎

@sdrozdsap sdrozdsap force-pushed the chore/migrate-eslint-flat-config branch from bf4731e to 55ebb46 Compare April 2, 2026 12:41
@github-actions github-actions Bot marked this pull request as draft April 2, 2026 12:41
Comment thread projects/storefrontapp/esbuild/plugins.ts Dismissed
@sdrozdsap sdrozdsap force-pushed the chore/migrate-eslint-flat-config branch from 55ebb46 to d30e9d7 Compare April 2, 2026 12:58
@sdrozdsap sdrozdsap force-pushed the chore/migrate-eslint-flat-config branch from d30e9d7 to 3b5f6eb Compare April 2, 2026 13:20
@sdrozdsap sdrozdsap marked this pull request as ready for review April 2, 2026 14:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions Bot marked this pull request as draft April 3, 2026 07:16
@pawelfras pawelfras marked this pull request as ready for review April 3, 2026 11:24
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

pawelfras
pawelfras previously approved these changes Apr 3, 2026
Copy link
Copy Markdown
Contributor

@pawelfras pawelfras left a comment

Choose a reason for hiding this comment

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

Nitpick: Let's update comments in our custom eslint rules to point to the proper rule name, e.g:

- NOTE: The rule will be available in ESLint configs as "@nrwl/nx/workspace/no-ngrx-fail-action-without-error-action-implementation"
+ NOTE: The rule will be available in ESLint configs as "@/nx/workspace-no-ngrx-fail-action-without-error-action-implementation"

Also, let's remember to inform tribe about the change and required "eslint.useFlatConfig": true in VSC config

Comment thread eslint.config.mjs
Comment on lines +215 to +224
{
files: ['**/*.module.ts'],
plugins: { '@nx': nxPlugin },
rules: {
'@nx/workspace-use-provide-default-config': 'error',
'@nx/workspace-use-provide-default-config-factory': 'error',
'@nx/workspace-use-provide-default-feature-toggles': 'error',
'@nx/workspace-use-provide-default-feature-toggles-factory': 'error',
},
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: is this a recommended way of using our custom rules? I couldn't find it in the official Nx docs: https://nx.dev/docs/technologies/eslint/guides/custom-workspace-rules

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To be honest, I'm not sure if its recommended or not. I think this is similar to what we had before, and I didn't give much thought about how we can refactor or change it. This approach is tested and works, but if you see any issue with it Im open minded for the change

@github-actions github-actions Bot marked this pull request as draft April 6, 2026 10:22
@sdrozdsap sdrozdsap marked this pull request as ready for review April 6, 2026 10:23
@github-actions github-actions Bot marked this pull request as draft April 6, 2026 10:59
@sdrozdsap
Copy link
Copy Markdown
Contributor Author

@pawelfras about that:

Also, let's remember to inform tribe about the change and required "eslint.useFlatConfig": true in VSC config

I actually don't have "eslint.useFlatConfig": true and it still works since flat config is the default now. Doesn't it work without it in your case?

@sdrozdsap sdrozdsap marked this pull request as ready for review April 6, 2026 11:01
@sdrozdsap sdrozdsap requested a review from pawelfras April 6, 2026 17:08
@github-actions github-actions Bot marked this pull request as draft April 7, 2026 07:05
@pawelfras
Copy link
Copy Markdown
Contributor

@pawelfras about that:

Also, let's remember to inform tribe about the change and required "eslint.useFlatConfig": true in VSC config

I actually don't have "eslint.useFlatConfig": true and it still works since flat config is the default now. Doesn't it work without it in your case?
I was referring to the information ESLint extension setting:

image Only now I realised we have ESLint version > 9.0.0, so the config is set to true by default. Indeed, it works without setting it explicitly to true. Thanks!

@sdrozdsap sdrozdsap marked this pull request as ready for review April 7, 2026 07:22
@github-actions github-actions Bot marked this pull request as draft April 7, 2026 08:15
@sdrozdsap sdrozdsap marked this pull request as ready for review April 7, 2026 08:15
@github-actions github-actions Bot marked this pull request as draft April 7, 2026 08:47
@sdrozdsap sdrozdsap marked this pull request as ready for review April 7, 2026 08:47
@sdrozdsap sdrozdsap merged commit 0dbe3dc into develop Apr 7, 2026
38 checks passed
@sdrozdsap sdrozdsap deleted the chore/migrate-eslint-flat-config branch April 7, 2026 09:17
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.

3 participants