harper_core/linting/
unclosed_quotes.rs1use super::{Lint, LintKind, Linter};
2use crate::document::Document;
3use crate::{Punctuation, Quote, TokenKind};
4
5#[derive(Debug, Clone, Copy, Default)]
6pub struct UnclosedQuotes;
7
8impl Linter for UnclosedQuotes {
9 fn lint(&mut self, document: &Document) -> Vec<Lint> {
10 let mut lints = Vec::new();
11
12 for token in document.tokens() {
14 if let TokenKind::Punctuation(Punctuation::Quote(Quote { twin_loc: None })) = token.kind
15 {
16 lints.push(Lint {
17 span: token.span,
18 lint_kind: LintKind::Formatting,
19 suggestions: vec![],
20 message: "This quote has no termination.".to_string(),
21 priority: 255,
22 })
23 }
24 }
25
26 lints
27 }
28
29 fn description(&self) -> &'static str {
30 "Quotation marks should always be closed. Unpaired quotation marks are a hallmark of sloppy work."
31 }
32}