microsoft / microsoft/node-jsonc-parser
parseTree - Option to keep comments
@aeschli ci sta già lavorando.
Dal 28/10/2019.
- Lingua principale
- TypeScript
- Stelle
- 759
- Fork
- 66
- Merge medio
- 5g 10h
- PR unite (30g)
- 7
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.