Skip to content

feat: add markdown-no-emphasis-keywords lint#137

Open
sumitvekariya wants to merge 2 commits intoethereum:masterfrom
sumitvekariya:feat/markdown-no-emphasis-keywords
Open

feat: add markdown-no-emphasis-keywords lint#137
sumitvekariya wants to merge 2 commits intoethereum:masterfrom
sumitvekariya:feat/markdown-no-emphasis-keywords

Conversation

@sumitvekariya
Copy link
Contributor

Add markdown-no-emphasis-keywords lint

Summary

Implements a new lint markdown-no-emphasis-keywords that 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:

**MUST** be implemented          // ❌ Flagged
**SHOULD** follow this          // ❌ Flagged  
**API** documentation           // ❌ Flagged
**HTTP** protocol              // ❌ Flagged
**JSON** format                // ❌ Flagged
**XML** parsing                // ❌ Flagged
**RFC** specification          // ❌ Flagged
**EIP** proposal               // ❌ Flagged

### Italic formatting violations:
*REQUIRED* for compliance       // ❌ Flagged
*OPTIONAL* feature             // ❌ Flagged
*SHALL* implement              // ❌ Flagged
*MAY* include                  // ❌ Flagged
*RECOMMENDED* approach         // ❌ Flagged
*URL* endpoint                 // ❌ Flagged
*SQL* database                 // ❌ Flagged
*CSS* styling                  // ❌ Flagged

- 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)?,
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Comment on lines +57 to +58
in_emphasis: bool,
emphasis_type: EmphasisType,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines +103 to +107
fn depart_emph(&mut self, _ast: &Ast) -> Result<(), Self::Error> {
self.in_emphasis = false;
self.emphasis_type = EmphasisType::None;
Ok(())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens in the case of Foo bar Bazz? In markdown:

**Foo _bar_ Bazz**

Comment on lines +72 to +75
let message = format!(
"uppercase keywords should not be formatted with {} emphasis",
emphasis_desc
);
Copy link
Contributor

Choose a reason for hiding this comment

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

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).

@SamWilsn
Copy link
Contributor

SamWilsn commented Oct 14, 2025

Thanks so much for the contribution! I'm sorry it's taken me so long to review. I incorrectly assumed this was spam.

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.

Add a lint that detects bolded or italic UPPERCASE keywords

2 participants