Fix auto-correctable eslint errors in frontend/#23256
Open
myabc wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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/HTMLInputElementassertions 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 asElementand!removes nullability, butmanageRowexpects anHTMLElement. Usetarget.closest<HTMLElement>(...)and handle a possiblenull(e.g., early return) instead of asserting non-null.
frontend/src/stimulus/controllers/dynamic/sort-by-config.controller.ts:223row.querySelector('select[name="sort_field"]')!is inferred asElement, but the code assigns.value. Preferrow.querySelector<HTMLSelectElement>(...)and handle the nullable case instead of asserting non-null.
frontend/src/stimulus/controllers/dynamic/reporting/page.controller.ts:504document.querySelector(selector)!is inferred asElementand asserts non-null, but the method useshiddenand iterateschildren. This breaks type-checked linting and the subsequentif (!input)guard becomes ineffective due to!. Preferdocument.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 asElement, but the code treats the results asHTMLInputElements (value,checked, attributes). Preferdup.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 checksif (!target)and calls.focus(). With the current typing it is inferred asElement, so.focus()is not type-safe and the guard is contradictory. Preferthis.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);
}
f904dba to
d1383cf
Compare
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.
d1383cf to
f2ccc0f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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