Skip to content

Conversation

@henrikmv
Copy link
Contributor

@henrikmv henrikmv commented Sep 18, 2025

DHIS2-16607

This pull changes the ESLint Max Length rule from warning to error. The main goal is to resolve existing ESLint max-length issues without introducing any changes to functionality.

ESLint configuration updates:

  • Increased the maximum line length to 125 characters.
  • Changed the rule severity from warning to error in both .eslintrc and packages/rules-engine/.eslintrc.

Challenges

  • Breaking long strings in i18n proved difficult without affecting the .pot file or introducing unwanted whitespace.
  • This was addressed by splitting strings into multiple i18n fragments where natural.
  • For strings where this was not feasible, eslint-disable comments were used to ignore max-length violations.

Other important changes

  • Concatenating strings in i18n (e.g. i18n.t('string1' + 'string2')) prevents them from appearing in the .pot file.
  • These strings have been improved, by removing the +, which explains the new entries in the .pot file.

henrikmv and others added 2 commits September 18, 2025 15:44
…o 125 characters (#4379)

* Change ESLint max-len rule from warning to error and increase length to 125

- Updated main .eslintrc: changed severity from 1 to 2 and length from 120 to 125
- Updated packages/rules-engine/.eslintrc: changed severity from 1 to 2 and length from 120 to 125
- Fixed all max-len violations in rules-engine package:
  - Fixed import statement in rulesEffectsProcessor.ts
  - Fixed multiple long lines in VariableService.ts by breaking them appropriately

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in multiple files

- Fixed import statements in trackerCapture.epics.ts and trackerCapture.reducerDescriptions.ts
- Fixed function signatures in IconButton components and validator files
- Fixed SVG attributes and paths in PreviewImage and DropdownChevron components
- Reduced max-len errors from 571 to 559

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in validator and utility files

- Fixed function signatures in phone, number, email, and integerZeroOrPositive validators
- Fixed long regex pattern in email validator
- Fixed function expressions in batchActionUtils

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in utility and component files

- Fixed import statement in currentSelections.reducerDescription.ts
- Fixed function signature in pipe.ts utility
- Fixed string literal in StorageController.ts
- Fixed array declaration in isCalendarSupported.ts
- Fixed static method signature in Pagination component
- Fixed hook return statement in useCurrentProgramInfo.ts

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in hooks and HOC components

- Fixed function signature in useCurrentTrackedEntityTypeId hook
- Fixed function signature in useAvailableProgramStages hook
- Fixed function signatures in withLoadingIndicator HOC
- Fixed HOC composition in TextRangeField component
- Fixed function signatures and connect call in withStateBoundLoadingIndicator

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in storage adapter comments

- Fixed long comment blocks in DomLocalStorageAdapter.ts
- Fixed long comment blocks in IndexedDBAdapter.ts
- Broke comments across multiple lines to fit within 125 character limit

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in date utils and UI components

- Fixed long comment in date.utils.ts
- Fixed long destructuring assignment in SingleSelectionBoxes component
- Fixed long calendar type union in Date.types.ts
- Fixed long error props object in DateTimeTime component

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in UI components and metadata builders

- Fixed long className assignment in ShrinkLabel component
- Fixed long destructuring and conditional in CoordinateField component
- Fixed long className and callback assignments in AgeField component
- Fixed long function signature in commonPrerequisitesGetter

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations using find_and_edit across multiple files

- Fixed long function signatures in converters and validators
- Fixed long destructuring assignments in components and epics
- Broke long parameter lists across multiple lines
- Fixed long type definitions and callback functions

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in ternary operators across 29 files

- Used find_and_edit to systematically fix long ternary expressions
- Broke long conditional statements across multiple lines
- Fixed violations in components, hooks, epics, and utility files
- Maintained code readability while adhering to 125 character limit

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations using systematic find_and_edit approach

- Fixed logical AND expressions across 90 files
- Fixed logical OR expressions across 21 files
- Fixed long function calls and parentheses expressions across 85 files
- Broke long expressions across multiple lines while maintaining readability
- Total of 196 files successfully edited with automated approach

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violation in AppLoader init.ts

- Break long string literal across multiple lines using concatenation
- Line 185 reduced from 128 to under 125 characters

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in 161 files (126-135 character lines)

- Break long lines across multiple lines while maintaining readability
- Target lines that were slightly over the 125 character limit
- Follow existing code formatting patterns and indentation
- Continue systematic approach to fix remaining max-len violations

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in 79 files (136-145 character lines)

- Break long lines across multiple lines while maintaining readability
- Target lines that were 136-145 characters over the 125 character limit
- Follow existing code formatting patterns and indentation
- Continue systematic approach to fix remaining max-len violations

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in 52 files (146-160 character lines)

- Break long lines across multiple lines while maintaining readability
- Target lines that were 146-160 characters over the 125 character limit
- Follow existing code formatting patterns and indentation
- Continue systematic approach to fix remaining max-len violations

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in 33 files (161-200 character lines)

- Break long lines across multiple lines while maintaining readability
- Target lines that were 161-200 characters over the 125 character limit
- Follow existing code formatting patterns and indentation
- Continue systematic approach to fix remaining max-len violations

Co-Authored-By: [email protected] <[email protected]>

* Fix max-len violations in 16 files (200+ character lines)

- Break extremely long lines across multiple lines while maintaining readability
- Target lines that were over 200 characters, the longest violations
- Follow existing code formatting patterns and indentation
- Complete systematic approach to fix all max-len violations

Co-Authored-By: [email protected] <[email protected]>

* Fix TypeScript compilation errors introduced by automated line breaking

- Correct import statements that were incorrectly split with string concatenation
- Fix JSX syntax error in MultiSelectionCheckedIcon component
- Restore proper import paths for all affected files
- Ensure TypeScript compiler can process files for linter to run

Co-Authored-By: [email protected] <[email protected]>

* Remove trailing spaces from all source files

- Fix no-trailing-spaces ESLint violations across 361 files
- Clean up whitespace formatting to meet linting standards
- Final cleanup before PR creation

Co-Authored-By: [email protected] <[email protected]>

* Fix additional max-len violations and formatting issues

Co-Authored-By: [email protected] <[email protected]>

* Fix long import statements to resolve max-len violations

Co-Authored-By: [email protected] <[email protected]>

* Fix parsing errors in import statements by removing string concatenation

Co-Authored-By: [email protected] <[email protected]>

* Fix parsing error and some max-len violations in icon components

Co-Authored-By: [email protected] <[email protected]>

* feat: temp

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: henrikmv <[email protected]>
Co-authored-by: henrikmv <[email protected]>
@henrikmv henrikmv requested a review from a team as a code owner September 18, 2025 13:47
@henrikmv henrikmv marked this pull request as draft September 18, 2025 13:47
@henrikmv henrikmv marked this pull request as ready for review September 19, 2025 13:36
@github-actions
Copy link

github-actions bot commented Sep 19, 2025

@henrikmv henrikmv marked this pull request as draft September 23, 2025 11:55
@henrikmv henrikmv marked this pull request as ready for review September 24, 2025 07:31
@henrikmv henrikmv added testing and removed testing labels Sep 24, 2025
@henrikmv henrikmv requested a review from Copilot September 25, 2025 10:50
Copy link

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 pull request updates the ESLint configuration to enforce stricter line length rules, changing from warnings to errors and increasing the maximum line length to 125 characters. The changes focus on resolving existing ESLint max-length violations across the codebase without affecting functionality.

Key changes include:

  • Updated ESLint configuration to enforce 125-character line length as errors instead of warnings
  • Split long import statements, function parameters, and strings to comply with new rules
  • Added strategic eslint-disable comments for cases where line breaks would affect i18n functionality
  • Improved i18n string concatenation to ensure proper extraction to .pot files

Reviewed Changes

Copilot reviewed 300 out of 405 changed files in this pull request and generated 3 comments.

File Description
Multiple component files Split long import statements and function parameters across multiple lines
Various i18n usage files Split concatenated i18n strings or added eslint-disable comments for untranslatable content
Configuration and helper files Reformatted long object properties, API field specifications, and query parameters

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@henrikmv henrikmv added testing and removed testing labels Oct 16, 2025
Copy link
Contributor

@simonadomnisoru simonadomnisoru left a comment

Choose a reason for hiding this comment

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

Overall is looks good @henrikmv 👏 ! I only made a few small comments that I hope you can have a look at

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
85 New issues
85 New Code Smells (required ≤ 0)
3 New Critical Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@henrikmv henrikmv removed the testing label Oct 21, 2025
@henrikmv henrikmv merged commit 31e209d into master Oct 21, 2025
39 of 41 checks passed
@henrikmv henrikmv deleted the hv/task/DHIS2-16607_EslintMaxLengthRule branch October 21, 2025 12:25
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 104.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants