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

Eslint showcase #12

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nimratcoderabbit wants to merge 2 commits into main from preview/eslint
Closed
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions eslint/test.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const foo = 42
let bar
console.log("Hello World")
if (foo == "42") {
console.log("Loose equality!")
}
Copy link

@coderabbitai coderabbitai bot Jul 14, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use strict equality instead of loose equality.

Replace the loose equality operator (==) with strict equality (===) to avoid unexpected type coercion behavior. This prevents potential bugs and aligns with JavaScript best practices.

-if (foo == "42") {
- console.log("Loose equality!")
+if (foo === 42) {
+ console.log("Strict equality!");
+}

Alternatively, if you specifically need to compare with a string, convert the number to string:

-if (foo == "42") {
- console.log("Loose equality!")
+if (foo.toString() === "42") {
+ console.log("String comparison!");
+}

Also add a semicolon after the console.log statement:

- console.log("Loose equality!")
+ console.log("Loose equality!");

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In eslint/test.js around lines 4 to 6, replace the loose equality operator (==)
with the strict equality operator (===) to prevent type coercion issues. Also,
add a semicolon after the console.log statement to follow JavaScript syntax best
practices.


AltStyle によって変換されたページ (->オリジナル) /