From e0b85eb6a087f2c6bd204374da0452b11d22c260 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Thu, 23 Jun 2022 00:41:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20more=20markdow?= =?UTF-8?q?n=20syntax=20support=20in=20declare=5Fdoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xtask/lintdoc/src/main.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/xtask/lintdoc/src/main.rs b/xtask/lintdoc/src/main.rs index 6990e7f5643..d3aabb6ba6b 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 = Some(0u64); 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:?}") From fc9e74ea802c6e7f73aff58cfcd75b6e9d7c0692 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Thu, 23 Jun 2022 00:45:55 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20more=20syntax=20supp?= =?UTF-8?q?ort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/analyzers/no_async_promise_executor.rs | 6 +++--- website/src/docs/lint/rules/index.md | 3 --- website/src/docs/lint/rules/noAsyncPromiseExecutor.md | 6 +++--- xtask/lintdoc/src/main.rs | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) 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..045df58972e 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,9 @@ 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. + /// - The executor function can also be an async function. However, this is usually a mistake, for a few reasons: + /// 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 abc974f9b86..527e4857dbd 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..7f7d0508fdc 100644 --- a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md +++ b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md @@ -6,10 +6,10 @@ 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. +- The executor function can also be an async function. However, this is usually a mistake, for a few reasons: +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 d3aabb6ba6b..cfe72447662 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 = Some(0u64); + let mut list_order = None; for event in parser { if is_summary { if matches!(event, Event::End(Tag::Paragraph)) { @@ -266,7 +266,7 @@ fn parse_documentation( list_order = list_order.map(|item| item + 1); writeln!(content)?; } - + _ => { // TODO: Implement remaining events as required bail!("unimplemented event {event:?}") From 2a3e325890e2751258eb9d4699087ece56f1e347 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Sat, 25 Jun 2022 00:26:14 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20lint=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rome_js_analyze/src/analyzers/no_async_promise_executor.rs | 2 +- website/src/docs/lint/rules/index.md | 1 + website/src/docs/lint/rules/noAsyncPromiseExecutor.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) 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 045df58972e..b8de67d3782 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,7 +5,7 @@ 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: + /// The executor function can also be an async function. However, this is usually a mistake, for a few reasons: /// 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. /// diff --git a/website/src/docs/lint/rules/index.md b/website/src/docs/lint/rules/index.md index 527e4857dbd..5862f6e58d5 100644 --- a/website/src/docs/lint/rules/index.md +++ b/website/src/docs/lint/rules/index.md @@ -19,6 +19,7 @@ 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:

diff --git a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md index 7f7d0508fdc..726cc56e4f9 100644 --- a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md +++ b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md @@ -6,8 +6,8 @@ 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: -- The executor function can also be an async function. However, this is usually a mistake, for a few reasons: 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 From d0af717e76494b74d607c94abb23e9bf3c372e2b Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Mon, 27 Jun 2022 15:41:35 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20address=20cr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rome_js_analyze/src/analyzers/no_async_promise_executor.rs | 1 + website/src/docs/lint/rules/index.md | 1 - website/src/docs/lint/rules/noAsyncPromiseExecutor.md | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) 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 b8de67d3782..1e684c448ba 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,6 +5,7 @@ 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: /// 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. diff --git a/website/src/docs/lint/rules/index.md b/website/src/docs/lint/rules/index.md index bfc39d6e9f6..da1cfbd744f 100644 --- a/website/src/docs/lint/rules/index.md +++ b/website/src/docs/lint/rules/index.md @@ -19,7 +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:

diff --git a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md index 726cc56e4f9..85e55c9a2f8 100644 --- a/website/src/docs/lint/rules/noAsyncPromiseExecutor.md +++ b/website/src/docs/lint/rules/noAsyncPromiseExecutor.md @@ -6,6 +6,7 @@ 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: 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. From 9376ae4d02ea1e02a9a90e2ace8dc3ebcb081123 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Mon, 27 Jun 2022 15:42:55 +0800 Subject: [PATCH 5/5] =?UTF-8?q?style:=20=F0=9F=92=84=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rome_js_analyze/src/analyzers/no_async_promise_executor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1e684c448ba..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,7 +5,7 @@ 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: /// 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.