GithubHelp home page GithubHelp logo

Comments (5)

pcaversaccio avatar pcaversaccio commented on June 10, 2024 1

Imho the exception solution for solhint-enable comments should be enough. I can't think of another situation where such a behaviour should be enforced.

from prettier-plugin-solidity.

Janther avatar Janther commented on June 10, 2024 1

the comment is set as a trailing comment of the previous statement instead of a leading comment of the next statement.

This combined with the rule of a line of separation for functions creates this odd behaviour.

Will have a look into this one.

thanks for finding this @pcaversaccio

from prettier-plugin-solidity.

Janther avatar Janther commented on June 10, 2024 1

this is a big one, even if we remove the automatic line of separation, it would not fix this issue because the bug would still be there but would only appear if the user added a separation line themselves.
Prettier would keep that line and then it would trigger the same behaviour.

definitely will have to look into it more

from prettier-plugin-solidity.

fvictorio avatar fvictorio commented on June 10, 2024

Confirmed. Minimal reproduction:

contract Foo {
  /* foo */
  uint public x;
  /* bar */

  function f() public {}
}

Formatting this snippet moves the /* bar */ comment.

I think this is an artifact of Prettier Solidity being somewhat opinionated about blank lines between functions. In this case, what I think it's happening is that the /* bar */ comment is associated with the function and moved when a blank line is added between the variable x and the function f.

Two options here:

  • Drop the auto-insertion of blank lines. Copy prettier's behavior: all blank lines are preserved, no new lines are added, and the only rule is that two or more blank lines are always collapsed to one blank line. One could argue this is a bit of a breaking change, since we are dropping a "feature".
  • Fix the logic somehow, although I don't know how we would do that. Maybe we can add an exception for solhint-enable comments, since that's the only case where I think it makes sense to have the comments the way you have them.

from prettier-plugin-solidity.

pcaversaccio avatar pcaversaccio commented on June 10, 2024

the comment is set as a trailing comment of the previous statement instead of a leading comment of the next statement.

This combined with the rule of a line of separation for functions creates this odd behaviour.

Will have a look into this one.

thanks for finding this @pcaversaccio

@Janther a quick follow-up. Is there any fix for this in the meantime?

from prettier-plugin-solidity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.