Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Biome showcase#13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
nimratcoderabbit wants to merge2 commits intomain
base:main
Choose a base branch
Loading
frompreview/biome
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletionstest.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
function greet(name: string) {
console.log("Hello, " + name)
}

let unused = 123

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🛠️ Refactor suggestion

Remove unused variable.

Theunused variable is declared but never used in the code.

-let unused = 123
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let unused = 123
🤖 Prompt for AI Agents
In test.ts at line 5, there is a variable named 'unused' declared but neverused. Remove the declaration of this unused variable to clean up the code andavoid unnecessary declarations.


const x = 1
x = 2
Comment on lines +7 to +8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

⚠️ Potential issue

Fix const reassignment error.

You cannot reassign a value to a constant. This will cause a compilation error.

-const x = 1-x = 2+let x = 1+x = 2
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constx=1
x=2
letx=1
x=2
🧰 Tools
🪛 Biome (1.9.4)

[error] 7-8: Can't assign x because it's a constant

This is where the variable is defined as constant

Unsafe fix: Replace const with let if you assign it to a new value.

(lint/correctness/noConstAssign)

🤖 Prompt for AI Agents
In test.ts around lines 7 to 8, the code attempts to reassign a value to aconstant variable 'x', which causes a compilation error. To fix this, change thedeclaration of 'x' from 'const' to 'let' if reassignment is needed, or avoidreassigning 'x' altogether if it should remain constant.


const items = [1, 2, 3]
items.forEach(async item => {
await fetch(`/api/${item}`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🛠️ Refactor suggestion

Add error handling to fetch calls.

The fetch call lacks error handling, which could cause unhandled promise rejections.

-  await fetch(`/api/${item}`)+  await fetch(`/api/${item}`).catch(error => {+    console.error(`Failed to fetch /api/${item}:`, error)+  })
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
awaitfetch(`/api/${item}`)
awaitfetch(`/api/${item}`).catch(error=>{
console.error(`Failed to fetch /api/${item}:`,error)
})
🤖 Prompt for AI Agents
In test.ts at line 12, the fetch call lacks error handling which can lead tounhandled promise rejections. Wrap the fetch call in a try-catch block or use.catch() to handle any errors that may occur during the fetch operation. Ensurethat any errors are logged or handled appropriately to prevent the applicationfrom crashing.

})
Comment on lines +10 to +13

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🛠️ Refactor suggestion

Replace forEach with Promise.all for async operations.

UsingforEach with async callbacks creates side effects and doesn't wait for completion. Replace withPromise.all andmap for proper async handling.

-items.forEach(async item => {-  await fetch(`/api/${item}`)-})+await Promise.all(items.map(async item => {+  return fetch(`/api/${item}`)+}))
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constitems=[1,2,3]
items.forEach(asyncitem=>{
awaitfetch(`/api/${item}`)
})
constitems=[1,2,3]
awaitPromise.all(items.map(asyncitem=>{
returnfetch(`/api/${item}`)
}))
🤖 Prompt for AI Agents
In test.ts around lines 10 to 13, the code uses forEach with an async callback,which does not wait for the async operations to complete. Replace the forEachloop with Promise.all combined with map to run all fetch calls concurrently andproperly await their completion. This ensures all async operations finish beforeproceeding.


greet("world")

[8]ページ先頭

©2009-2025 Movatter.jp