Automattic / Automattic/harper
Org-mode: Harper flag TODO directives as spelling errors
- Dominant language
- Rust
- Stars
- 15.4k
- Forks
- 627
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 102
Description
**Describe the bug**
Harper's org-mode support (added in https://github.com/Automattic/harper/pull/1369) flags todo list indicators as spelling errors (suggesting that the word be changed to "to-do").
**To Reproduce**
1. Open a new `repro.org` file.
2. Add a top level TODO item:
```org
* TODO Some task
```
3. Observe that the `TODO` is flagged for linting
**Expected behavior**
TODO should not be flagged here.
**Screenshots**
**Platform**
This is using Emacs with the following `harper-ls` configuration:
```elisp
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(text-mode . ("harper-ls" "--stdio"))))
```
**Additional context**
Add any other context about the problem here.
This behavior is reproducible with a simple unit test:
```patch
harper-core/src/parsers/org_mode.rs | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/harper-core/src/parsers/org_mode.rs b/harper-core/src/parsers/org_mode.rs
index 54fdf14c..7abd899a 100644
--- a/harper-core/src/parsers/org_mode.rs
+++ b/harper-core/src/parsers/org_mode.rs
@@ -260,6 +260,19 @@ This is regular text."#;
assert!(tokens.iter().any(|t| matches!(t.kind, TokenKind::Word(_))));
}
+ #[test]
+ fn todo_unlintable() {
+ let source = r#"
+* TODO Some task
+"#;
+ let tokens = OrgMode.parse_str(source);
+ let unlintable_count = tokens
+ .iter()
+ .filter(|t| matches!(t.kind, TokenKind::Unlintable))
+ .count();
+ assert_eq!(unlintable_count, 1);
+ }
+
#[test]
fn case_insensitive_source_blocks() {
let source = r#"#+begin_src python
```
```
failures:
---- parsers::org_mode::tests::todo_unlintable stdout ----
thread 'parsers::org_mode::tests::todo_unlintable' panicked at harper-core/src/parsers/org_mode.rs:271:9:
assertion `left == right` failed
left: 0
right: 1
failures:
parsers::org_mode::tests::todo_unlintable
```
---
Using TODOs as the first word of a title is part of org-mode's syntax, and should not have its spelling adjusted:
- https://orgmode.org/manual/TODO-Basics.html
Contributor guide
Research direction
Start in harper-core/src/parsers/org_mode.rs and run the parsers::org_mode::tests::todo_unlintable test shown in the issue. Verify how a top-level `* TODO Some task` is tokenized, then make the test pass so the TODO directive is unlintable and no longer reported as a spelling error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100