microsoft / microsoft/TypeScript

Support column limit in formatter

Open
#1,988 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Help Wanted Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Currently, running the formatter
(eg via the compiler API: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#pretty-printer-using-the-ls-formatter)
produces code which is arbitrarily wide, for statements which are nested, complex, etc.

Our style guide requires a maximum columns, which means the formatter should take a configuration for how wide this is.
Line breaks should probably be added at the highest point in the AST on the long line.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the compiler API's pretty-printer and language-service formatter documentation linked in the issue, then trace the formatter entry point and how it represents nested AST nodes. Done means the formatter accepts a maximum column width and produces line breaks for overly wide nested statements, with behavior that can be verified against representative complex code.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.