Skip to content

fix(#421): defineConfig compatible#466

Merged
SukkaW merged 5 commits intoun-ts:masterfrom
SukkaW:fix-eslint-define-config-type
Mar 11, 2026
Merged

fix(#421): defineConfig compatible#466
SukkaW merged 5 commits intoun-ts:masterfrom
SukkaW:fix-eslint-define-config-type

Conversation

@SukkaW
Copy link
Copy Markdown
Collaborator

@SukkaW SukkaW commented Mar 11, 2026

Fixes #421, make eslint-plugin-import-x compatible with ESLint defineConfig().

The PR also manages to retain the Linter.Config<RulesRecord>'s RulesRecord generic as readable, check the output index.d.ts:

image

TODO:

  • Make plugin type correct as well

Summary by CodeRabbit

  • Enhancements

    • Improved compatibility with ESLint's defineConfig and modern config patterns
    • Enhanced and tightened type definitions for plugin configurations for better IDE support
  • Tests

    • Added type-level verification tests to ensure configuration compatibility across all supported groups
  • Chores

    • Patch release entry added and a new dev dependency for type assertions included

@SukkaW SukkaW requested review from 43081j and JounQin March 11, 2026 16:31
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 91fb01f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-import-x Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Mar 11, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@SukkaW SukkaW changed the title fix(#421): defineConfig compatible [WIP] fix(#421): defineConfig compatible Mar 11, 2026
@SukkaW SukkaW marked this pull request as draft March 11, 2026 16:33
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7221ea24-97a9-423a-9b5f-99e15f900e66

📥 Commits

Reviewing files that changed from the base of the PR and between 81bdc6d and 91fb01f.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • package.json
  • src/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

📝 Walkthrough

Walkthrough

Updates TypeScript typings to use ESLint's native Linter types, makes createFlatConfig generic, adjusts exported plugin/config types for defineConfig compatibility, adds expect-type for type tests, adds a changeset, and introduces type-level tests validating the exports.

Changes

Cohort / File(s) Summary
Type System & Exports
src/index.ts, src/types.ts
Switched public types to use eslint's ESLint/Linter types; made createFlatConfig generic and adjusted return types; changed flatConfigs/configs typings and plugin export shape to be compatible with defineConfig.
Dependencies & Release metadata
package.json, .changeset/common-results-stay.md
Added expect-type dependency and devDependency entry; added a changeset noting a patch release and defineConfig compatibility change.
Type-Level Tests
test/index.spec-d.ts
Added type-only tests using expect-type to assert that exported flatConfigs and plugin fit defineConfig-compatible shapes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

types

Suggested reviewers

  • JounQin
  • 43081j

Poem

🐇 I tuned the types with careful hop and cheer,
Generic flats now fit where configs appear,
Linter friends hold hands with defineConfig's light,
Tests nod hello in type-only sight,
A tiny rabbit dances—types compile right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(#421): defineConfig compatible' directly references the main issue and clearly indicates the PR fixes ESLint defineConfig compatibility.
Linked Issues check ✅ Passed The PR successfully addresses issue #421 by updating type signatures to use ESLint's native Linter types instead of custom PluginConfig types, enabling defineConfig() compatibility.
Out of Scope Changes check ✅ Passed All changes are directly related to achieving defineConfig() compatibility: type imports, function signatures, configuration type updates, and type-level tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SukkaW SukkaW marked this pull request as ready for review March 11, 2026 16:39
@SukkaW SukkaW changed the title [WIP] fix(#421): defineConfig compatible fix(#421): defineConfig compatible Mar 11, 2026
Comment thread src/index.ts Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-import-x@466

commit: a82ebf3

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/index.spec-d.ts (1)

6-35: Consider adding test coverage for flatConfigs.warnings.

The test covers electron, errors, stage-0, react, react-native, typescript, and recommended, but warnings is also present in flatConfigs (see src/index.ts:160) and isn't tested.

📝 Suggested addition
     expectTypeOf(flatConfigs.recommended).toExtend<
       Parameters<typeof defineConfig>[0]
     >()
+
+    expectTypeOf(flatConfigs.warnings).toExtend<
+      Parameters<typeof defineConfig>[0]
+    >()
   })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/index.spec-d.ts` around lines 6 - 35, Add a type test for
flatConfigs.warnings similar to the existing ones: in the describe block in
test/index.spec-d.ts add an
expectTypeOf(flatConfigs.warnings).toExtend<Parameters<typeof
defineConfig>[0]>() so flatConfigs.warnings is covered alongside
flatConfigs.electron, errors, stage-0, react, react-native, typescript, and
recommended.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/index.spec-d.ts`:
- Around line 6-35: Add a type test for flatConfigs.warnings similar to the
existing ones: in the describe block in test/index.spec-d.ts add an
expectTypeOf(flatConfigs.warnings).toExtend<Parameters<typeof
defineConfig>[0]>() so flatConfigs.warnings is covered alongside
flatConfigs.electron, errors, stage-0, react, react-native, typescript, and
recommended.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d77ca44c-a4d0-4904-b144-c9c2aa7687f5

📥 Commits

Reviewing files that changed from the base of the PR and between 1da4043 and 81bdc6d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • .changeset/common-results-stay.md
  • package.json
  • src/index.ts
  • src/types.ts
  • test/index.spec-d.ts

@SukkaW SukkaW closed this Mar 11, 2026
@SukkaW SukkaW reopened this Mar 11, 2026
Copy link
Copy Markdown
Collaborator

@43081j 43081j left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Maybe worth trying it out in a real world project somewhere

@SukkaW SukkaW requested a review from 43081j March 11, 2026 17:02
@SukkaW
Copy link
Copy Markdown
Collaborator Author

SukkaW commented Mar 11, 2026

Looks good to me!

Maybe worth trying it out in a real world project somewhere

Can be easily verified with #466 (comment)

npm i https://pkg.pr.new/eslint-plugin-import-x@466
pnpm add https://pkg.pr.new/eslint-plugin-import-x@466

Update: it does work with my eslint-config-sukka without type mismatch, where I used to just type cast.

image

@SukkaW SukkaW mentioned this pull request Mar 11, 2026
@SukkaW SukkaW enabled auto-merge (squash) March 11, 2026 18:02
@SukkaW SukkaW removed the request for review from JounQin March 11, 2026 18:02
@SukkaW SukkaW merged commit b669aca into un-ts:master Mar 11, 2026
54 of 55 checks passed
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.

Unable to use defineConfig() with TypeScript config

2 participants