microsoft / microsoft/qdk

Allow exclusion from Q# formatting

Open
#1,315 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design needed enhancement language low-priority
Dominant language
Rust
Stars
1k
Forks
212
Avg merge
3d 8h
Merged PRs (30d)
65

Description

I expect that automatic formatting of Q# files will be done on the scale of the entire repo - in CI, during publishing, etc. Typically, it means that there's an action that formats the entire codebase. However it isn't always desirable to autoformat everything. There may be very small number of exceptions. For example, if the author needs to express specific structure in the code, some esoteric aligning or even a test of a compiler of whitespace handling.

In this case it is desirable to specifically exclude portion of the code from auto-formatting. Something like "auto-format all my Q# files except this code fragment". The granularity could be a code block or something similar. The directive could be similar to #pragma(DoNotAutoformat).

The alternative could be "not do anything". This would require user to carefully exclude certain file from autoformat in scripts and while saving. Given that the author of the code is typically not the person who runs scripts and saves files, it may require a lot of careful manual handling.

(Result of a discussion here: https://github.com/microsoft/qsharp/pull/1303)

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 with the discussion in pull request #1303, which the issue identifies as the source of the requirement. Determine the supported scope and syntax for excluding a Q# code fragment from repository-wide formatting, then establish the expected behavior and validation path before implementation.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.