Skip to content

Commit

Permalink
fix(web): lint not showing up on the web for #131
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Jan 14, 2025
1 parent 48e70e4 commit b5c3dc4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
63 changes: 29 additions & 34 deletions harper-core/src/linting/terminating_conjunctions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::{Lint, LintKind, PatternLinter};
use crate::patterns::{ConsumesRemainingPattern, Pattern, SequencePattern};
use crate::Lrc;
use crate::patterns::{ConsumesRemainingPattern, Pattern, SequencePattern, WordSet};

pub struct TerminatingConjunctions {
pattern: Box<dyn Pattern>,
Expand All @@ -12,37 +11,33 @@ impl Default for TerminatingConjunctions {
pattern: Box::new(ConsumesRemainingPattern::new(Box::new(
SequencePattern::default()
.then_anything_but_hyphen()
.then_any_word_in(Lrc::new(
[
"although",
"as",
"because",
"if",
"lest",
"once",
"only",
"since",
"supposing",
"than",
"though",
"till",
"unless",
"until",
"when",
"whenever",
"where",
"whereas",
"wherever",
"whether",
"not",
"while",
"or",
"nor",
"and",
]
.into_iter()
.collect(),
))
.then_word_set(WordSet::all(&[
"although",
"as",
"because",
"if",
"lest",
"once",
"only",
"since",
"supposing",
"than",
"though",
"till",
"unless",
"until",
"when",
"whenever",
"where",
"whereas",
"wherever",
"whether",
"not",
"while",
"or",
"nor",
"and",
]))
.then_comma(),
))),
}
Expand All @@ -55,7 +50,7 @@ impl PatternLinter for TerminatingConjunctions {
}

fn match_to_lint(&self, matched_tokens: &[crate::Token], source: &[char]) -> Lint {
let word_span = matched_tokens[0].span;
let word_span = matched_tokens[1].span;
let word = word_span.get_content_string(source);

Lint {
Expand Down
5 changes: 1 addition & 4 deletions packages/harper.js/src/LocalLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ export default class LocalLinter implements Linter {

async lint(text: string): Promise<Lint[]> {
await this.initialize();
let lints = this.inner!.lint(text);

// We only want to show fixable errors.
lints = lints.filter((lint) => lint.suggestion_count() > 0);
const lints = this.inner!.lint(text);

return lints;
}
Expand Down

0 comments on commit b5c3dc4

Please sign in to comment.