prettier / prettier/prettier

Prefer breaking before dot instead of inside []

Open
#6,091 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:function calls lang:javascript
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

Input:
myListHasALongName[someLongVariableName[sessionsIdx]]["specifier"].push({ content });

Output:

 myListHasALongName[someLongVariableName[sessionsIdx]][
                    "specifier"
                  ].push({
                    content
                  });

Expected behavior: Do not break code
Result:
error: Expected "[" and "]" to be on the same line (standard/computed-property-even-spacing) at

Any ideas how to disable this behavior?

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 from the issue's JavaScript/JSX input and compare the reported output with the requested break before the dot. Locate the formatter entry point and related line-breaking tests, then verify that the computed-property brackets stay together while the chain breaks at the preferred boundary.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.