Skip to content

--range-start and --range-end don't work as documented #6428

@sheerun

Description

@sheerun

Environments:

  • Prettier Version: 1.18.2
  • Running Prettier via: CLI
  • Runtime: Node 10
  • Operating System: MacOS

Steps to reproduce:

echo "'aaa';\n'bbb';" | prettier --range-start 0 --range-end 1 --parser babel
'aaa';
'bbb';

Expected behavior:

Following behavior is currently documented:

The range will extend:

Backwards to the start of the first line containing the selected statement.
Forwards to the end of the selected statement.

So it should format only first quotes.

In fact there is no range I can specify so only first quote is formatted.

Actual behavior:

It formats both quotes

Additional notes:

The first range that results in formatting of both quotes is following:

echo "'aaa';\n'bbb';" | prettier --range-start 0 --range-end 14 --parser babel
"aaa";
"bbb";

Strangely nothing is formatted when range-start is 1 (again, against what is documented):

echo "'aaa';\n'bbb';" | prettier --range-start 1 --range-end 14 --parser babel
'aaa';
'bbb';

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:rangesIssues about formatting/ignoring/etc segments of fileslang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions