Skip to content

Commit

Permalink
Fix ESLint rules documentation
Browse files Browse the repository at this point in the history
Part of the article got duplicated by mistake.
  • Loading branch information
guyca committed Aug 4, 2024
1 parent b2521a8 commit e13243d
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions packages/documentation/docs/documentation/meta/eslint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,9 @@ class SomeGraph extends ObjectGraph {
### strongly-typed-inject-component
Ensure injected components are strongly typed.

When a component is injected using `injectComponent`, its props are typed with a combination of its `Own` props and the `Injected` props provided by the graph; `Own`, `Injected`, or `Own & Injected`. By default, `injectComponent` returns a component who's props are optional. This is correct if a component only depends on injected props. If a component also has its own props, then `Own` props should be required. This rule ensures that the `injectComponent` call is typed correctly.
When a component is injected using `injectComponent`, its props are typed with a combination of its `Own` props and the `Injected` props; `Own`, `Injected`, or `Own & Injected`. By default, `injectComponent` returns a component who's props are optional. This is correct if a component only depends on injected props. If a component also has its own props, then `Own` props should be required. This rule ensures that the `injectComponent` call is typed correctly.


```ts
@Graph()
class SomeGraph extends ObjectGraph {
@Provides()
foo(bar: Bar) {
return new Foo(bar);
}

@Provides()
bar(foo: Foo) {
// ^ Since Foo depends on Bar, this will trigger a lint error.
return new Bar(foo);
}
}
```

### strongly-typed-inject-component
Ensure injected components are strongly typed.

When a component is injected using `injectComponent`, its props are typed with a combination of its `Own` props and the `Injected` props provided by the graph; `Own`, `Injected`, or `Own & Injected`. By default, `injectComponent` returns a component who's props are optional. This is correct if a component only depends on injected props. If a component also has its own props, then `Own` props should be required. This rule ensures that the `injectComponent` call is typed correctly.

<table>
<tr>
<td> <center><b>Incorrect</b></center> </td> <td> <center><b>Correct</b></center> </td>
Expand Down Expand Up @@ -144,8 +123,3 @@ export default injectComponent<Own, Injected>(Foo, Graph);
</td>
</tr>
</table>





0 comments on commit e13243d

Please sign in to comment.