Skip to content

Re-enable the ESLint rules disabled for assets/js - #8230

Merged
donnapep merged 11 commits into
trunkfrom
update/eslint-reenable-rules
Sep 4, 2026
Merged

donnapep merged 11 commits into
trunkfrom
update/eslint-reenable-rules

Conversation

@donnapep

@donnapep donnapep commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Proposed Changes

During the @wordpress/scripts 34 / ESLint 10 flat-config migration, a broad set of ESLint rules were switched off for assets/js/** to get CI green. This turns them back on and fixes the resulting violations, so the linter again catches real problems (unused variables, shadowing, loose equality) in this code.

Almost all changes are mechanical and behavior-preserving. A few things are worth a reviewer's attention:

  • User-facing fix: the "Generate quiz questions with AI" upsell label used the wrong text domain (sensei-pro), so it was never translatable on a Sensei site. Corrected to sensei-lms.
  • Behavior-sensitive rewrites, all preserved: loose == comparisons that relied on type coercion were rewritten to keep the same result for both string and numeric inputs (lesson quick-edit checkbox normalization, empty bulk-action detection). Server-facing identifiers — $_POST/$_GET keys, CSS selectors, HTML ids, and localized globals — were deliberately left unchanged during the camelcase renames.

Testing Instructions

The riskiest edits are in untested legacy jQuery (grading, student management, lesson quick-edit) and the course editor sidebar. Verify these by hand:

  • Lesson quick-edit (Lessons list → hover a lesson → Quick Edit): set "Pass required", "Enable quiz reset", and "Random question order" to Yes/No, click Update, and confirm the values persisted by opening the lesson editor's Quiz block settings; confirm no JavaScript console errors during the Quick Edit. (The Quick Edit dropdowns always display "-- No Change --" regardless of saved state — a pre-existing display bug unrelated to this PR — so verify persistence in the block editor, not in Quick Edit.)
  • Grading auto-grade (Sensei LMS → Grading → grade a quiz submission with auto-gradable questions): confirm answers auto-mark correct/incorrect and the total grade and percentage calculate correctly, and that manual grade overrides still update the total.
  • Student management actions (Sensei LMS → Students): withdraw and then re-enrol a student (the confirm dialog appears and the action applies), and reset/remove a student's course progress (confirm dialog appears, row updates).
  • Edit start date (Students → edit a student's enrolment start date): save a new date and confirm it persists after reload.
  • Add student search (Students → Add Student to Course): type ≥3 characters, confirm the search dropdown populates and the Add button enables only when a student is selected.
  • Bulk student actions (Students list): confirm the Select Action button stays disabled until both at least one student checkbox is ticked and a real action is chosen in the "Select Bulk Actions" dropdown — leaving the dropdown on the "Select Bulk Actions" placeholder keeps it disabled.
  • Enrolled courses "more" link (Students list, a student enrolled in several courses → click the "…more" link in their Courses column): confirm the extra courses load in via AJAX (exercises the refactored bulk-actions AJAX path).
  • Course editor sidebar (edit a Course → open the Course Settings plugin sidebar via the Sensei pin icon or the ⋮ menu → expand the General section): change the Teacher and toggle "Feature this course"; confirm both save and reload correctly.
  • Confirm no new JavaScript console errors on any of the above.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Fixed

Message

Fixed the text domain on the "Generate quiz questions with AI" upsell label so it can be translated.

donnapep and others added 6 commits September 3, 2026 19:08
Turn on object-shorthand, prefer-const, no-var, no-else-return,
no-lonely-if, no-useless-return, and prettier/prettier. All fixes are
mechanical and behavior-preserving.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Turn on jsdoc/check-tag-names, require-param-type, require-returns-type,
and require-returns-check. Add missing param/return types and
descriptions, drop stale @return void tags, and allow the intentional
@hook and @Usage custom tags via definedTags.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Turn on no-shadow, @wordpress/no-unused-vars-before-return, and
@wordpress/i18n-text-domain. Rename shadowed variables, move
declarations past early returns so they aren't assigned when unused, and
correct the text domain on the AI upsell string from sensei-pro to
sensei-lms.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Turn on no-alert. The two confirm() calls guarding destructive
enrollment and progress changes are intentional, so keep them behind
targeted eslint-disable-next-line comments rather than changing behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Turn on eqeqeq. Most sites compare values already known to be strings or
parseInt results, so they become === / !== directly. Where the loose
compare intentionally coerced, preserve behavior for both string and
numeric inputs: normalize the lesson quick-edit checkbox fields with an
includes() membership check, and match the empty bulk action against the
'0' placeholder string.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Turn on camelcase and rename local variables from snake_case to
camelCase. Server-facing identifiers are preserved: object keys sent as
$_POST/$_GET data, CSS selectors, HTML ids and localized globals
(ajax_object, sensei_log_event, sensei_event_logging) are left unchanged,
and properties:never keeps payload keys exempt. Renames were applied with
scope-accurate binding analysis so every reference stays consistent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 3, 2026 23:38
@donnapep donnapep added this to the 4.26.4 milestone Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

WordPress Playground Preview

The changes in this pull request can previewed and tested using a WordPress Playground instance.

Open WordPress Playground Preview

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated assets/js/** ESLint enforcement likely breaks CI because at least one legacy script still violates rules that were previously disabled (e.g., no-alert/eqeqeq usage).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR restores a stricter ESLint rule set for assets/js/** (previously broadly disabled during the ESLint 10 flat-config migration) and applies mostly mechanical, behavior-preserving refactors to bring the code back into compliance. It also fixes a user-facing i18n issue where the “Generate quiz questions with AI” upsell label used the wrong text domain.

Changes:

  • Re-enable ESLint enforcement for assets/js/** and tighten JSDoc tag validation.
  • Mechanical JS cleanups across legacy jQuery/admin scripts (const/let, strict equality, shadowing fixes, object shorthand, etc.).
  • Fix the upsell label’s text domain from sensei-pro to sensei-lms and add a changelog entry.
File summaries
File Description
eslint.config.js Re-enables rule enforcement for assets/js/** and adjusts JSDoc tag-name validation / camelcase handling.
changelog/update-eslint-reenable-rules Adds the patch-level changelog entry for the i18n fix.
assets/js/settings.js JSDoc + strict equality and minor modernization.
assets/js/ranges.js Modernizes variable declarations and object callback syntax.
assets/js/question-answer-tinymce-editor.js Tightens JSDoc typing and strict equality for placeholder logic.
assets/js/modules-admin.js Modernizes legacy admin script patterns (const/let, shorthand, etc.).
assets/js/learners-general.js Refactors learner management actions for lint compliance (incl. confirm handling).
assets/js/learners-bulk-actions.js Refactors bulk actions logic and preserves placeholder-action detection semantics.
assets/js/grading-general.js Refactors grading/auto-grade logic for lint compliance and stricter comparisons.
assets/js/frontend/course-video/video-blocks-manager.js Minor formatting + JSDoc tag normalization.
assets/js/file-upload-question-type.js Minor formatting / readability adjustments.
assets/js/admin/settings/experimental-features.js Minor modernization (const).
assets/js/admin/sensei-notice-dismiss.js Improves JSDoc typing.
assets/js/admin/ordering.js Minor modernization (let).
assets/js/admin/message-menu-fix.js Minor modernization (const).
assets/js/admin/lesson-quick-edit.js Preserves checkbox normalization behavior while eliminating loose equality.
assets/js/admin/lesson-bulk-edit.js Minor modernization (const) in bulk edit handler.
assets/js/admin/lesson-ai.js Fixes i18n text domain for the upsell label.
assets/js/admin/event-logging.js Refactors event logging function signature / naming and const correctness.
assets/js/admin/course-general-sidebar.js Avoids variable shadowing and tightens comparisons in sidebar controls.
assets/js/admin/course-edit.js Refactors tracking callback naming / const usage.
Review details
  • Files reviewed: 21/21 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread eslint.config.js
Rename the wp_localize_script handle from ajax_object to ajaxObject and
update its sole JS reference, so the camelcase allow-list exemption is no
longer needed. Drop it from the ESLint config.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The sensei_event_logging → senseiEventLogging rename is incomplete and breaks existing runtime consumers (e.g. assets/shared/helpers/log-event.js).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

assets/js/learners-bulk-actions.js:211

  • $userId and $dataNonce are plain string values, not jQuery objects; the $ prefix is misleading here (especially next to $hiddenPosts, which is a jQuery object). Renaming improves readability and avoids confusion when maintaining this legacy jQuery code.
    changelog/update-eslint-reenable-rules:4
  • This PR description indicates the changelog entry will be auto-generated by CI (“Automatically create a changelog entry”), but this PR also commits a changelog/ entry file. The repo convention is to do one or the other (not both), otherwise you can end up with duplicate entries or confusing review/CI behavior.
  • Files reviewed: 22/22 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread includes/class-sensei-admin.php Outdated
Rename the wp_localize_script handle from sensei_event_logging to
senseiEventLogging and update its sole JS reference. The global is defined
and consumed only within Sensei LMS (Sensei Pro references the same-named
PHP filter hooks, not this JS global), so no allow-list exemption is
needed. Only sensei_log_event, which Sensei Pro's frontend JS calls,
remains exempt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@donnapep
donnapep force-pushed the update/eslint-reenable-rules branch from 5720f92 to c90d2cd Compare September 4, 2026 14:21
donnapep and others added 2 commits September 4, 2026 11:34
Restore the ajax_object and sensei_event_logging wp_localize_script
handles and JS references, and add them back to the camelcase allow-list.
Renaming these window globals is a backward-incompatible change to
undocumented surfaces third-party code could read, which is not worth it
in a lint cleanup; exempting them (as with sensei_log_event) is the safe,
consistent choice.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Usage is not a recognized JSDoc tag and nothing consumes it, so replace
it with the built-in @example tag on the sensei-modal usage block and
drop 'usage' from the check-tag-names allow-list. 'hook' stays allowed
since wp-hookdoc defines it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@donnapep
donnapep enabled auto-merge September 4, 2026 17:45
@donnapep
donnapep merged commit 6a2f6ae into trunk Sep 4, 2026
21 checks passed
@donnapep
donnapep deleted the update/eslint-reenable-rules branch September 4, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants