💅 Nest.js app breaks with useImportType rule #4514
Labels
S-Needs response
Status: await response from OP
S-Needs triage
Status: this issue needs to be triaged
Environment information
Rule name
lint/style/useImportType
Playground link
https://github.com/aak-lear/biome-repro
Expected result
When you setup the Biome in Nest.js app and
useImportType
rule is enabled, app breaks after linting.The reason is Biome rewrites imports for injectable classes and Nest.js can't resolve dependencies.
I attached the link to reproduction repository and the expected result for file
src/app.controller.ts
is:Why This Matters
Nest.js is a popular Node.js framework widely used in the TypeScript community. Importing injectable classes without import type is essential for the proper functioning of the Nest.js DI container. Currently, the
useImportType
rule in Biome does not support ignoring specific classes, forcing developers to either break the project's style guide or add rule suppressions at the code level.Suggested Improvement
Add a configuration option to useImportType that allows ignoring injectable classes. This could take the form of a new option, for example:
The
ignoreInjectableClasses
option would enable Biome to skip theuseImportType
rule for classes used in DI contexts (such as classes decorated with@Injectable()
in Nest.js). This change would greatly simplify working with Nest.js, improving compatibility with the framework and reducing the need for line-level rule suppression.This enhancement would allow developers to maintain a consistent project style defined by Biome and improve compatibility with popular frameworks like Nest.js, where injectable classes are necessary for proper functionality.
Code of Conduct
The text was updated successfully, but these errors were encountered: