nodejs / nodejs/node

remove redundancy in node.config schema keys

Abierto
#60,904 10 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

config feature request stale
Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

What is the problem this feature will solve?

Notice below how in the current schema, the namespaces "test" and "watch" are redundantly specified. This is the result of mapping the CLI args as-is.

{
    "$schema": "https://nodejs.org/dist/vX.Y.Z/docs/node-config-schema.json",
    "test": {
        "test-concurrency": 3
        "test-isolation": "process"
        "test-timeout": 5000
        "test-rerun-failures": true
        "test-only": true
        "test-force-exit": false
        "test-name-pattern": "^iso"
        "test-skip-pattern": "tree$"
        "test-global-setup": "setup-module.mjs"
        "experimental-test-coverage": true
        "test-coverage-exclude": "test/**"
        "test-coverage-include": "src/**"
        "test-coverage-branches": 100
        "test-coverage-functions": 100
        "test-coverage-lines": 100
        "test-reporter": ["dot", "spec", "lcov"]
        "test-reporter-destination": ["stdout", "test.report", "lcov.info"]
        "experimental-test-module-mocks": true
        "test-update-snapshots": true
    },
    "watch": {
        "watch-preserve-output": true
        "watch-path": "./src"
    }
} 
What is the feature you are proposing to solve the problem?

Instead, the namespace part of the CLI arg could automatically be mapped to a namespace within the config schema:

{
    "$schema": "https://nodejs.org/dist/vX.Y.Z/docs/node-config-schema.json",
    "test": {
        "concurrency": 3
        "isolation": "process"
        "timeout": 5000
        "rerun-failures": true
        "only": true
        "force-exit": false
        "name-pattern": "^iso"
        "skip-pattern": "tree$"
        "global-setup": "setup-module.mjs"
        "experimental-coverage": true
        "coverage-exclude": "test/**"
        "coverage-include": "src/**"
        "coverage-branches": 100
        "coverage-functions": 100
        "coverage-lines": 100
        "reporter": ["dot", "spec", "lcov"]
        "reporter-destination": ["stdout", "test.report", "lcov.info"]
        "experimental-module-mocks": true
        "test-update-snapshots": true
    },
    "watch": {
        "preserve-output": true
        "path": "./src"
    }
} 

Note that for "experimental-" CLI args, the mapped namespace occurs after that prefix.

We can take it a step further, apply the idea recursively, as below. This has the added of benefit fixing how destinations are specified when there are multiple test reporters.

{
    "$schema": "https://nodejs.org/dist/vX.Y.Z/docs/node-config-schema.json",
    "test": {
        "concurrency": 3
        "isolation": "process"
        "timeout": 5000
        "rerun-failures": true
        "only": true
        "force-exit": false
        "name-pattern": "^iso"
        "skip-pattern": "tree$"
        "global-setup": "setup-module.mjs"
        "experimental-coverage": {
            "exclude": "test/**"
            "include": "src/**"
            "branches": 100
            "functions": 100
            "lines": 100
        }
        "reporter": {
            "dot": {"destination": "stdout"}
            "spec": {"destination": "test.report"}
            "lcov": {"destination": "lcov.info"}
        }
        "experimental-module-mocks": true
        "update-snapshots": true
    },
    "watch": {
        "preserve-output": true
        "path": "./src"
    }
} 
What alternatives have you considered?

No response

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 rastreando la correspondencia entre los argumentos CLI de Node y el esquema de configuración, y compara cómo se generan actualmente las claves test y watch. Los ejemplos del issue definen el resultado previsto: se deben eliminar los prefijos de espacio de nombres, gestionar las opciones experimentales después de su prefijo y mapear recursivamente los destinos anidados de reporter.

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

Evaluación

Stack tecnológico
javascript, node.js
Área
cli, developer-experience
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.