Skip to content

[new] [jsx-curly-brace-presence] Disallow unnecessary JSX expressions or enforce them #1349

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

Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5605a36
Add optional rule to disallow unnecessary JSX expressions
jackyho112 Aug 7, 2017
d5e5a2e
Support adding ability to enfore curly brace presence
jackyho112 Aug 7, 2017
0b5e95d
Add docs
jackyho112 Aug 8, 2017
5bd5a7f
Change doc name
jackyho112 Aug 8, 2017
52aaa54
Fix tests
jackyho112 Aug 8, 2017
1a0cac1
Fix tests
jackyho112 Aug 8, 2017
6ea4972
Account for when there are more than one child
jackyho112 Aug 8, 2017
2d695c4
Refactor according to feedback
jackyho112 Aug 8, 2017
ba3dc83
Account for template literal and a single string option to set default
jackyho112 Aug 8, 2017
b8c6698
Update docs
jackyho112 Aug 9, 2017
b647ac8
Add a few more tests
jackyho112 Aug 9, 2017
2397a16
Do a bit of refactoring
jackyho112 Aug 10, 2017
50cc416
Merge branch 'master' into add-new-rule-no-unnecessary-curly-brace
jackyho112 Aug 10, 2017
c237913
Change constant variable names to maintain consistency
jackyho112 Aug 10, 2017
3a03eea
Add ability to fix for missing curly and option for quotes
jackyho112 Aug 10, 2017
78e2ee2
Accounting for quotes
jackyho112 Aug 10, 2017
d87c53f
Account for edge cases
jackyho112 Aug 12, 2017
0f0e292
Add more tests
jackyho112 Aug 12, 2017
82fe18e
Update docs
jackyho112 Aug 12, 2017
03cf18b
Improve docs
jackyho112 Aug 12, 2017
dfddc4d
Fix a lint error
jackyho112 Aug 12, 2017
50b3ae8
Add comments
jackyho112 Aug 14, 2017
fe850fb
Get rid of deconstruction for older node version compatibility
jackyho112 Aug 14, 2017
35cb961
Add a comment
jackyho112 Aug 14, 2017
c299551
Add two more test cases
jackyho112 Aug 16, 2017
b180919
Remove ability to handle quotes
jackyho112 Aug 16, 2017
c66def5
Change tests
jackyho112 Aug 16, 2017
0554b49
Fix docs
jackyho112 Aug 16, 2017
cb93f6b
Fix an error in the doc
jackyho112 Aug 16, 2017
8adfb8c
Improve jsx-curly-brace-presence docs
jackyho112 Aug 16, 2017
0203b70
Add more tests for more than one prop
jackyho112 Aug 16, 2017
d2b2aac
Further improve docs about jsx-curly-brace-presence rule fixing
jackyho112 Aug 17, 2017
401e341
Account for feedback and add more tests
jackyho112 Aug 22, 2017
f2a4d03
Improve docs
jackyho112 Aug 22, 2017
2439068
Change a variable name
jackyho112 Aug 22, 2017
d3df38b
Change a function name
jackyho112 Aug 22, 2017
990daca
Fix an edge case
jackyho112 Aug 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/rules/jsx-curly-brace-presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module.exports = {
{
type: 'object',
properties: {
props: {enum: optionValues},
children: {enum: optionValues}
props: {enum: optionValues, default: optionNever},
Copy link
Contributor Author

@jackyho112 jackyho112 Aug 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the default by mistake. They are back now.

children: {enum: optionValues, default: optionNever}
},
additionalProperties: false
}
Expand Down Expand Up @@ -116,15 +116,15 @@ module.exports = {
// --------------------------------------------------------------------------

return {
JSXExpressionContainer: function(node) {
JSXExpressionContainer: node => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the change to maintain consistencies across files, but I guess it doesn't matter anyway. I have changed it back to using the arrow function.

const {expression: {type}, parent} = node;

if (shouldCheckForUnnecessaryCurly(type, parent, userConfig)) {
lintUnnecessaryCurly(node);
}
},

Literal: function(node) {
Literal: node => {
const {parent: {type: parentType}} = node;

if (shouldCheckForMissingCurly(parentType, userConfig)) {
Expand Down