microsoft / microsoft/TypeScript

Formatter fails to format uglified files

Open
#10,126 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: Formatter Help Wanted Suggestion VS Code Tracked
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 1.8.10

I use vscode from the Command Palette to format a javascript file uglified by uglify-js, but it failed. It not format code correctly, and only format partially.

source file
2016-07-12 4 47 08

sublime jsFormat formated
2016-07-12 4 47 29

vscode formated
2016-07-12 4 47 45

You see, It seems like, vscode only add some spaces around brackets, letters, commas etc.

See https://github.com/Microsoft/vscode/issues/8914#issuecomment-231978337 and the discussion below for more details. The provided traces clearly show that the tsserver only returns white space (" ") changes. No insertion of new lines.

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

Reproduce the issue by running VS Code's Command Palette formatter on JavaScript output produced by uglify-js. Start with the tsserver formatting traces referenced in the report, which show only whitespace changes; done means uglified files receive the expected line breaks and indentation rather than only spacing adjustments.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.