-
Couldn't load subscription status.
- Fork 2.2k
feat(forge-lint): new LateLintPass + support code snippets
#10846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
i was working on improved lints that would show code diffs, and i realized that despite using `fn highlighted_note`, the `fn flatten_messages` would remove the style. so this PR aims to enhance `fn flatten_messages` to optionally preserve styles while flattening (depending on whether the emitter supports styles or not). i added a new `fn label_with_style()` to try to avoid breaking API changes for solar users, but not sure if may have missed something. @DaniPopes please lmk if the approach looks good or if we should do it differently. PS: `forge-lint` PR in case it is useful foundry-rs/foundry#10846
…foundry into rusowsky/lints-with-examples
LateLintPass + support code snippets
…foundry into rusowsky/lints-with-examples
|
lgtm! Pending review from @DaniPopes / @grandizzy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! pending @DaniPopes review, this should also unblock #10980
crates/lint/src/linter.rs
Outdated
|
|
||
| /// Trait for lints that operate directly on the AST. | ||
| /// Its methods mirror `ast::visit::Visit`, with the addition of `LintCotext`. | ||
| pub trait EarlyLintPass<'ast>: Send + Sync { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move these to early.rs and late.rs
crates/forge/src/cmd/eip712.rs
Outdated
| &sess, | ||
| &self.build, | ||
| None, | ||
| Some(vec![self.target_path].as_ref()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no vec! needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
TODO:
Motivation
Boost
forge-lintcapabilities by adding 2 new features:Implementation
Linter Architecture
Updated the architecture to a dual-pass system:
Relevant changes:
trait LateLintPassand implemented aLateLintVisitorthat traverses the HIR + runs late lint passes.trait Linterto support both early (AST) and late (HIR) linting phases.earlyorlate.Code Snippet Support
enum Snippetto represent code suggestions:fn emit_with_fix()method toLintContextto emit diagnostics with (formatted) snippets