dprint-plugin-typescript icon indicating copy to clipboard operation
dprint-plugin-typescript copied to clipboard

Format more code in jsx pre tags

Open dsherret opened this issue 2 years ago • 1 comments

See #420 and #398. It should probably format more code in pre tags instead of turning off formatting in them.

dsherret avatar Sep 09 '22 14:09 dsherret

I just stumbled upon this issue, and I do not understand why <pre> needs to be special cased at all. It looks like this has been introduced in https://github.com/dprint/dprint-plugin-typescript/issues/398, but the two snippets of code in that issue ("input" and "unexpected output") have exactly the same runtime semantics. Whitespace inside JSX is not significant (all whitespace and newlines are collapsed to a single space), regardless of which tag contains it.

You can see in https://babeljs.io/repl#?code_lz=DwBwTgpgfAUABHYBjA9gEwnJAbAhgZ3wDlcBbCAXgCI8A7AcwFdd6IBaACwBdTsrYECAGTYuAbhBD64-IOGix-ELlpTxAFQ4BLfHB1x8KcnC4QAHlwB0I8QHolKtWNny7k6c4TBbqDLG_g0M4woJACiL6YOATEZJQ0Kkws7Ny8_C5wNhJOmQoOqh6a-vqGxqYW1gr2ygXiuW5Ost6R_raBsEA&sourceType=module (<- enable the React preset in the left sidebar) that the output code for the two cases is exactly the same.

nicolo-ribaudo avatar Dec 19 '23 12:12 nicolo-ribaudo