Skip to content

Commit a4fb0a4

Browse files
committed
flesh out tests and docs
1 parent 40cdaaa commit a4fb0a4

File tree

2 files changed

+275
-40
lines changed

2 files changed

+275
-40
lines changed

docs/rules/no-multi-comp.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,51 @@ module.exports = HelloJohn;
7373

7474
When `true` the rule will ignore components which are not exported, which allows you to define components as long as they are only used within a private scope.
7575

76+
Examples of **correct** code for this rule:
77+
78+
```jsx
79+
export function Hello(props) {
80+
return <div>Hello {props.name}</div>;
81+
}
82+
function HelloAgain(props) {
83+
return <div>Hello again {props.name}</div>;
84+
}
85+
```
86+
87+
```jsx
88+
function Hello(props) {
89+
return <div>Hello {props.name}</div>;
90+
}
91+
class HelloJohn extends React.Component {
92+
render() {
93+
return <Hello name="John" />;
94+
}
95+
}
96+
module.exports = HelloJohn;
97+
```
98+
99+
Examples of **incorrect** code for this rule:
100+
101+
```jsx
102+
export function Hello(props) {
103+
return <div>Hello {props.name}</div>;
104+
}
105+
export function HelloAgain(props) {
106+
return <div>Hello again {props.name}</div>;
107+
}
108+
```
109+
110+
```jsx
111+
function Hello(props) {
112+
return <div>Hello {props.name}</div>;
113+
}
114+
function HelloAgain(props) {
115+
return <div>Hello again {props.name}</div>;
116+
}
117+
module.exports = {Hello, HelloAgain}
118+
```
119+
120+
76121
## When Not To Use It
77122

78123
If you prefer to declare multiple components per file you can disable this rule.

0 commit comments

Comments
 (0)