Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So Prettier is behaving quite weirdly for me. I have this simplified interface in a language called solidity:

interface Token {
  function getTotalSupply(address _market, TokenType _tokenType) external view returns (uint256);
  function mint(address _to, uint256 _amount, TokenType _tokenType) external;
}

After formatting it gets formatted to this:

interface Token {
  function getTotalSupply(address _market, TokenType _tokenType) external view returns (uint256);

  function mint(
    address _to,
    uint256 _amount,
    TokenType _tokenType
  ) external;
}

I want both functions to stay on one line. The printWidth option does not seem to be the issue here, as the first function is actually longer than the second one and does not line break. The difference seems to be that the second function has more arguments and that every function with more than 2 arguments gets split up. Here is my .prettierrc

{
  "overrides": [
    {
      "files": "*.sol",
      "options": {
        "printWidth": 160,
        "tabWidth": 4,
        "useTabs": false,
        "singleQuote": false,
        "bracketSpacing": false,
        "explicitTypes": "always"
      }
    }
  ]
}

How can I fix this?

question from:https://stackoverflow.com/questions/65876455/weird-behaviour-with-prettier-in-vs-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

This looks fine to me. Do you have your .Prettierrc file in the root, and did you reload/restart after setting it up?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...