fvictorio / solhint-plugin-prettier

A Solhint plugin for checking your contracts style
29 stars 13 forks source link

Function type parsing and comments #7

Closed adjicf closed 4 years ago

adjicf commented 4 years ago

Function type declaration are rewritten incorrectly and when ignoring them and adding some comments there is another extra error.

The original code:

contract Broken {
    struct Something {
        // This gives an error
        function (address) external view returns (uint256) getSomething;
    }
}

The rewrite:

contract Broken {
    struct Something {
        // This gives an error
        function(address) returns (uint256) external view getSomething;
    }
}

When ignoring it:

contract Broken {
    // prettier-ignore
    struct Something {
        // This gives an error
        function (address) external view returns (uint256) getSomething;
    }
}

The error: contracts/Broken.sol: Error: Comment "This gives an error" was not printed. Please report this error! [error] at astComments.forEach.comment (...../contracts/node_modules/prettier/index.js:14273:13) [error] at Array.forEach () [error] at Object.ensureAllCommentsPrinted (contracts/node_modules/prettier/index.js:14271:15) [error] at coreFormat (...../contracts/node_modules/prettier/index.js:14858:12) [error] at format (...../contracts/node_modules/prettier/index.js:15063:14) [error] at formatWithCursor (...../contracts/node_modules/prettier/index.js:15080:12) [error] at Object.args [as formatWithCursor] (...../contracts/node_modules/prettier/index.js:54658:12) [error] at format (...../contracts/node_modules/prettier/bin-prettier.js:15851:14) [error] at Object.formatFiles (...../contracts/node_modules/prettier/bin-prettier.js:16035:16) [error] at Object.run (...../contracts/node_modules/prettier/bin-prettier.js:16508:14)

fvictorio commented 4 years ago

Hey @adjicf, thanks for opening this.

This plugin only works as glue between solhint and prettier-solidity. Could you please open an issue in prettier-solidity?

Actually, I think there are two bugs, so maybe you should open two different issues:

adjicf commented 4 years ago

Done, thank you very much.