Skip to content

Commit 5b5a707

Browse files
committed
chore: update detect circular reference docs and add it to recommended rules
1 parent d95cd9e commit 5b5a707

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

docs/rules/detect-circular-reference.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ description: 'Detects usage of `forwardRef()` function commonly used to handle c
44

55
[Forward references](https://docs.nestjs.com/fundamentals/circular-dependency#forward-reference) are commonly used to handle circular dependencies between services or modules. For example, if `FooService` and `BarService` depend on each other, you can use `forwardRef()` to resolve the circular dependency. However, `forwardRef()` must be a last resort, and we generally recommend changing your code to avoid circular dependencies. This rule detects usage of the `forwardRef()` method so you can keep track of what potentially needs refactoring.
66

7-
One strategy to avoid circular dependencies between services is to make each responsible for a single use case. That way you decrease the interface and likelihood of circular dependencies. You can also avoid using services as facades for data repositories. Instead, services should be usually used to encapsulate business logic (commands). Leave query responsibilities to repositories.
8-
97
## Options
108

119
This rule has no additional options yet.

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import enforceCloseTestingModuleRule from './rules/enforce-close-testing-module.rule';
22
import checkInjectDecoratorRule from './rules/check-inject-decorator.rule';
3+
import detectCircularReferenceRule from './rules/detect-circular-reference.rule';
34
// TODO: we should type this as ESLint.Plugin but there's a type incompatibilities with the utils package
45
const plugin = {
56
configs: {
67
recommended: {
78
rules: {
89
'@trilon/enforce-close-testing-module': 'error',
910
'@trilon/check-inject-decorator': 'error',
11+
'@trilon/detect-circular-reference': 'warn',
1012
},
1113
},
1214
},
1315
rules: {
1416
'enforce-close-testing-module': enforceCloseTestingModuleRule,
1517
'check-inject-decorator': checkInjectDecoratorRule,
18+
'detect-circular-reference': detectCircularReferenceRule,
1619
},
1720
};
1821

0 commit comments

Comments
 (0)