foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(`forge lint`): create syntax for ignoring a linting rule on a line-level (`// forge-lint-ignore: foo-bar-baz`)

Open zerosnacks opened this issue 6 months ago • 2 comments

Component

Forge

Describe the feature you would like

Currently a syntax like // forge-config: default.lint.exclude_lints = ["mixed-case-variable"] defined on a function level would correctly ignore the lint rule violations defined here but is unwieldy and would override all exclusive lints defined on a global level rather than be additive.

// forge-config: default.lint.exclude_lints = ["mixed-case-variable"]
contract StdCheatsForkTest is Test {
    MockUSDT public USDT;
    MockUSDC public USDC;
}

There are cases like this where line level ignoring also makes sense:

note[screaming-snake-case-const]: constants should use SCREAMING_SNAKE_CASE
   --> /forge-std/src/StdCheats.sol:656:25
    |
656 |     Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));

We should have a syntax, preferably short like: // forge-lint-ignore: mixed-case-variable to ignore and a // forge-lint: mixed-case-variable to enable selectively.

Additionally we should optionally accept an array // forge-lint-ignore: [mixed-case-variable, foo-bar, bar-baz] syntax and a // forge-lint: [mixed-case-variable, foo-bar, bar-baz] to enable / ignore multiple.

Additional context

No response

zerosnacks avatar Jun 12 '25 09:06 zerosnacks

cc @0xrusowsky a good test case here is to run forge lint on forge-std, there are quite a few false positives and things we would want to be able to ignore

zerosnacks avatar Jun 12 '25 09:06 zerosnacks

cc @0xrusowsky a good test case here is to run forge lint on forge-std, there are quite a few false positives and things we would want to be able to ignore

just finished an initial impl on the plane.

will try to add support for the array on the second leg of my trip, and push once home!

0xrusowsky avatar Jun 13 '25 04:06 0xrusowsky