New Rule: no-trailing-spaces
- Dominant language
- JavaScript
- Stars
- 581
- Forks
- 92
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 11
Description
### Rule details
Disallow trailing whitespace at the end of lines in Markdown content, except where it is used intentionally to create a hard line break.
In CommonMark, a line ending preceded by 2 or more spaces produces a hard break (`
`). Anywhere else, trailing whitespace has no effect on rendering.
This rule allows exactly two trailing-space counts and flags everything else:
- 0 trailing spaces: allowed (no effect, nothing to flag).
- 1 trailing space: incorrect — has no effect.
- 2 trailing spaces: allowed (intentional hard break).
- 3 or more trailing spaces: incorrect — exceeds what's needed for a hard break.
### What type of rule is this?
Warns about a potential problem
### Example code
```markdown
This line has no trailing whitespace.[0 space]
This line ends with a hard break.[2 spaces]
Next line.
This line has one trailing space.[1 space]
This line has three trailing spaces.[more than 2 spaces]
Next line.
```
### Prior Art
markdownlint - [md009](https://github.com/DavidAnson/markdownlint/blob/main/doc/md009.md)
### Participation
- [x] I am willing to submit a pull request to implement this rule.
### AI acknowledgment
- [ ] I did not use AI to generate this issue report.
- [x] (If the above is not checked) I have reviewed the AI-generated content before submitting.
### Additional comments
Disclosure: I'm a participant of [open source contribution program OSSCA](https://github.com/eslint-ossca)
Contributor guide
Assessment
This issue has not been assessed yet.