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

Force JSX children expressions to have spacing #4362

Merged
merged 1 commit into from
Jan 9, 2018

Conversation

noisysocks
Copy link
Member

This change forces us to write:

{ isVisible && (
    <Something
        foo="bar"
    />
) }

Instead of:

{isVisible && (
    <Something
        foo="bar"
    />
)}

It does this by setting the children property on the react/jsx-curly-spacing rule.

To test:

  1. Open up e.g. editor/index.js
  2. Insert {post} underneath line 88
  3. Run npm run lint
  4. It should complain that you didn't write { post }

The `react/jsx-curly-spacing` rule applies only to curly brackets used
in attributes. We can force curly brakcets used in children to have
spacing by setting children: true on the rule.
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Great 👍

@noisysocks noisysocks merged commit a7f9da3 into master Jan 9, 2018
@noisysocks noisysocks deleted the fix/jsx-curly-spacing branch January 9, 2018 22:44
@gziolo
Copy link
Member

gziolo commented Jan 10, 2018

🎉 should we include Prettier-eslint as a devDependency as the next step? 😎

@ahmadawais
Copy link
Contributor

@gziolo What about the spacing rule issue?

@gziolo
Copy link
Member

gziolo commented Jan 10, 2018

What about the spacing rule issue?

There is a workaround for it with eslint --fix. @noisysocks confirmed that it works pretty well for him.

@ahmadawais
Copy link
Contributor

@gziolo but then what's the use of Prettier if after running it we'll again run the code through ESLint?

@gziolo
Copy link
Member

gziolo commented Jan 10, 2018

@gziolo but then what's the use of Prettier if after running it we'll again run the code through ESLint?

It's not the best workflow you can imagine, but still better than format code yourself :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants