Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort-module-metadata-arrays breaks factory provider injection #198

Open
fpd007 opened this issue Jul 16, 2024 · 1 comment
Open

sort-module-metadata-arrays breaks factory provider injection #198

fpd007 opened this issue Jul 16, 2024 · 1 comment
Labels
Accepting PRs or funding bug Something isn't working

Comments

@fpd007
Copy link

fpd007 commented Jul 16, 2024

The sort-module-metadata-arrays rule break the factory provider injection.

The rule suggests (or auto-fixes) to change the order of the inject array, but it does not change the order of the useFactory arguments which need to be in the same order.

@Module({
    providers: [
        {
            provide: 'EXAMPLE_PROVIDER',
            useFactory: (bProvider: BProvider, aProvider: AProvider): unknown => {
                return new WhatEver();
            },
        // autofix would swap the order here but leave the useFactory above as is, which silently breaks code
        inject: [BProvider, AProvider],
        }
    ]
})
@darraghoriordan
Copy link
Owner

nice find. yea that would break things for sure.

feel free to submit a PR to fix or just disable the rule for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepting PRs or funding bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants