diff --git a/crates/rome_js_analyze/src/analyzers/no_async_promise_executor.rs b/crates/rome_js_analyze/src/analyzers/no_async_promise_executor.rs index b7e54dcbb45..52c1aab26de 100644 --- a/crates/rome_js_analyze/src/analyzers/no_async_promise_executor.rs +++ b/crates/rome_js_analyze/src/analyzers/no_async_promise_executor.rs @@ -5,9 +5,10 @@ use rome_rowan::{AstNode, AstSeparatedList}; declare_rule! { /// Disallows using an async function as a Promise executor. + /// /// The executor function can also be an async function. However, this is usually a mistake, for a few reasons: - /// If an async executor function throws an error, the error will be lost and won't cause the newly-constructed `Promise` to reject. This could make it difficult to debug and handle some errors. - /// If a Promise executor function is using `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor, or the scope of the `new Promise` constructor can be reduced. + /// 1. If an async executor function throws an error, the error will be lost and won't cause the newly-constructed `Promise` to reject. This could make it difficult to debug and handle some errors. + /// 2. If a Promise executor function is using `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor, or the scope of the `new Promise` constructor can be reduced. /// /// ## Examples /// ### Valid diff --git a/website/src/docs/lint/rules/index.md b/website/src/docs/lint/rules/index.md index 5d553181c86..da1cfbd744f 100644 --- a/website/src/docs/lint/rules/index.md +++ b/website/src/docs/lint/rules/index.md @@ -19,9 +19,6 @@ eleventyNavigation: Disallows using an async function as a Promise executor. -The executor function can also be an async function. However, this is usually a mistake, for a few reasons: -If an async executor function throws an error, the error will be lost and won't cause the newly-constructed Promise to reject. This could make it difficult to debug and handle some errors. -If a Promise executor function is using await, this is usually a sign that it is not actually necessary to use the new Promise constructor, or the scope of the new Promise constructor can be reduced.

diff --git a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md index 6de0beb318a..85e55c9a2f8 100644 --- a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md +++ b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md @@ -6,10 +6,11 @@ layout: layouts/rule.liquid # noAsyncPromiseExecutor Disallows using an async function as a Promise executor. + The executor function can also be an async function. However, this is usually a mistake, for a few reasons: -If an async executor function throws an error, the error will be lost and won't cause the newly-constructed `Promise` to reject. This could make it difficult to debug and handle some errors. -If a Promise executor function is using `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor, or the scope of the `new Promise` constructor can be reduced. +1. If an async executor function throws an error, the error will be lost and won't cause the newly-constructed `Promise` to reject. This could make it difficult to debug and handle some errors. +2. If a Promise executor function is using `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor, or the scope of the `new Promise` constructor can be reduced. ## Examples ### Valid diff --git a/xtask/lintdoc/src/main.rs b/xtask/lintdoc/src/main.rs index d18318f661a..444b25a6044 100644 --- a/xtask/lintdoc/src/main.rs +++ b/xtask/lintdoc/src/main.rs @@ -143,7 +143,7 @@ fn parse_documentation( // Tracks the content of the current code block if it's using a // language supported for analysis let mut language = None; - + let mut list_order = None; for event in parser { if is_summary { if matches!(event, Event::End(Tag::Paragraph)) { @@ -245,6 +245,28 @@ fn parse_documentation( writeln!(content)?; } + Event::Start(Tag::List(num)) => { + if let Some(num) = num { + list_order = Some(num); + } + } + + Event::End(Tag::List(_)) => { + list_order = None; + } + Event::Start(Tag::Item) => { + if let Some(num) = list_order { + write!(content, "{num}. ")?; + } else { + write!(content, "- ")?; + } + } + + Event::End(Tag::Item) => { + list_order = list_order.map(|item| item + 1); + writeln!(content)?; + } + _ => { // TODO: Implement remaining events as required bail!("unimplemented event {event:?}")