Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting rule improvements #13945

Merged
merged 3 commits into from Apr 29, 2024
Merged

Formatting rule improvements #13945

merged 3 commits into from Apr 29, 2024

Conversation

shenglol
Copy link
Contributor

@shenglol shenglol commented Apr 26, 2024

Updated two formatting rules based on user feedback. Main changes:

  • The formatter no longer put if expression on a different line unless there is a single-line comment between = and if.
  • If the last function argument ends with a multi-line object or array, the function argument list will not be forced to wrap, unless the width limit is exceeded. This happens to be a heuristic implemented by Prettier.

Closes #13676.

Microsoft Reviewers: Open in CodeFlow

Copy link
Contributor

github-actions bot commented Apr 26, 2024

Test this change out locally with the following install scripts (Action run 8927734929)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 8927734929
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 8927734929"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 8927734929
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 8927734929"

Copy link
Contributor

github-actions bot commented Apr 26, 2024

Test Results

    66 files   -     33      66 suites   - 33   23m 16s ⏱️ - 7m 38s
10 876 tests  -     20  10 875 ✅  -     20  1 💤 ±0  0 ❌ ±0 
25 648 runs   - 12 820  25 646 ✅  - 12 819  2 💤  - 1  0 ❌ ±0 

Results for commit c273afb. ± Comparison against base commit 52025f9.

♻️ This comment has been updated with latest results.

@@ -637,18 +647,63 @@ private IEnumerable<Document> LayoutParenthesizedTypeSyntax(ParenthesizedTypeSyn
this.LayoutMany(leadingNodes)
.Where(x => x != HardLine); // Remove empty lines between decorators.

private IEnumerable<Document> LayoutCommaSeparatedArguments<T>(ImmutableArray<SyntaxBase> children, ImmutableArray<T> arguments)
private Document? LayoutFunctionTailObjectOrArrayArgumentSyntax(ImmutableArray<FunctionArgumentSyntax> argumentSyntaxes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "layout" is a noun, "lay out" is a verb. But it is a free country, so you decide.... :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good catch. Will probably change all occurrence of Layout... to LayOut... in a separate PR.

@shenglol shenglol merged commit ed77ca3 into main Apr 29, 2024
44 checks passed
@shenglol shenglol deleted the shenglol/formatter-improvements branch April 29, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formmatting and folding code issues
2 participants