Skip to content

feat(core): implement "despite of" lint #531

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

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

hippietrail
Copy link
Collaborator

Implements #500 but fails lint_descriptions_are_clean

I don't understand why that is or what it means, so just a draft PR sadly.

Running the tests in despite_of.rs from VS Code they all pass but just test fails:

test spell::fst_dictionary::tests::fst_contains_hello ... ok
test linting::spell_check::tests::markdown_capitalized ... ok
test linting::lint_group::tests::lint_descriptions_are_clean ... FAILED
test linting::spell_check::tests::harper_automattic_capitalized ... ok
test spell::fst_dictionary::tests::fuzzy_result_sorted_by_edit_distance ... ok

Implements Automattic#500 but fails `lint_descriptions_are_clean`
Copy link
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.

Overall, looks good! Some edits are required. Once we're done here, I'd like to make it the example in the documentation.

}

fn description(&self) -> &'static str {
"Don\"t use \"despite of\". Both \"despite\" and \"in spite of\" are correct English."
Copy link
Collaborator

Choose a reason for hiding this comment

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

You used a double-apostrophe rather than a single apostrophe here.

The failing test checks that your description does not include any errors that Harper can detect. In this particular case, it's complaining about the stuff you have in quotes. This is a known issue that I plan to resolve soon. For now, just wrap them in backticks (`) without the quotes.

In other words, replace Both \"despite\" and with Both `despite` and

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I never heard them called "double apostrophe" before but good catch on the one in "don't"!

.unwrap()
.is_uppercase();

// generate suggestion based on case
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can achieve similar behavior by using Suggestion::replace_with_match_case.

If the function's description is confusing, take a look at the source for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm more confused by some struct names than function names so far. And just finding what I can use where.


impl Default for DespiteOf {
fn default() -> Self {
let mut pattern = WordPatternGroup::default();
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're absolutely right that the ThatWhich linter is a poor example.

A slightly better constructor would define the pattern as:

// "aco" stands for "any capitalization of"
let pattern = SequencePattern::aco("despite").then_whitespace().t_aco("of");

Using the WordPatternGroup here is somewhat redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I really don't know what the alternatives are and find the existing linters hard to compare and extrapolate from. It would help new contributors a lot if some subset of them were considered “exemplars” and copiously commented. Enough to illustrate the common alternatives. Especially if you want to attract people that know less Rust than me. The new docs are helping a lot already though.

@hippietrail
Copy link
Collaborator Author

Sorry I guess I have to manually click "Ready for review" again here after I commit the requested changes?

@hippietrail hippietrail marked this pull request as ready for review January 30, 2025 07:32
@elijah-potter
Copy link
Collaborator

Looks great. I might come back in here and add comments to make it one of several models for the documentation. In the meantime, I'm gonna merge it.

@elijah-potter elijah-potter merged commit 6990d06 into Automattic:master Jan 30, 2025
4 checks passed
@hippietrail hippietrail deleted the despite_of_lint branch January 31, 2025 02:31
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 6, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [Automattic/harper/harper-ls](https://github.com/Automattic/harper) | minor | `v0.18.1` -> `v0.19.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>Automattic/harper (Automattic/harper/harper-ls)</summary>

### [`v0.19.1`](https://github.com/Automattic/harper/releases/tag/v0.19.1)

[Compare Source](Automattic/harper@v0.18.1...v0.19.1)

#### What's Changed

The biggest change in this version: the ability to ignore lints. This is some pretty new code, so we hope to hear from you all to see how we can improve it.

-   feat: issue templates by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#539
-   feat(core): even more holidays by [@&#8203;hippietrail](https://github.com/hippietrail) in Automattic/harper#533
-   feat(core): implement "despite of" lint by [@&#8203;hippietrail](https://github.com/hippietrail) in Automattic/harper#531
-   feat(html): condense spaces like most HTML parsers by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#546
-   Ignore Lints by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#529
-   fix(core): [#&#8203;548](Automattic/harper#548) `you` is not a verb by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#551
-   docs: mention [#&#8203;536](Automattic/harper#536) on installation pages by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#538
-   Site fixes and updates by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#552
-   feat(core): created framework for correcting common phrases by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#550
-   feat(core): condense multi-token Latin words and phrases by [@&#8203;elijah-potter](https://github.com/elijah-potter) in Automattic/harper#473

**Full Changelog**: Automattic/harper@v0.18.1...v0.19.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjEuNiIsInVwZGF0ZWRJblZlciI6IjM5LjE2MS42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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.

2 participants