prettier / prettier/plugin-php

Improper body indentation for split inline tags

Aperta
#1,668 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
PHP
Stelle
1.9k
Fork
139
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Prettier 2.2.1

PHP Plugin 0.16.1

{
	"printWidth": 100,
	"useTabs": true,
	"semi": true,
	"quoteProps": "consistent",
	"trailingComma": "all",
	"phpVersion": "7.4",
	"braceStyle": "1tbs"
}

Input:

<div>
	<p> some html </p>
	<div>
		<p>some more html with an inline element <?= htmlspecialchars("test") ?> and another inline element <?= htmlspecialchars("test") ?> with even more <?= htmlspecialchars("test") ?></p>
	</div>
</div>

Output:

<div>
	<p> some html </p>
	<div>
		<p>some more html with an inline element <?= htmlspecialchars(
  	"test",
  ) ?> and another inline element <?= htmlspecialchars(
 	"test",
 ) ?> with even more <?= htmlspecialchars("test") ?></p>
	</div>
</div>

Expected behavior:

This is an issue of opinion so there are multiple solutions here, however, I think everyone would agree that all the parts should be indented the same (or at least identically).

image

The two htmlspecialchars that got split have different amounts of indentation on their closing parenthesis. Additionally, I would argue that the entire block should be indented the same, even if it produced something weird like:

		<p>some more html with an inline element <?= htmlspecialchars(
		  	"test",
		) ?> and another inline element <?= htmlspecialchars(
		 	"test",
		) ?> with even more <?= htmlspecialchars("test") ?></p>

(which is weird HTML with the <p> being on the same line of a multi-line body, however, this is a PHP prettier plugin, not HTML).

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo l’input PHP fornito con la configurazione indicata di Prettier e del plugin PHP, quindi traccia il modo in cui vengono formattati i tag inline suddivisi e le espressioni incorporate al loro interno. Il lavoro è completato quando le espressioni suddivise usano un’indentazione coerente e il comportamento scelto è coperto da un caso di regressione per questo esempio.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.