-
-
Notifications
You must be signed in to change notification settings - Fork 643
feat(lint): no-alert rule #6355
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
Conversation
CodSpeed Performance ReportMerging #6355 will not alter performanceComparing Summary
|
let name_text = name.text(); | ||
|
||
if matches!(name_text, "alert" | "confirm" | "prompt") { | ||
// Check if this is actually a global function call (not a local variable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
window.prompt("enter name"); | ||
|
||
// Bracket notation calls (should trigger the rule) | ||
window["alert"]("bracket notation"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says it should trigger, but I don't think it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch, thank you. Should be fixed now.
Co-authored-by: Naoki Ikeguchi <[email protected]>
Co-authored-by: Naoki Ikeguchi <[email protected]>
} | ||
|
||
fn is_global_object(name: &str) -> bool { | ||
GLOBAL_OBJECTS.contains(&name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open question - should we care about cases like:
let anyAlias = window;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote for no, otherwise we could keep chasing an endless amount of cases that are not yet caught 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Do you want to add a changeset?
} | ||
|
||
fn is_global_object(name: &str) -> bool { | ||
GLOBAL_OBJECTS.contains(&name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote for no, otherwise we could keep chasing an endless amount of cases that are not yet caught 😅
…iome into shew/no-alert-rule
🦋 Changeset detectedLatest commit: 1b48d29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@arendjr Not the first time I've forgotten to add a changeset in this repo! Thanks for the reminder, added it on. |
Summary
Adds the
no-alert
rule from ESLint.Test Plan
Added valid/invalid tests for the rule.