feat: add markdown-no-emphasis-keywords lint#137
feat: add markdown-no-emphasis-keywords lint#137sumitvekariya wants to merge 2 commits intoethereum:masterfrom
Conversation
- Add new lint to detect uppercase keywords in bold/italic formatting - Detects any uppercase keywords (2+ consecutive uppercase letters) - Prevents inappropriate emphasis formatting of keywords like MUST, API, HTTP, etc. - Includes comprehensive tests covering various scenarios - Resolves ethereum#136
- Format code in known_lints.rs and no_emphasis_keywords.rs - Ensure consistent code style across the project
| slug, | ||
| in_emphasis: false, | ||
| emphasis_type: EmphasisType::None, | ||
| uppercase_regex: Regex::new(r"\b[A-Z]{2,}\b").map_err(Error::custom)?, |
There was a problem hiding this comment.
Since there's a fixed list of keywords from the RFC ("MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL"), instead of using a regex, I think it would be safer to explicitly list them and make it configurable. What do you think?
| in_emphasis: bool, | ||
| emphasis_type: EmphasisType, |
There was a problem hiding this comment.
| in_emphasis: bool, | |
| emphasis_type: EmphasisType, | |
| emphasis_type: Option<EmphasisType>, |
It's less error prone to combine the bool with the kind. This way you can't accidentally represent the state in_emphasis == false && emphasis_type != None.
| fn depart_emph(&mut self, _ast: &Ast) -> Result<(), Self::Error> { | ||
| self.in_emphasis = false; | ||
| self.emphasis_type = EmphasisType::None; | ||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
What happens in the case of Foo bar Bazz? In markdown:
**Foo _bar_ Bazz**| let message = format!( | ||
| "uppercase keywords should not be formatted with {} emphasis", | ||
| emphasis_desc | ||
| ); |
There was a problem hiding this comment.
I think you could simplify this to something like:
keywords should be uppercase and otherwise unadorned
or something. Specifying the type of formatting doesn't seem to add much to the error message, and might make an author using bold think they're supposed to use italic (or the other way around).
|
Thanks so much for the contribution! I'm sorry it's taken me so long to review. I incorrectly assumed this was spam. |
Add markdown-no-emphasis-keywords lint
Summary
Implements a new lint
markdown-no-emphasis-keywordsthat detects uppercase keywords (2+ consecutive uppercase letters) formatted with bold or italic emphasis. This helps maintain consistent formatting standards in EIP documents by preventing inappropriate emphasis on keywords.Closes #136
What this lint detects ❌
The lint flags uppercase keywords when they are formatted with bold (
**text**) or italic (*text*) emphasis:Bold formatting violations: