prettier / prettier/plugin-pug

Feature Request: Ability to disable warnings via code comments or global config rules

Open
#325 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted type: bug
Dominant language
TypeScript
Stars
208
Forks
49
Avg merge
4h 26m
Merged PRs (30d)
8

Description

Request / Idea

This is a feature request to have the ability to disable warnings via code comments or global config rules.

Right now this section of code https://github.com/prettier/plugin-pug/blob/9e6620a4624261561aa966faaaea657804a74749/src/printer.ts#L1456-L1483 has no way of being disabled from outputting to console.

Similar to being able to ignore automatic formatting, it would be great to have (via comments or config, or both possibly), the ability to ignore warnings.

e.g. https://prettier.github.io/plugin-pug/guide/#usage highlights the ability to write //- prettier-ignore before a block of code to disable prettier from auto-formatting it

Input

❯ npx prettier app/views/layout.pug --write --loglevel error
[PugPrinter:start-pipeless-text]: The following expression could not be formatted correctly. This is likely a syntax error or an issue caused by the missing execution context. If you think this is a bug, please open a bug issue.
code: `window._types = {
  success: "#{ t('Success') }",
  error: "#{ t('Error') }",
  info: "#{ t('Info') }",
  warning: "#{ t('Warning') }",
  question: "#{ t('Question') }"
};
window._messages = !{json(flash(), null, null)};`
You used interpolated code in your pipeless script tag, so you may ignore this warning.
Found babel SyntaxError: Unexpected token, expected "," (8:32)
  6 |   question: "#{ t('Question') }"
  7 | };
> 8 | window._messages = !{json(flash(), null, null)};
    |                                ^
  9 |.

Expected Output

None

Additional Context

There is no ability that I've found so far as to disable warnings, or specific warnings related to specific blocks/lines of code.

cc @spence-s @shadowgate15

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 reviewing src/printer.ts at lines 1456-1483 and the existing prettier-ignore guidance in the linked plugin-Pug guide. Reproduce the warning with the provided npx prettier command, then determine the intended comment or global configuration behavior. Done means users can suppress the relevant warning for selected code or through configuration without suppressing unrelated output.

Written by the indexing model from the issue text.

Assessment

Tech stack
pug, typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.