Skip to content

Commit

Permalink
refac: Implemented reviewed changes to maintain consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Abeeujah committed Nov 4, 2024
1 parent 97da96d commit 0559ab3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions eipw-lint/src/lints/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

pub mod headings_only;
pub mod heading_first;
pub mod headings_space;
pub mod html_comments;
pub mod json_schema;
Expand All @@ -17,7 +17,7 @@ pub mod relative_links;
pub mod section_order;
pub mod section_required;

pub use self::headings_only::HeadingsOnly;
pub use self::heading_first::HeadingsOnly;
pub use self::headings_space::HeadingsSpace;
pub use self::html_comments::HtmlComments;
pub use self::json_schema::JsonSchema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

use comrak::nodes::NodeValue;
use eipw_snippets::Level;

use crate::lints::{Error, Lint};

Expand All @@ -14,17 +13,23 @@ pub struct HeadingsOnly;

impl Lint for HeadingsOnly {
fn lint<'a>(&self, slug: &'a str, ctx: &crate::lints::Context<'a, '_>) -> Result<(), Error> {
let annotation_type = Level::Error;
let second = match ctx.body().descendants().nth(1) {
Some(el) => el.data.borrow().to_owned().value,
None => return ctx.report(annotation_type.title("Cannot submit an empty proposal")),
None => {
return ctx.report(
ctx.annotation_level()
.title("Nothing is permitted between the preamble and the first heading")
.id(slug),
)
}
};
match second {
NodeValue::Heading(_) => Ok(()),
_ => {
let annotation_type = Level::Error;
ctx.report(annotation_type.title("Only Heading is allowed after FrontMatter"))
}
_ => ctx.report(
ctx.annotation_level()
.title("Only Heading is allowed after FrontMatter")
.id(slug),
),
}
}
}

0 comments on commit 0559ab3

Please sign in to comment.