From 5feabe3fe28f3e1119a5041031bb42c069b463fe Mon Sep 17 00:00:00 2001 From: Dj Isaac Date: Fri, 12 Apr 2024 19:43:50 -0500 Subject: [PATCH 1/3] Add a forOf to useForOf docs --- website/src/content/docs/linter/rules/use-for-of.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/src/content/docs/linter/rules/use-for-of.md b/website/src/content/docs/linter/rules/use-for-of.md index a26e1359aedc..b59183c04ea0 100644 --- a/website/src/content/docs/linter/rules/use-for-of.md +++ b/website/src/content/docs/linter/rules/use-for-of.md @@ -47,6 +47,12 @@ for (let i = 0, j = 0; i < array.length; i++) { } ``` +```jsx +for (var i of array) { + console.log(i) +} +``` + ## Related links - [Disable a rule](/linter/#disable-a-lint-rule) From 470c11b80d7a8820f321d7edbcb60b2cb71b5f06 Mon Sep 17 00:00:00 2001 From: Dj Isaac Date: Fri, 12 Apr 2024 19:47:04 -0500 Subject: [PATCH 2/3] Move forOf to the top --- website/src/content/docs/linter/rules/use-for-of.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/src/content/docs/linter/rules/use-for-of.md b/website/src/content/docs/linter/rules/use-for-of.md index b59183c04ea0..f075ac222003 100644 --- a/website/src/content/docs/linter/rules/use-for-of.md +++ b/website/src/content/docs/linter/rules/use-for-of.md @@ -35,6 +35,12 @@ for (let i = 0; i < array.length; i++) { ### Valid +```jsx +for (let i of array) { + console.log(i); +} +``` + ```jsx for (let i = 0; i < array.length; i++) { console.log(i, array[i]); @@ -47,12 +53,6 @@ for (let i = 0, j = 0; i < array.length; i++) { } ``` -```jsx -for (var i of array) { - console.log(i) -} -``` - ## Related links - [Disable a rule](/linter/#disable-a-lint-rule) From e2e3ae088c5e82e99a0ea69ba528b3e2081f1df7 Mon Sep 17 00:00:00 2001 From: Dj Isaac Date: Sat, 13 Apr 2024 03:05:47 -0500 Subject: [PATCH 3/3] docs: add better example of useforof --- crates/biome_js_analyze/src/lint/style/use_for_of.rs | 6 ++++++ website/src/content/docs/linter/rules/use-for-of.md | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/biome_js_analyze/src/lint/style/use_for_of.rs b/crates/biome_js_analyze/src/lint/style/use_for_of.rs index afcfffa38d91..465731885de5 100644 --- a/crates/biome_js_analyze/src/lint/style/use_for_of.rs +++ b/crates/biome_js_analyze/src/lint/style/use_for_of.rs @@ -29,6 +29,12 @@ declare_rule! { /// ### Valid /// /// ```js + /// for (let item of array) { + /// console.log(item); + /// } + /// ``` + /// + /// ```js /// for (let i = 0; i < array.length; i++) { /// console.log(i, array[i]); /// } diff --git a/website/src/content/docs/linter/rules/use-for-of.md b/website/src/content/docs/linter/rules/use-for-of.md index f075ac222003..b891b56a3eb3 100644 --- a/website/src/content/docs/linter/rules/use-for-of.md +++ b/website/src/content/docs/linter/rules/use-for-of.md @@ -23,22 +23,22 @@ for (let i = 0; i < array.length; i++) {
style/useForOf.js:1:1 lint/style/useForOf ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
    Use for-of loop instead of a for loop.
-  
+
   > 1 │ for (let i = 0; i < array.length; i++) {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   > 2 │   console.log(array[i]);
   > 3 │ }
    ^
     4 │ 
-  
+
 
### Valid ```jsx -for (let i of array) { - console.log(i); -} +for (let item of array) { + console.log(item); + } ``` ```jsx