prettier / prettier/plugin-php

Unexpected Indentation Level in Tests

Abierto
#952 0 comentarios 1 reacción 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

As mentioned in #950, the tests produce a strange behavior with indentation of PHP code blocks in markdown.

Even when no tabWidth is configured in the markdown test (currently it is set to 4 to work around this issue), PHP code is indented by 2 spaces with the standalone build:

[...]

```php
function test(){$a=1;}
`​``

[...]

becomes

[...]

```php
function test()
{
  $a = 1;
}
`​``

[...]

Note: Be careful when copy-pasting the code above. The code fences contain zero-width spaces to retain syntax highlighting.


This incorrect behavior is pretty unique:

  • It does not occur in the same test for the Node.js build, which correctly indents by 4 spaces in the tests.

  • It does not occur in the standalone build when used in the browser.

  • It does not even occur in the test for the standalone build, when the jest.config.js is changed to not using projects (which it currently does), to something like this:

    module.exports = {
      setupFiles: ["<rootDir>/tests_config/run_spec.js"],
      testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
      snapshotSerializers: ["jest-snapshot-serializer-raw"],
      testEnvironment: "jsdom",
      globals: {
        STANDALONE: true
      }
    };
    

So especially because of the last point, I'm assuming this has something to do with the architecture of the tests. I wasn't able to narrow it down any further.

As mentioned above, currently there's a workaround (introduced in #950) to not break the tests with something that doesn't occur "in the wild", but it should probably be taken a deeper look on.

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

Empieza con la prueba de markdown en tests/markdown y compara los resultados de Node.js y standalone. Inspecciona jest.config.js, especialmente su configuración de projects, y reproduce la diferencia con tests_config/run_spec.js. El trabajo estará terminado cuando la prueba standalone ya no necesite la solución alternativa tabWidth: 4 y coincida con la indentación esperada.

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

Evaluación

Stack tecnológico
javascript, node.js, php
Área
testing-qa
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 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.