-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
…lints-with-examples
…foundry into rusowsky/lints-with-examples
LateLintPass
+ support code snippets
…lints-with-examples
…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
Self::Diff { desc, .. } => *desc, | ||
Self::Block { desc, .. } => *desc, | ||
} | ||
} | ||
} | ||
|
||
/// 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
…lints-with-examples
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-lint
capabilities by adding 2 new features:Implementation
Linter Architecture
Updated the architecture to a dual-pass system:
Relevant changes:
trait LateLintPass
and implemented aLateLintVisitor
that traverses the HIR + runs late lint passes.trait Linter
to support both early (AST) and late (HIR) linting phases.early
orlate
.Code Snippet Support
enum Snippet
to represent code suggestions:fn emit_with_fix()
method toLintContext
to emit diagnostics with (formatted) snippets