Skip to content
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

[jsx-wrap-multilines] Add new nodes for wrap #1384

Merged
merged 13 commits into from Oct 30, 2017

Conversation

yepninja
Copy link
Contributor

Add ConditionalExpression, LogicalExpression and JSXAttribute

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

In general, let's make sure we have tests for "true", "false", and "omitted", for all three of these new options.

The following patterns are not considered warnings when configured `{logical: true}`.

```jsx
<div> not
Copy link
Member

Choose a reason for hiding this comment

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

?

@@ -201,20 +232,6 @@ ruleTester.run('jsx-wrap-multilines', rule, {
options: [{return: true}],
errors: [{message: 'Missing parentheses around multilines JSX'}]
}, {
code: DECLARATION_TERNARY_NO_PAREN,
Copy link
Member

Choose a reason for hiding this comment

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

why do these tests need to be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same tests as tests for condition rule. I can return them if you think that they are useful. The more tests the better

Copy link
Member

Choose a reason for hiding this comment

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

For semver-minor PRs, it makes me happier when tests are only added :-)

@yepninja
Copy link
Contributor Author

Fix example for valid jsx in the attribute

@yepninja
Copy link
Contributor Author

Return tests.
Also I've added conditions to defaults. They were already part of declaration and assignment rules. Now it is separated and becomes more common rule.

@yepninja
Copy link
Contributor Author

yepninja commented Sep 1, 2017

@ljharb Can you review again, please?

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Overall LGTM


There are the possible syntax available:

* `declaration`
* `assignment`
* `return`
* `arrow`
* `condition`
* `logical` (not enabled by default)
* `attr` (not enabled by default)
Copy link
Member

Choose a reason for hiding this comment

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

this should probably be "prop" - in jsx, elements have props, and "attributes" are something HTML elements have (which jsx isn't)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed!
I've renamed to prop

@@ -155,14 +217,14 @@ ruleTester.run('jsx-wrap-multilines', rule, {
code: DECLARATION_TERNARY_PAREN
}, {
code: DECLARATION_TERNARY_NO_PAREN,
options: [{declaration: false}]
options: [{condition: false}]
Copy link
Member

Choose a reason for hiding this comment

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

why does this option need to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test case checked the condition in declaration. Now checking the condition is separated.

Copy link
Member

Choose a reason for hiding this comment

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

Does that mean that "declaration: true" now doesn't check as much as it used to? That would make this a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is a broken change for declarations. But now the logic of checking is better

Copy link
Member

Choose a reason for hiding this comment

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

Is there any way we could avoid making it breaking?

Like if condition is absent, it uses the old behavior, but if it's present (true or false) then it uses the new behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can do it now. But it is not very good, so I suggest to do this only as temporary solution, and separate checking condition in major release

Copy link
Member

Choose a reason for hiding this comment

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

Yes, definitely we'd want to separate that in the next major - but for now, we'd be able to add these new options as semver-minor.

}, {
code: ASSIGNMENT_TERNARY_SINGLE_LINE
}, {
code: ASSIGNMENT_TERNARY_PAREN
}, {
code: ASSIGNMENT_TERNARY_NO_PAREN,
options: [{assignment: false}]
options: [{condition: false}]
Copy link
Member

Choose a reason for hiding this comment

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

why does this option need to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test case checked the condition in assignment. Now checking the condition is separated.

Copy link
Member

Choose a reason for hiding this comment

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

Similarly, does that mean that "assignment: true" now doesn't check as much as it used to? That would make this a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is a broken change for assignments too

@yepninja
Copy link
Contributor Author

yepninja commented Sep 4, 2017

Now there are only additions, so this version is fully compatible with previous.

@yepninja
Copy link
Contributor Author

yepninja commented Sep 6, 2017

@ljharb Is it would be useful to add warning?

@ljharb
Copy link
Member

ljharb commented Sep 6, 2017

What kind of warning?

@yepninja
Copy link
Contributor Author

yepninja commented Sep 6, 2017

To enable checking condition if they now use conditions in declaration or assignment

@yepninja
Copy link
Contributor Author

yepninja commented Oct 23, 2017

@ljharb Hello! What is the status of this PR? Do you need these changes in the project?

@ljharb
Copy link
Member

ljharb commented Oct 24, 2017

I'm waiting for reviews from other collaborators.

@lencioni lencioni merged commit da9cbe9 into jsx-eslint:master Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants