Lint suggestion variables on non-camelCase (#6590)

* initial

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-04-29 20:41:40 -07:00
committed by GitHub
parent a0afe9dd0e
commit 5f31f3a6b3
6 changed files with 91 additions and 39 deletions

View File

@ -3,7 +3,13 @@ use schemars::JsonSchema;
use serde::Serialize;
use tower_lsp::lsp_types::{Diagnostic, DiagnosticSeverity};
use crate::{errors::Suggestion, lsp::IntoDiagnostic, walk::Node, SourceRange};
use crate::{
errors::Suggestion,
lsp::IntoDiagnostic,
parsing::ast::types::{Node as AstNode, Program},
walk::Node,
SourceRange,
};
/// Check the provided AST for any found rule violations.
///
@ -11,15 +17,15 @@ use crate::{errors::Suggestion, lsp::IntoDiagnostic, walk::Node, SourceRange};
/// but it can also be manually implemented as required.
pub trait Rule<'a> {
/// Check the AST at this specific node for any Finding(s).
fn check(&self, node: Node<'a>) -> Result<Vec<Discovered>>;
fn check(&self, node: Node<'a>, prog: &AstNode<Program>) -> Result<Vec<Discovered>>;
}
impl<'a, FnT> Rule<'a> for FnT
where
FnT: Fn(Node<'a>) -> Result<Vec<Discovered>>,
FnT: Fn(Node<'a>, &AstNode<Program>) -> Result<Vec<Discovered>>,
{
fn check(&self, n: Node<'a>) -> Result<Vec<Discovered>> {
self(n)
fn check(&self, n: Node<'a>, prog: &AstNode<Program>) -> Result<Vec<Discovered>> {
self(n, prog)
}
}