microsoft / microsoft/node-jsonc-parser

parseTree - Option to keep comments

Abierto
#28 6 comentarios 4 reacciones 1 asignado Ver en GitHub

@aeschli ya está trabajando en esto.

Desde el 28/10/2019.

feature-request help wanted
Lenguaje dominante
TypeScript
Estrellas
759
Forks
66
Merge medio
5 d 10 h
PR fusionados (30 d)
7

Descripción

Thanks for this library! I wrote a jsonc code formatter using it.

Right now I'm using the scanner to get the comments around the nodes in the tree. It would be slightly faster to not rescan these out and instead get all the comments when calling parseTree.

A simple solution would may be to have an option that returns all the comments in an array. Maybe something like...

export function parseTree(text: string, errors: ParseError[] = [], options: ParseOptions = ParseOptions.DEFAULT): Node;

Goes to:

export function parseTree(text: string, options: ParseOptions = ParseOptions.DEFAULT): ParseResult;

interface ParseResult {
	file: Node;
	errors: ParseError[];
	/** Included when `options.includeComments` is true. **/
	comments?: Comment[];
};

Then:

export interface ParseOptions {
	disallowComments?: boolean;
	allowTrailingComma?: boolean;
	allowEmptyContent?: boolean;
}

Goes to:

export interface ParseOptions {
	disallowComments?: boolean;
	includeComments?: boolean;
	allowTrailingComma?: boolean;
	allowEmptyContent?: boolean;
}

Thoughts? I could submit a PR for this, but will just need some direction on how the public API should look.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.