Skip to content

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

@zerosnacks

Description

@zerosnacks
Member

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

Activity

zerosnacks

zerosnacks commented on Jun 12, 2025

@zerosnacks
MemberAuthor

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

added this to the v1.3.0 milestone on Jun 12, 2025
changed the title [-]feat(`forge lint`): create syntax for ignoring a linting rule on a line-level[/-] [+]feat(`forge lint`): create syntax for ignoring a linting rule on a line-level (`// forge-lint-ignore: foo-bar-baz`)[/+] on Jun 12, 2025
0xrusowsky

0xrusowsky commented on Jun 13, 2025

@0xrusowsky
Contributor

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!

self-assigned this
on Jun 13, 2025
moved this from Backlog to Ready For Review in Foundryon Jun 17, 2025
moved this from Ready For Review to Done in Foundryon Jun 26, 2025
moved this from Done to Completed in Foundryon Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Completed

Development

Participants

@0xrusowsky@zerosnacks

Issue actions

    feat(`forge lint`): create syntax for ignoring a linting rule on a line-level (`// forge-lint-ignore: foo-bar-baz`) · Issue #10769 · foundry-rs/foundry