Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat(core): removed `IndexMap` + bad test, added comments

Elijah Potter5c42a4b85645
diff --git a/Cargo.lock b/Cargo.lock
index 0bab533ad..ab0644118 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -739,7 +739,6 @@ dependencies = [
"foldhash",
"fst",
"hashbrown 0.15.2",
- "indexmap",
"is-macro",
"itertools 0.14.0",
"lazy_static",
diff --git a/harper-core/Cargo.toml b/harper-core/Cargo.toml
index 230905c85..1efd6d862 100644
--- a/harper-core/Cargo.toml
+++ b/harper-core/Cargo.toml
@@ -28,7 +28,6 @@ levenshtein_automata = { version = "0.2.1", features = ["fst_automaton"] }
cached = "0.54.0"
lru = "0.13.0"
foldhash = "0.1.4"
-indexmap = { version = "2.7.1", features = ["serde"] }
[dev-dependencies]
criterion = { version = "0.5.1", default-features = false }
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rs
index 97f1883c4..9eeba6f89 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group.rs
@@ -8,7 +8,6 @@ use std::sync::Arc;
use cached::proc_macro::cached;
use foldhash::quality::RandomState;
use hashbrown::HashMap;
-use indexmap::IndexMap;
use lru::LruCache;
use serde::{Deserialize, Serialize};
@@ -72,7 +71,7 @@ use crate::{Dictionary, MutableDictionary};
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
#[serde(transparent)]
pub struct LintGroupConfig {
- inner: IndexMap<String, Option<bool>>,
+ inner: HashMap<String, Option<bool>>,
}
#[cached]
@@ -90,7 +89,7 @@ impl LintGroupConfig {
/// Remove any configuration attached to a rule.
/// This allows it to assume its default (curated) state.
pub fn unset_rule_enabled(&mut self, key: impl AsRef<str>) {
- self.inner.swap_remove_entry(key.as_ref());
+ self.inner.remove(key.as_ref());
}
pub fn set_rule_enabled_if_unset(&mut self, key: impl AsRef<str>, val: bool) {
@@ -116,7 +115,7 @@ impl LintGroupConfig {
///
/// Conflicting keys will be overridden by the value in the other group.
pub fn merge_from(&mut self, other: &mut LintGroupConfig) {
- for (key, val) in other.inner.drain(..) {
+ for (key, val) in other.inner.drain() {
if val.is_none() {
continue;
}
@@ -145,6 +144,7 @@ impl Hash for LintGroupConfig {
hasher.write_u8(1);
hasher.write_u8(*value as u8);
} else {
+ // Do it twice so we fill the same number of bytes as the other branch.
hasher.write_u8(0);
hasher.write_u8(0);
}
diff --git a/harper-ls/src/main.rs b/harper-ls/src/main.rs
index b610b513d..c99551564 100644
--- a/harper-ls/src/main.rs
+++ b/harper-ls/src/main.rs
@@ -39,7 +39,7 @@ async fn main() -> anyhow::Result<()> {
let subscriber = FmtSubscriber::builder()
.map_writer(move |_| stderr)
.with_ansi(false)
- .with_max_level(Level::INFO)
+ .with_max_level(Level::WARN)
.finish();
tracing::subscriber::set_global_default(subscriber)?;
diff --git a/packages/harper.js/src/Linter.test.ts b/packages/harper.js/src/Linter.test.ts
index e7da44f23..f8726ef5a 100644
--- a/packages/harper.js/src/Linter.test.ts
+++ b/packages/harper.js/src/Linter.test.ts
@@ -206,18 +206,3 @@ test('Linters have the same config format', async () => {
expect(config).toBeTypeOf('object');
}
});
-
-test('Linters have the same JSON config format', async () => {
- const configs = [];
-
- for (const Linter of Object.values(linters)) {
- const linter = new Linter();
-
- configs.push(await linter.getLintConfigAsJSON());
- }
-
- for (const config of configs) {
- expect(config).toEqual(configs[0]);
- expect(config).toBeTypeOf('string');
- }
-});