Skip to content

Let me laugh#3365

Merged
elijah-potter merged 2 commits into
masterfrom
feature/let-me-laugh
May 12, 2026
Merged

Let me laugh#3365
elijah-potter merged 2 commits into
masterfrom
feature/let-me-laugh

Conversation

@JasonTheAdams
Copy link
Copy Markdown
Member

Summary

  • Adds a default-enabled AllowInformalLaughter config rule.
  • Allows strictly alternating ha/hah laughter chains like hah, haha, and hahahah.
  • Keeps malformed hah-style chains like hahhah linted, and leaves nearby interjections like ah, ahah, and hehe to existing behavior.

This is, admittedly, a small rule with a big emotional range.

Tests

  • cargo test -p harper-core laughter
  • cargo test -p harper-core default_config
  • cargo test -p harper-core lint_descriptions_are_clean
  • cargo run --bin harper-cli --release -- lint "hah"
  • cargo run --bin harper-cli --release -- lint "I laughed hahahah."
  • cargo run --bin harper-cli --release -- lint "hahhah"

Copy link
Copy Markdown
Collaborator

@elijah-potter elijah-potter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the spirit of the rule, but I see that it's implementation is not as contained as I would prefer. Would you mind tweaking it to remove logic from LintGroup?

Comment on lines +297 to +299
const ALLOW_INFORMAL_LAUGHTER: &str = "AllowInformalLaughter";
const SPELL_CHECK: &str = "SpellCheck";
const SPLIT_WORDS: &str = "SplitWords";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to avoid constants like this, especially if they simply stand alone and aren't clearly connected to any particular part of the code. Would you mind inlining them?

Comment on lines +798 to +808
let mut results = BTreeMap::new();
let allow_informal_laughter = self.config.is_rule_enabled(ALLOW_INFORMAL_LAUGHTER);

// Normal linters
for (key, linter) in &mut self.linters {
if self.config.is_rule_enabled(key) {
results.insert(key.to_owned(), linter.lint(document));
let mut lints = linter.lint(document);
if allow_informal_laughter && should_filter_informal_laughter_lints(key) {
lints.retain(|lint| !is_informal_laughter(lint.get_ch(document.get_source())));
}
results.insert(key.to_owned(), lints);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a rule, I try to avoid letting one linter affect the output of another, especially in a composition location like the LintGroup. It gives the struct more responsibility than it should be given.

Would it be possible to refactor this PR into a modification on the RepeatedWords rule, with some additions to the dictionary?

See:

  • harper-core/src/linting/repeated_words.rs
  • harper-core/dictionary.dict

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so would this mean it's no longer a distinct rule that a user could disable? For things like academic papers and such they won't want this to be enabled.

Copy link
Copy Markdown
Collaborator

@elijah-potter elijah-potter May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. A separate rule, maybe called SilenceLaughter could be added that stops laughter. It would be pretty straightforward to implement.

This way, each rule's responsibility is maintained, which makes it easier to audit each one down the line.

I'd be happy to make the changes for you.

Copy link
Copy Markdown
Collaborator

@elijah-potter elijah-potter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thanks!

@elijah-potter elijah-potter added this pull request to the merge queue May 12, 2026
Merged via the queue into master with commit 36af6c6 May 12, 2026
11 checks passed
@elijah-potter elijah-potter deleted the feature/let-me-laugh branch May 12, 2026 23:07
@hippietrail
Copy link
Copy Markdown
Collaborator

This also reminds me of the FillerWords rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants