Comments (5)
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.
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.
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.
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.
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)
- prettier
- Add support for user-defined operators
- Function declarations dont follow style guide any longer HOT 2
- Investigate CI false negatives HOT 1
- Problem with formatting when comment before contract HOT 3
- This e-notation broke formatting HOT 2
- Names in mappings (Solidity 0.8.18) gives an error Error: extraneous input 'loanAddress' expecting '=>' HOT 2
- Unwanted line wrap in if/else conditions without curly brackets HOT 4
- Unnecessary grouping of operands HOT 2
- Add support for `prettier` `3.0` HOT 4
- plugin broken with 3.0.0 prettier release HOT 4
- Feature Request: Sorted Imports HOT 5
- Incompatible with Prettier 3 HOT 3
- Option to disable new line spacing between function in interface
- Error using prettier-plugin-solidity with Vite and Monaco HOT 6
- [BUG] __dirname is not defined HOT 3
- "Format on Save" and "Format Document" are broken with the latest VS Code HOT 9
- Prettier step is ignored for Solidity files on Mac HOT 7
- Feature request: Enforce all blocks with brackets as optional configuration
- named-parameters-mapping error below solidity version 0.8.18 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier-plugin-solidity.