fix: #3614938 Resolve ESLint findings
Summary
Updates comment_notify.js to current Drupal JavaScript formatting, method shorthand, and jQuery event binding standards without changing the checkbox behavior.
Why these changes were needed
| Original code | ESLint rule | Why it failed | Resolution |
|---|---|---|---|
"use strict"; |
strict |
ESLint already treats the file as strict, making the directive unnecessary. | Removed the redundant directive. |
attach: function (context) |
object-shorthand |
Drupal JavaScript standards require object method shorthand. | Changed it to attach(context). |
.bind("change", handler) |
no-jquery/no-bind |
Drupal prohibits the legacy jQuery .bind() event API. |
Replaced it with the equivalent .on("change", handler). |
| Double-quoted JavaScript strings | prettier/prettier |
The current Prettier configuration requires single quotes. | Changed the affected strings to single quotes. |
Computed show or hide call formatting |
prettier/prettier |
The expression did not match the configured line wrapping. | Applied the required multiline formatting. |
| Missing statement terminator | prettier/prettier |
The formatted computed method call requires a semicolon. | Added the semicolon. |
Behavioral safety
- The Drupal behavior still attaches with the supplied
context. - Both element selectors are unchanged.
- jQuery implements
.bind()through.on()for this use case, so the event behavior is equivalent. - The event callback remains a normal function so
this.checkedcontinues to reference the changed checkbox. - The initial
.trigger("change")behavior remains in place. - No
once()behavior was introduced, preserving existing AJAX reattachment behavior. - Mouse and keyboard activation continue to use the native checkbox
changeevent.
Validation
- Manual browser testing confirmed that selecting Notify me when new comments are posted displays the All comments and Replies to my comment options, and clearing it hides them.
- Complete Comment Notify test directory passed locally: 17 tests and 483 assertions.
- ESLint job passed: https://git.drupalcode.org/project/comment_notify/-/jobs/11364565
- Current MR pipeline completed successfully: https://git.drupalcode.org/project/comment_notify/-/pipelines/912689
Closes #3614938
AI-Generated: Yes (OpenAI Codex inspected CI, implemented and reviewed the focused changes, ran local validation, and assisted with this merge request description. A human reviewed the behavior before merge.)
Edited by David Valdez