-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add option to the self-closing-comp #600
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,79 @@ var contentContainer = <div className="content"></div>; | |
|
||
var HelloJohn = <Hello name="John" />; | ||
|
||
var Profile = <Hello name="John"><img src="picture.png" /></Hello>; | ||
var Profile = <Hello name="John"><img src="picture.png" /></Hello>; | ||
``` | ||
|
||
## Rule Options | ||
|
||
It takes an option as the second parameter, which corresponding what components tags should be self-closed when this is possible. | ||
|
||
```js | ||
... | ||
"self-closing-comp": [<enabled>, 'all'|'component'|'html'>] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i wonder if rather than "all", this should have the format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, your solution is better, thanks, I'll fix this |
||
... | ||
``` | ||
|
||
### `all` | ||
|
||
All tags, including custom components and html components should be self-closed. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```js | ||
var HelloJohn = <Hello name="John"></Hello>; | ||
|
||
var contentContainer = <div className="content"></div>; | ||
``` | ||
|
||
The following patterns are not considered warnings: | ||
|
||
```js | ||
var HelloJohn = <Hello name="John" />; | ||
|
||
var Profile = <Hello name="John"><img src="picture.png" /></Hello>; | ||
|
||
var contentContainer = <div className="content" />; | ||
|
||
var contentContainer = <div className="content"><div /></div>; | ||
``` | ||
|
||
### `component` | ||
|
||
Only custom components tags should be self-closed. This is the default option. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```js | ||
var HelloJohn = <Hello name="John"></Hello>; | ||
``` | ||
|
||
The following patterns are not considered warnings: | ||
|
||
```js | ||
var contentContainer = <div className="content"></div>; | ||
|
||
var HelloJohn = <Hello name="John" />; | ||
|
||
var Profile = <Hello name="John"><img src="picture.png" /></Hello>; | ||
``` | ||
|
||
### `html` | ||
|
||
Only html components tags should be self-closed. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```js | ||
var contentContainer = <div className="content"></div>; | ||
``` | ||
|
||
The following patterns are not considered warnings: | ||
|
||
```js | ||
var HelloJohn = <Hello name="John"></Hello>; | ||
|
||
var contentContainer = <div className="content" />; | ||
|
||
var contentContainer = <div className="content"><div /></div>; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should indicate which is the default here - "component" i think.