IssueRaiser

(feat) Change config per file or section by comment.

**Prettier 2.3.2** Sometimes we need different setup / config for files or just code blocks. Therefore it would be nice if we could add prettier-comments to override options like "print-width". I don't want to disable prettier. Just adjust some settings. To keep the format features with other options. For whole file or code sections. For example to disable the short printWidth to avoid different formattings in a list of similar lines. In this example we disable printWidth by a high value. ```ts // prettier-override printWidth=80 const someVariableApple = createVariable("One", "Two", "Three", SomeEnum.Apple); const someVariableBanana = createVariable( "One", "Two", "Three", SomeEnum.Banana); // Result: As some lines reach the print width limit of 80 (or whatever), wrapping occurs. It looks confusing. See next: // prettier-override printWidth=1000 const someVariableApple = createVariable("One", "Two", "Three", SomeEnum.Apple); const someVariableBanana = createVariable("One", "Two", "Three", SomeEnum.Banana); // Result: This is much better for that code section. ``` Or just extend `prettier-ignore` like that: ```ts // prettier-ignore printWidth ``` This should disable printWidth. Means: Not fallback to default (80), disable or set it to a high value. The ignore/override-comment should not only affected to the next node. We need a disable and enable comment. Like: ```ts // prettier-ignore-start printWidth someCode(); someCode(); someCode(); someCode(); // prett

Posted by infacto on Jul 8, 2021, 9:16 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

onboarding (Other)

(feat) Change config per file or section by comment.

infactoJul 8, 2021, 9:16 AM

**Prettier 2.3.2** Sometimes we need different setup / config for files or just code blocks. Therefore it would be nice if we could add prettier-comments to override options like "print-width". I don't want to disable prettier. Just adjust some settings. To keep the format features with other options. For whole file or code sections. For example to disable the short printWidth to avoid different formattings in a list of similar lines. In this example we disable printWidth by a high value. ```ts // prettier-override printWidth=80 const someVariableApple = createVariable("One", "Two", "Three", SomeEnum.Apple); const someVariableBanana = createVariable( "One", "Two", "Three", SomeEnum.Banana); // Result: As some lines reach the print width limit of 80 (or whatever), wrapping occurs. It looks confusing. See next: // prettier-override printWidth=1000 const someVariableApple = createVariable("One", "Two", "Three", SomeEnum.Apple); const someVariableBanana = createVariable("One", "Two", "Three", SomeEnum.Banana); // Result: This is much better for that code section. ``` Or just extend `prettier-ignore` like that: ```ts // prettier-ignore printWidth ``` This should disable printWidth. Means: Not fallback to default (80), disable or set it to a high value. The ignore/override-comment should not only affected to the next node. We need a disable and enable comment. Like: ```ts // prettier-ignore-start printWidth someCode(); someCode(); someCode(); someCode(); // prett

Comments (0)

No comments yet. Start the discussion.

Comment on this issue