diff --git a/eipw-lint/src/lints/markdown.rs b/eipw-lint/src/lints/markdown.rs index 4e17e3e4..ebeae5ad 100644 --- a/eipw-lint/src/lints/markdown.rs +++ b/eipw-lint/src/lints/markdown.rs @@ -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; @@ -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; diff --git a/eipw-lint/src/lints/markdown/headings_only.rs b/eipw-lint/src/lints/markdown/heading_first.rs similarity index 60% rename from eipw-lint/src/lints/markdown/headings_only.rs rename to eipw-lint/src/lints/markdown/heading_first.rs index b891a28b..cdcd2b12 100644 --- a/eipw-lint/src/lints/markdown/headings_only.rs +++ b/eipw-lint/src/lints/markdown/heading_first.rs @@ -5,7 +5,6 @@ */ use comrak::nodes::NodeValue; -use eipw_snippets::Level; use crate::lints::{Error, Lint}; @@ -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), + ), } } } diff --git a/eipw-lint/tests/lint_markdown_headings_only.rs b/eipw-lint/tests/lint_markdown_heading_first.rs similarity index 100% rename from eipw-lint/tests/lint_markdown_headings_only.rs rename to eipw-lint/tests/lint_markdown_heading_first.rs