Skip to content

Rule proposal: require parens around jsx that lives on its own line #1207

@rsolomon

Description

@rsolomon

The title is not very eloquent, so I'll explain what I'm after by example.

Currently you can only require parens around multiline jsx. I'd also like to require parens around single-line jsx, but only when it lives on its own line. This is particularly useful when within an arrow function.

For example, the following would raise an error:

foo.map((bar, baz) => 
  <div>I'm on my own line!</div>
);

As would this:

const content = 
  <div>Hi there!</div>;

The following would not raise errors:

foo.map((bar, baz) => (
  <div>I'm on my own line!</div>
));
const content = (
  <div>Hi there!</div>;
);
const content = <div>Hi there!</div>;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions