prettier / prettier/prettier

Support prettier-ignore-start/end for other languages (not only Markdown)

Open
#5,287 75 comments 442 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:ignore help wanted
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

It seems this feature was added only for markdown (#4202 cc @ikatyang), but it's actually useful for other languages as well. It is not working on typescript files on my tests.

Related: https://github.com/facebook/create-react-app/issues/5543

Environments:

  • Prettier Version: 1.14.3
  • Running Prettier via: CLI
  • Runtime: Node.js v8.11.4
  • Operating System: macOS

Steps to reproduce:

Create a index.d.ts file with the following content:

// prettier-ignore
type A1 = string;

// prettier-ignore
type A2 = string

/* prettier-ignore-start */
type B1 = string;
type B2 = string
/* prettier-ignore-end */

type C1 = string;
type C2 = string

Expected behavior:

// prettier-ignore
type A1 = string;

// prettier-ignore
type A2 = string

/* prettier-ignore-start */
type B1 = string;
type B2 = string
/* prettier-ignore-end */

-type C1 = string;
+type C1 = string
type C2 = string

Actual behavior:

// prettier-ignore
type A1 = string;

// prettier-ignore
type A2 = string

/* prettier-ignore-start */
-type B1 = string;
+type B1 = string
type B2 = string
/* prettier-ignore-end */

-type C1 = string;
+type C1 = string
type C2 = string

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 by reproducing the issue with Prettier CLI on the provided index.d.ts example and compare the handling of prettier-ignore-start/end with single-line prettier-ignore. Trace the TypeScript formatting path and existing Markdown support; done means the B1/B2 region remains unchanged while C1 is formatted as shown.

Written by the indexing model from the issue text.

Assessment

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