microsoft / microsoft/TypeScript-Sublime-Plugin

Difficulties with JSX/TSX indentation

Open
#729 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.7k
Forks
236
Avg merge
21d 13h
Merged PRs (30d)
1

Description

I have some issues getting indentation for JSX tags playing along nicely. Here's an exmaple:

  render() {
    return (
      <div class="wrap">
        <div>
        </div>
      </div>
      )
  }

Creating a new line anywhere within the JSX block indents to the parent starting line, not the indented one

  render() {
    return (
      <div class="wrap">
      |here
        <div>
        </div>
      </div>
      )
  }

Outside of JSX code the intendation works fine, for example inserting a new line after the opening bracket correctly indents by 2. This also messes with simple code formatting like through vintageous.

I tried playing with the typescript_auto_format setting and set my indent settings for typescript files to

{
    "tab_size": 2,
    "indent_size": 2,
}

but no good. Am I missing a setting here? (

(I have enable_*_language_service off and use typescript LSP through the sublime lsp project)

Contributor guide

No contributing guide indexed for this repository

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

No file or test is mentioned. First reproduce the JSX/TSX indentation behavior in the Sublime Text TypeScript plugin with the shown two-space settings and the reported language-service configuration; done means new lines inside nested JSX follow the surrounding tag indentation and formatting behaves consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
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.