Skip to content

feat(eslint-plugin): add schematic support for flat configs#4747

Merged
brandonroberts merged 3 commits intomainfrom
eslint-ng-add-flatconfig
Apr 21, 2025
Merged

feat(eslint-plugin): add schematic support for flat configs#4747
brandonroberts merged 3 commits intomainfrom
eslint-ng-add-flatconfig

Conversation

@timdeschryver
Copy link
Copy Markdown
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The current schematic only supports the "old" ESLint configuration, which exists in a JSON file.

Closes #4643

What is the new behavior?

This PR adds support to add the NgRx plugin to the flat config (Eslint v9.
It supports the following formats:

  • eslint.config.js
  • eslint.config.mjs
  • eslint.config.cjs

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 5, 2025

Deploy Preview for ngrx-io canceled.

Name Link
🔨 Latest commit e327ffc
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/67f16ddf519d250008c20f32

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

modules/eslint-plugin/schematics/ng-add/index.ts:96

  • If no import declarations exist, the insertion point defaults to 0, which may insert the new import statement in an unexpected location; consider handling this case separately to ensure the import is placed in a logical location relative to the tseslint.config call.
recorder.insertRight(lastImport?.end ?? 0, `\nimport ngrx from '${ngrxPlugin}';`);

@timdeschryver timdeschryver changed the title feat(eslint-plugin): add schematic supports flat configs feat(eslint-plugin): add schematic support for flat configs Apr 5, 2025
Copy link
Copy Markdown
Contributor

@rainerhahnekamp rainerhahnekamp left a comment

Choose a reason for hiding this comment

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

Ouch - migrating to flat config isn’t as straightforward as it looks.
We went through something similar in Sheriff, and it definitely took some effort.
Fingers crossed the flat config stays stable for a few years now! 🤞

@brandonroberts brandonroberts merged commit f966d0a into main Apr 21, 2025
10 checks passed
@brandonroberts brandonroberts deleted the eslint-ng-add-flatconfig branch April 21, 2025 12:38
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.

ng-add should also work for ESLint 9 flat config files

5 participants