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

forge fmt does not always respect project's Foundry config #456

Closed
PaulRBerg opened this issue Apr 19, 2023 · 4 comments
Closed

forge fmt does not always respect project's Foundry config #456

PaulRBerg opened this issue Apr 19, 2023 · 4 comments
Assignees
Labels
status:ready This issue is ready to be worked on type:bug Something isn't working

Comments

@PaulRBerg
Copy link

PaulRBerg commented Apr 19, 2023

I keep bumping into the bug that should have been fixed by #316.

Hardhat VSCode does not always pick up my [fmt] configuration in foundry.toml:

[fmt]
  bracket_spacing = true
  int_types = "long"
  line_length = 120
  multiline_func_header = "all"
  number_underscore = "thousands"
  quote_style = "double"
  tab_width = 4
  wrap_comments = true

In particular, it does not consistently follow the bracket_spacing rule, e.g. this:

import { IPRBProxy } from "../../src/interfaces/IPRBProxy.sol";

Turns into this:

import {IPRBProxy} from "../../src/interfaces/IPRBProxy.sol";

The bug is transitory, though. When I open the file again and save it, the fmt rules are picked up correctly,

I cannot pinpoint the root cause, but this happens very often - basically every day. Might there be a race condition somewhere in Hardhat VSCode?

For context, these are my VSCode settings:

{
  "[solidity]": {
    "editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
  },
  "[toml]": {
    "editor.defaultFormatter": "tamasfe.even-better-toml"
  },
  "npm.exclude": "**/lib/**",
  "solidity.formatter": "forge"
}

This happens in all of my repos, but for a particular example, you can take a look at PRBProxy.

@kanej
Copy link
Member

kanej commented Apr 19, 2023

@PaulRBerg thanks for feedback.

Does the "losing the connectiowith the foundry config", happen immediately on opening the project in vscode or is it that it works correctly initially but then there is some point during editing that it starts failing?

@PaulRBerg
Copy link
Author

The second scenario - works correctly initially, but it then drifts away.

@kanej kanej added status:ready This issue is ready to be worked on type:bug Something isn't working and removed status:triaging labels Apr 20, 2023
@kanej kanej moved this to Todo in hardhat-vscode Apr 20, 2023
@antico5 antico5 moved this from Todo to In Progress in hardhat-vscode Apr 25, 2023
@antico5
Copy link
Collaborator

antico5 commented Apr 25, 2023

@PaulRBerg hey there! I've investigated this issue and can't find where or how this is happening. The formatting process is pretty straightforward. To help troubleshoot it, I've submitted a PR that adds a bit of logging to the formatting process, so when it happens you could set the logging to verbose and we may be able to spot the source of the problem.

The PR is #465

@antico5 antico5 moved this from In Progress to In Review in hardhat-vscode Apr 25, 2023
@PaulRBerg
Copy link
Author

Interestingly enough, this problem stopped happening on my end.

I will tentatively close the issue in the meantime, but if it happens again I will follow your guidance and set the logging to verbose 👍

@PaulRBerg PaulRBerg closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in hardhat-vscode Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on type:bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants