Skip to content
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

Overhaul #726

Merged
merged 26 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9678ca4
refactor(core): move word validity into the type
elijah-potter Feb 18, 2025
7fb35c0
refactor(core): make `LintGroup` runtime-extensible
elijah-potter Feb 18, 2025
e26908d
refactor(core): use only one `Linter` type for `phrase_corrections`
elijah-potter Feb 19, 2025
efb3b82
refactor(core): centralize linter configuration
elijah-potter Feb 19, 2025
a21423e
refactor(core): move `MapPhraseLinter` to its own module
elijah-potter Feb 19, 2025
7f7527c
refactor(core): use `LintGroup` for `closed_compounds`
elijah-potter Feb 19, 2025
613b85c
refactor(core): use macros to make `phrase_corrections` easier to grok
elijah-potter Feb 19, 2025
bcd6bf5
fix(core): make changes backwards-compatible
elijah-potter Feb 19, 2025
1f6be62
Merge branch 'master' into perf-fixes
elijah-potter Feb 19, 2025
dd21fbd
chore: update settings keys in docs and for the VS Code plugin
elijah-potter Feb 19, 2025
5b1a49f
test(vscode): update to use new lint setting name
elijah-potter Feb 19, 2025
2ceb624
docs(core): wrote an update that points people towards adding simple …
elijah-potter Feb 19, 2025
a4c94a9
feat(core): convert more `matcher` rules to the proper style
elijah-potter Feb 19, 2025
7c3423d
fix: remove unneeded import
elijah-potter Feb 19, 2025
a96d349
fix: `just` command to work with new `LintGroup`
elijah-potter Feb 19, 2025
228a71d
feat(core): create linter for time unit expansion
elijah-potter Feb 20, 2025
d466fc9
fix: misc failures
elijah-potter Feb 20, 2025
5c2d2c1
refactor(core): reduce boilerplate
elijah-potter Feb 20, 2025
99af4a7
fix(core): avoid allocation in hot path
elijah-potter Feb 20, 2025
9a018f4
fix(core): avoid more allocation by using `Cow`
elijah-potter Feb 20, 2025
719e0f7
chore(core): remove dead import
elijah-potter Feb 20, 2025
b14e5ff
feat(core): use more realistic data for benchmark
elijah-potter Feb 20, 2025
cdd4a43
feat(core): use standard `AnyCapitalization` linter instead.
elijah-potter Feb 20, 2025
11995f3
feat: update to Rust `2024`
elijah-potter Feb 20, 2025
285ab80
chore: ran `rustfmt` under new version
elijah-potter Feb 20, 2025
9605e7e
feat(ls): update keys to match new naming convention
elijah-potter Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions harper-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::format_err;
use ariadne::{Color, Label, Report, ReportKind, Source};
use clap::Parser;
use harper_comments::CommentParser;
use harper_core::linting::{LintGroup, LintGroupConfig, Linter};
use harper_core::linting::{LintGroup, Linter};
use harper_core::parsers::{Markdown, MarkdownOptions};
use harper_core::spell::hunspell::parse_default_attribute_list;
use harper_core::spell::hunspell::word_list::parse_word_list;
Expand Down Expand Up @@ -57,14 +57,13 @@ enum Args {
fn main() -> anyhow::Result<()> {
let args = Args::parse();
let markdown_options = MarkdownOptions::default();
let linting_options = LintGroupConfig::default();
let dictionary = FstDictionary::curated();

match args {
Args::Lint { file, count } => {
let (doc, source) = load_file(&file, markdown_options)?;

let mut linter = LintGroup::new(linting_options, dictionary);
let mut linter = LintGroup::new_curated(dictionary);
let mut lints = linter.lint(&doc);

if count {
Expand Down Expand Up @@ -199,15 +198,14 @@ fn main() -> anyhow::Result<()> {
description: String,
}

let mut linter = LintGroup::new(linting_options, dictionary);
linter.config.fill_default_values();
let linter = LintGroup::new_curated(dictionary);

let default_config: HashMap<String, bool> =
serde_json::from_str(&serde_json::to_string(&linter.config).unwrap()).unwrap();

// Use `BTreeMap` so output is sorted by keys.
let mut configs = BTreeMap::new();
for (key, desc) in linter.all_descriptions().to_vec_pairs() {
for (key, desc) in linter.all_descriptions() {
configs.insert(
key.to_owned(),
Config {
Expand Down
2 changes: 1 addition & 1 deletion harper-comments/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "harper-comments"
version = "0.22.0"
edition = "2021"
edition = "2024"
description = "The language checker for developers."
license = "Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion harper-comments/src/comment_parsers/go.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use harper_core::parsers::{Markdown, MarkdownOptions, Parser};
use harper_core::Lrc;
use harper_core::Token;
use harper_core::parsers::{Markdown, MarkdownOptions, Parser};

use super::without_initiators;

Expand Down
12 changes: 7 additions & 5 deletions harper-comments/src/comment_parsers/jsdoc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use harper_core::parsers::{Markdown, MarkdownOptions, Parser};
use harper_core::Lrc;
use harper_core::parsers::{Markdown, MarkdownOptions, Parser};
use harper_core::{Punctuation, Span, Token, TokenKind};
use itertools::Itertools;

Expand Down Expand Up @@ -162,7 +162,7 @@ fn parse_inline_tag(tokens: &[Token]) -> Option<usize> {

#[cfg(test)]
mod tests {
use harper_core::{parsers::MarkdownOptions, Document, Punctuation, TokenKind};
use harper_core::{Document, Punctuation, TokenKind, parsers::MarkdownOptions};

use crate::CommentParser;

Expand Down Expand Up @@ -226,8 +226,10 @@ mod tests {
CommentParser::new_from_language_id("javascript", MarkdownOptions::default()).unwrap();
let document = Document::new_curated(source, &parser);

assert!(document
.tokens()
.all(|t| t.kind.is_unlintable() || t.kind.is_newline() || t.kind.is_paragraph_break()));
assert!(
document.tokens().all(|t| t.kind.is_unlintable()
|| t.kind.is_newline()
|| t.kind.is_paragraph_break())
);
}
}
2 changes: 1 addition & 1 deletion harper-comments/src/comment_parsers/unit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use harper_core::parsers::{Markdown, MarkdownOptions, Parser};
use harper_core::Lrc;
use harper_core::parsers::{Markdown, MarkdownOptions, Parser};
use harper_core::{Span, Token};

use super::without_initiators;
Expand Down
7 changes: 2 additions & 5 deletions harper-comments/tests/language_support.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::Path;

use harper_comments::CommentParser;
use harper_core::linting::{LintGroup, LintGroupConfig, Linter};
use harper_core::linting::{LintGroup, Linter};
use harper_core::parsers::MarkdownOptions;
use harper_core::{Document, FstDictionary};

Expand All @@ -25,10 +25,7 @@ macro_rules! create_test {
let dict = FstDictionary::curated();
let document = Document::new(&source, &parser, &dict);

let mut linter = LintGroup::new(
LintGroupConfig::default(),
dict
);
let mut linter = LintGroup::new_curated(dict);
let lints = linter.lint(&document);

dbg!(&lints);
Expand Down
3 changes: 2 additions & 1 deletion harper-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "harper-core"
version = "0.22.0"
edition = "2021"
edition = "2024"
description = "The language checker for developers."
license = "Apache-2.0"
readme = "README.md"
Expand All @@ -25,6 +25,7 @@ unicode-blocks = "0.1.9"
unicode-script = "0.5.7"
unicode-width = "0.2.0"
levenshtein_automata = { version = "0.2.1", features = ["fst_automaton"] }
cached = "0.54.0"

[dev-dependencies]
criterion = { version = "0.5.1", default-features = false }
Expand Down
Loading
Loading