Skip to content

Commit

Permalink
chore(lints): Add more abbreviation lints (#55)
Browse files Browse the repository at this point in the history
* Recognize more abbreviations
* Check enum variants
  • Loading branch information
ethanuppal authored Jan 13, 2025
1 parent 6f3210b commit a5afc56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions xtasks/xtask-lint/src/lints/abbreviated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ static ABBREVIATIONS: sync::LazyLock<HashMap<&str, Vec<&str>>> =
("beg", vec!["begin", "beginning"]),
("jeff", vec!["rust_enjoyer"]),
("len", vec!["length"]),
("addr", vec!["address"]),
("hdr", vec!["header"]),
("resp", vec!["response"]),
("conn", vec!["connect", "connection", "connector"]),
("recv", vec!["receive", "receiver"]),
("err", vec!["error"]),
])
});

Expand Down Expand Up @@ -158,6 +164,11 @@ impl<'ast> syn::visit::Visit<'ast> for Abbreviated<'_> {
self.check_words(&ident_pattern.ident, Case::Snake);
syn::visit::visit_pat_ident(self, ident_pattern);
}

fn visit_variant(&mut self, variant: &'ast syn::Variant) {
self.check_words(&variant.ident, Case::Pascal);
syn::visit::visit_variant(self, variant);
}
}

impl<'a> WithDiagnosticContext<'a> for Abbreviated<'a> {
Expand Down

0 comments on commit a5afc56

Please sign in to comment.