-
Notifications
You must be signed in to change notification settings - Fork 27
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
Prevent text before the first heading #117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, how would you feel about heading_first.rs
instead? I think headings_only.rs
implies that headings are the only node type allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been updated to reflect the desired naming convention.
let annotation_type = Level::Error; | ||
ctx.report(annotation_type.title("Only Heading is allowed after FrontMatter")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with the other lints, the minimal report should look something like:
let annotation_type = Level::Error; | |
ctx.report(annotation_type.title("Only Heading is allowed after FrontMatter")) | |
self.ctx | |
.annotation_level() | |
.title("Only Heading is allowed after FrontMatter") | |
.id(self.slug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been done to maintain consistency as well
let annotation_type = Level::Error; | ||
ctx.report(annotation_type.title("Only Heading is allowed after FrontMatter")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this for the error message:
let annotation_type = Level::Error; | |
ctx.report(annotation_type.title("Only Heading is allowed after FrontMatter")) | |
ctx.report(annotation_type.title("Nothing is permitted between the preamble and the first heading")) |
All requested changes has been implemented @SamWilsn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last nit, then this looks good to merge.
consistency and improve error message ergonomics.
Hi @SamWilsn Gone through your commits on this Pull Request and I must say you had a more elegant solution than I did 🫡 I'm inspired to do more, and get better 💪 |
Not at all! I just plumbed the new lint up, wrote docs, and added line number info. It's still your algorithm! |
closes #115
This PR introduces a new linting rule to enforce a clean document structure by preventing any text from appearing before the first heading in EIPS. This ensures consistency across all EIPS.