feat(xtask_lintdoc): add more markdown syntax support
MODIFY
crates/rome_js_analyze/src/analyzers/no_async_promise_executor.rs
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

MODIFY
website/src/docs/lint/rules/index.md
website/src/docs/lint/rules/index.md
@@ -19,9 +19,6 @@ eleventyNavigation:
<a class="header-anchor" href="#noAsyncPromiseExecutor"></a>
</h3>
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 <code>Promise</code> to reject. This could make it difficult to debug and handle some errors.
-If a Promise executor function is using <code>await</code>, this is usually a sign that it is not actually necessary to use the <code>new Promise</code> constructor, or the scope of the <code>new Promise</code> constructor can be reduced.
</div>
<div class="rule">
<h3 data-toc-exclude id="noCompareNegZero">

MODIFY
website/src/docs/lint/rules/noAsyncPromiseExecutor.md
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

MODIFY
xtask/lintdoc/src/main.rs
xtask/lintdoc/src/main.rs
@@ -147,7 +147,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)) {
@@ -249,6 +249,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:?}")

feat(xtask_lintdoc): add more markdown syntax support (#2764)