prettier / prettier/plugin-php

Improper body indentation for split inline tags

Abierto
#1,668 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
PHP
Estrellas
1.9k
Forks
139
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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).

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo la entrada PHP proporcionada con la configuración indicada de Prettier y del plugin de PHP; después, sigue cómo se formatean las etiquetas inline divididas y las expresiones incrustadas en ellas. Se considera terminado cuando las expresiones divididas usan una indentación coherente y el comportamiento elegido está cubierto por un caso de regresión para este ejemplo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
php
Área
tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.