-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lint rule that enforces curly brace opinions (#130)
- Loading branch information
1 parent
143b57d
commit 762f864
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
'eslint-config-seek': minor | ||
--- | ||
|
||
Adds [react/jsx-curly-brace-presence][docs] as an error. | ||
This removes unnecessary braces around strings in props and children. | ||
|
||
It also enforces braces around expressions in props and children. | ||
|
||
[docs]: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md | ||
|
||
### Examples | ||
|
||
```diff | ||
// Unecessary braces around string prop | ||
- <Column width={'content'}> | ||
+ <Column width="content"> | ||
``` | ||
```diff | ||
// Unecessary braces around string child | ||
- <Text>{'Hello'}</Text> | ||
+ <Text>Hello</Text> | ||
``` | ||
```diff | ||
// Mandatory braces around prop expression | ||
- <Button icon=<IconSearch />> | ||
+ <Button icon={<IconSearch />}> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters