Skip to content

Conversation

@milosdjurica
Copy link
Contributor

Added a new linting rule that checks for multiple contract-like items (contracts, abstract contracts, interfaces and libraries) per .sol file

Motivation

Enforce best practice.

Solution

I have some doubts regarding this, would like to hear your opinion.

  1. Should the rule skip interfaces and libraries and count only contracts?
  2. Should the rule show linting note for every contract-like item in the file, or only one time per file is enough?

My solution count interfaces and libraries too, and it shows linting note only once per file. Let me know if you want something to be changed :)

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Keep up the good work guys, cheers!

@0xrusowsky
Copy link
Contributor

0xrusowsky commented Nov 17, 2025

@milosdjurica first of all thanks for the PR and the initiative, we love new contributions to forge's linter!

i think the idea overall makes sense, however imo we can improve it.

  1. i'd like each contract to be flagged, not just the 2nd one
  2. imo it would make sense to add a custom config for this lint, so that users can decide if they want to allow interfaces and/or libs in the same file. To do so, you'd want to modify the LinterConfig to have a dedicated config for this lint. If we do that, i think we then want to create a new intermediate struct that group all lint configs (i.e. the pre-existing mixed_case_exceptions + your newly introduced config)

lmk if this seems reasonable and if u have any doubts regarding impl

@0xrusowsky 0xrusowsky self-assigned this Nov 17, 2025
@0xrusowsky 0xrusowsky added Cmd-forge-lint Command: forge lint T-external labels Nov 17, 2025
@0xrusowsky 0xrusowsky moved this to In Progress in Foundry Nov 17, 2025
@0xrusowsky 0xrusowsky added this to the v1.6.0 milestone Nov 17, 2025
@milosdjurica
Copy link
Contributor Author

@milosdjurica first of all thanks for the PR and the initiative, we love new contributions to forge's linter!

i think the idea overall makes sense, however imo we can improve it.

  1. i'd like each contract to be flagged, not just the 2nd one
  2. imo it would make sense to add a custom config for this lint, so that users can decide if they want to allow interfaces and/or libs in the same file. To do so, you'd want to modify the LinterConfig to have a dedicated config for this lint. If we do that, i think we then want to create a new intermediate struct that group all lint configs (i.e. the pre-existing mixed_case_exceptions + your newly introduced config)

lmk if this seems reasonable and if u have any doubts regarding impl

Sounds great, I like it! Will look to implement it ASAP :)
Thanks for the response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cmd-forge-lint Command: forge lint T-external

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants