Skip to content

Text at the end of JSX line is impossible #3094

Open
@fregante

Description

@fregante

Let's start simple, this is fine:

<span>(<b>Hi</b>)</span>

Let's say that Hi is actually super long so it needs to stay on its own line, for example:

<span>
	(
		<b>
			Nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura, ché la diritta via era smarrita.
		</b>
	)
</span>

Fair enough… except:

  ✖  59:1   Expected indentation of 0 tabs but found 1.            @typescript-eslint/indent
  ✖  59:8   Ambiguous spacing before next element b                react/jsx-child-element-spacing
  ✖  59:8   Expected indentation of 0 tab characters but found 1.  react/jsx-indent
  ✖  61:1   Expected indentation of 0 tabs but found 1.            @typescript-eslint/indent
  ✖  61:12  Ambiguous spacing after previous element b             react/jsx-child-element-spacing

uh… let's try:

<span>
	(
	<b>
		Nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura, ché la diritta via era smarrita.
	</b>
	)
</span>

ok, but still

  ✖  59:7   Ambiguous spacing before next element b     react/jsx-child-element-spacing
  ✖  61:11  Ambiguous spacing after previous element b  react/jsx-child-element-spacing

I suppose:

<span>
	(<b>
		Nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura, ché la diritta via era smarrita.
	</b>)
</span>

But, a wild rule appears!

  ✖  60:7  Expected closing tag to match indentation of opening.  react/jsx-closing-tag-location

I'll spare you the rest of the steps, but the linter’s suggestion is:

<span>{`${'('}`}
	<b>
		Nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura, ché la diritta via era smarrita.
	</b>)
</span>

Please show me the way. Is there any? What am I supposed to do? The last piece of code is the opposite of what I want a linter to help me write.

For the record, I'm using XO’s defaults: npx xo file.jsx

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