Skip to content

Fix auto-correctable eslint errors in frontend/#23256

Open
myabc wants to merge 1 commit into
devfrom
fix/eslint-whitespace-errors
Open

Fix auto-correctable eslint errors in frontend/#23256
myabc wants to merge 1 commit into
devfrom
fix/eslint-whitespace-errors

Conversation

@myabc
Copy link
Copy Markdown
Contributor

@myabc myabc commented May 18, 2026

Ticket

n/a

What are you trying to accomplish?

Fix auto-correctable eslint errors in frontend/. Also fixes trailing whitespace errors.

Screenshots

What approach did you choose and why?

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@myabc myabc marked this pull request as ready for review May 18, 2026 22:12
Copilot AI review requested due to automatic review settings May 18, 2026 22:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to eliminate auto-correctable ESLint issues (plus trailing whitespace) across the frontend/ TypeScript code, primarily by applying optional chaining and refactoring DOM lookups.

Changes:

  • Replaced a number of verbose null checks with optional chaining and simplified boolean expressions.
  • Refactored many DOM lookups from as HTMLElement/HTMLInputElement assertions to postfix non-null assertions (!).
  • Minor spec wording cleanup and whitespace-only adjustments.

Reviewed changes

Copilot reviewed 37 out of 41 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
frontend/src/turbo/turbo-global-listeners.ts Adjusts DOM lookup for #content when warning bar is present.
frontend/src/stimulus/controllers/dynamic/work-packages/export/generate-pdf-form.controller.ts Refactors caption DOM lookup in PDF export form.
frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts Refactors focus logic DOM lookups in date picker preview.
frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts Refactors DOM lookups for sort-by config rows/selects.
frontend/src/stimulus/controllers/dynamic/shares/bulk-selection.controller.ts Removes a cast affecting selected permission label typing.
frontend/src/stimulus/controllers/dynamic/reporting/page.controller.ts Uses optional chaining and refactors querySelector usage.
frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts Refactors DOM lookup for calendar column width synchronization.
frontend/src/stimulus/controllers/dynamic/menus/main.controller.ts Refactors DOM lookup for back navigation arrow.
frontend/src/stimulus/controllers/dynamic/hide-sections.controller.ts Refactors section lookup and dataset access in hide handler.
frontend/src/stimulus/controllers/dynamic/costs/budget-subform.controller.ts Refactors DOM lookup for #budget_fixed_date.
frontend/src/stimulus/controllers/dynamic/admin/registration.controller.ts Refactors checked radio lookup for registration settings.
frontend/src/stimulus/controllers/dynamic/admin/progress-tracking.controller.ts Refactors checked radio lookup for progress mode selection.
frontend/src/stimulus/controllers/dynamic/admin/hierarchy-item.controller.ts Refactors DOM lookup for drag/drop origin element.
frontend/src/stimulus/controllers/dynamic/admin/custom-fields.controller.ts Refactors DOM lookups when duplicating custom option rows.
frontend/src/app/shared/helpers/chronic_duration.spec.ts Test description wording cleanup.
frontend/src/app/shared/directives/search-highlight.directive.ts Simplifies highlight early-return condition.
frontend/src/app/shared/components/searchable-project-list/searchable-project-list.service.ts Refactors optional chaining around active item click.
frontend/src/app/shared/components/persistent-toggle/persistent-toggle.component.ts Removes trailing whitespace.
frontend/src/app/shared/components/op-context-menu/handlers/wp-create-settings-menu.directive.ts Removes trailing whitespace.
frontend/src/app/shared/components/grids/grid/resize.service.ts Simplifies resized-area check using optional chaining.
frontend/src/app/shared/components/grids/grid/area.service.ts Simplifies ignored-area filter using optional chaining.
frontend/src/app/shared/components/fields/edit/field-types/project-edit-field.component.ts Refactors access to changeset type link for filter building.
frontend/src/app/shared/components/fields/edit/field-handler/hal-resource-edit-field-handler.ts Refactors inline edit target lookup for focusing.
frontend/src/app/shared/components/fields/display/field-types/wp-spent-time-display-field.module.ts Removes redundant string cast for project identifier.
frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts Refactors editable wrapper lookup.
frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.ts Refactors dialog container lookup.
frontend/src/app/shared/components/datepicker/basic-range-date-picker/basic-range-date-picker.component.ts Refactors dialog container lookup.
frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-group-by.service.ts Simplifies grouped-by check using optional chaining.
frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts Refactors timeline bar lookup.
frontend/src/app/features/work-packages/components/wp-table/sort-header/sort-header.directive.ts Simplifies current-sort comparison using optional chaining.
frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts Simplifies update-link comparison using optional chaining.
frontend/src/app/features/work-packages/components/wp-list/wp-list-invalid-query.service.ts Simplifies group-by restore lookup using optional chaining.
frontend/src/app/features/work-packages/components/wp-inline-create/wp-inline-create.component.ts Simplifies current WP comparison using optional chaining.
frontend/src/app/features/work-packages/components/wp-fast-table/handlers/row/wp-state-links-handler.ts Refactors closest-element lookups for state link handling.
frontend/src/app/features/work-packages/components/wp-fast-table/handlers/cell/edit-cell-handler.ts Removes trailing whitespace.
frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.spec.ts Test description wording cleanup.
frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts Simplifies memoization check using optional chaining.
frontend/src/app/features/calendar/op-work-packages-calendar.service.ts Removes redundant casts from URL param parsing and JSON.parse input.
frontend/src/app/features/boards/board/board-list/board-list.component.ts Refactors pathname matching to RegExp.exec.
frontend/src/app/features/bim/ifc_models/toolbar/manage-ifc-models-button/bim-manage-ifc-models-button.component.ts Removes trailing whitespace.
frontend/src/app/features/admin/editable-query-props/editable-query-props.component.ts Removes an eslint-disable comment line.
Comments suppressed due to low confidence (5)

frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts:123

  • target.closest(...)! is inferred as Element and ! removes nullability, but manageRow expects an HTMLElement. Use target.closest<HTMLElement>(...) and handle a possible null (e.g., early return) instead of asserting non-null.
    frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts:223
  • row.querySelector('select[name="sort_field"]')! is inferred as Element, but the code assigns .value. Prefer row.querySelector<HTMLSelectElement>(...) and handle the nullable case instead of asserting non-null.
    frontend/src/stimulus/controllers/dynamic/reporting/page.controller.ts:504
  • document.querySelector(selector)! is inferred as Element and asserts non-null, but the method uses hidden and iterates children. This breaks type-checked linting and the subsequent if (!input) guard becomes ineffective due to !. Prefer document.querySelector<HTMLElement>(selector) and early-return when it's null.
    frontend/src/stimulus/controllers/dynamic/admin/custom-fields.controller.ts:139
  • These querySelector(...)! calls are inferred as Element, but the code treats the results as HTMLInputElements (value, checked, attributes). Prefer dup.querySelector<HTMLInputElement>(...) / dup.querySelector<HTMLInputElement>(...) (nullable) and guard, rather than asserting non-null without typing.
    const count = this.customOptionRowTargets.length;
    const last = this.customOptionRowTargets[count - 1];
    const dup = last.cloneNode(true) as HTMLElement;

    const input = dup.querySelector('.custom-option-value input')!;

    input.setAttribute('name', `custom_field[custom_options_attributes][${count}][value]`);
    input.setAttribute('id', `custom_field_custom_options_attributes_${count}_value`);
    input.value = '';

    dup
      .querySelector('.custom-option-id')
      ?.remove();

    const defaultValueCheckbox = dup.querySelector('input[type="checkbox"]')!;
    const defaultValueHidden = dup.querySelector('input[type="hidden"]')!;

    defaultValueHidden.setAttribute('name', `custom_field[custom_options_attributes][${count}][default_value]`);
    defaultValueHidden.removeAttribute('id');
    defaultValueCheckbox.setAttribute('name', `custom_field[custom_options_attributes][${count}][default_value]`);
    defaultValueCheckbox.setAttribute('id', `custom_field_custom_options_attributes_${count}_default_value`);
    defaultValueCheckbox.checked = false;

frontend/src/app/shared/components/fields/edit/field-handler/hal-resource-edit-field-handler.ts:114

  • this.element.querySelector('.inline-edit--field')! asserts the element exists but the code immediately checks if (!target) and calls .focus(). With the current typing it is inferred as Element, so .focus() is not type-safe and the guard is contradictory. Prefer this.element.querySelector<HTMLElement>(...) without ! and keep the null guard.
  public focus(setClickOffset?:number) {
    const target = this.element.querySelector('.inline-edit--field')!;

    if (!target) {
      debugLog(`Tried to focus on ${this.fieldName}, but element does not (yet) exist.`);
      return;
    }

    // Focus the input
    target.focus();

    // Set selection state if input element
    if (setClickOffset && target.tagName === 'INPUT') {
      setPosition(target as HTMLInputElement, setClickOffset);
    }

Comment thread frontend/src/turbo/turbo-global-listeners.ts
Comment thread frontend/src/stimulus/controllers/dynamic/shares/bulk-selection.controller.ts Outdated
@myabc myabc force-pushed the fix/eslint-whitespace-errors branch from f904dba to d1383cf Compare May 18, 2026 22:28
Apply safe TypeScript ESLint cleanups and trailing whitespace fixes
across frontend files.

Keep DOM lookups typed and nullable when generic autocorrection would
otherwise assert through missing elements or erase intended guards.
@myabc myabc force-pushed the fix/eslint-whitespace-errors branch from d1383cf to f2ccc0f Compare May 19, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants