Skip to content

fix: Type exported configs correctly#95

Open
porada wants to merge 3 commits intoe18e:mainfrom
porada:fix/types
Open

fix: Type exported configs correctly#95
porada wants to merge 3 commits intoe18e:mainfrom
porada:fix/types

Conversation

@porada
Copy link
Copy Markdown

@porada porada commented Mar 28, 2026

This PR tightens the types on the exported configs.

Given the plugin referenced itself, so this isn’t the most elegant type definition, but it does the job and improves the overall consumer experience. satisfies wouldn’t be enough in this case.

Fixes #67.
Closes #68.

Before

export default defineConfig({
    rules: {
        ...(pluginPerformance.configs!.modernization as Linter.Config) .rules,
        ...(pluginPerformance.configs!.moduleReplacements as Linter.Config).rules,
        ...(pluginPerformance.configs!.performanceImprovements as Linter.Config).rules,
    },
});

After

export default defineConfig({
    rules: {
        ...pluginPerformance.configs.modernization.rules,
        ...pluginPerformance.configs.moduleReplacements.rules,
        ...pluginPerformance.configs.performanceImprovements.rules,
    },
});

modernization: modernization(plugin),
moduleReplacements: moduleReplacements(plugin),
performanceImprovements: performanceImprovements(plugin)
} as const;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This could be tightened ever further with as const satisfies NonNullable<ESLint.Plugin['configs']>, but I thought the following plugin.configs = configs would be enough.

@porada porada requested a review from 43081j March 29, 2026 18:31
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.

e18e.configs is possibly undefined when in type-checked eslint config files

3 participants