Skip to content

Fix UI lint errors failing static checks - #74402

Merged
pierrejeambrun merged 1 commit into
apache:mainfrom
Pushkal-Gupta:fix-ui-lint-prefer-logical-operator
Oct 7, 2026
Merged

pierrejeambrun merged 1 commit into
apache:mainfrom
Pushkal-Gupta:fix-ui-lint-prefer-logical-operator

Conversation

@Pushkal-Gupta

Copy link
Copy Markdown
Contributor

ts-compile-lint-ui currently fails on main, so every open PR inherits a red Static checks whatever it touches. Two ternaries trip unicorn/prefer-logical-operator-over-ternary:

src/hooks/useAdvancedSearch.ts:43:14       error  unicorn/prefer-logical-operator-over-ternary
src/queries/useRecentTaskStateCounts.tsx:54:22  error  unicorn/prefer-logical-operator-over-ternary

185 problems (2 errors, 183 warnings)

Both arrived on 2026-10-06, in #74289 and #69619.

useRecentTaskStateCounts.tsx

-    refetchInterval: hasUnfinishedRun ? refetchInterval : false,
+    refetchInterval: hasUnfinishedRun && refetchInterval,

Straightforward, and exactly the operator the rule derives: the consequent is not a boolean constant, the alternate is false, so it wants && with no negation.

useAdvancedSearch.ts — worth a look before approving

-      if (urlValues.includes(key)) {
-        return true;
-      }
-
-      return urlValues.includes(`-${key}`) ? false : undefined;
+      return urlValues.includes(key) || (!urlValues.includes(`-${key}`) && undefined);

This reads worse than what it replaces, and I would rather flag that than quietly ship it. Behaviour is unchanged across all three inputs:

includes(key) includes("-key") before after
true — true true
false true false false
false false undefined undefined

The readable fix does not survive the linter. Keeping the early-return if and rewriting only the ternary leaves unicorn/prefer-ternary complaining about the if above it, so the two rules push in opposite directions and the combined logical expression is what satisfies both.

If a maintainer would rather keep the original and silence the rule at these two sites, or reconsider the rule for this package, that seems a reasonable call and I am happy to redo it that way. The aim here is just to get main green.

Verification

  • pnpm eslint . across the UI: 0 errors (159 warnings, none new)
  • tsc --noEmit -p tsconfig.json: clean
  • Reproduced the original failure first by installing the declared
    eslint-plugin-unicorn@76.0.0; a stale local 73.0.0 does not flag either site,
    which is probably why these reached main

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

@boring-cyborg boring-cyborg Bot added the area:UI Related to UI/UX. For Frontend Developers. label Oct 7, 2026
@Pushkal-Gupta Pushkal-Gupta changed the title Fix UI lint erros failing static checks Fix UI lint errors failing static checks Oct 7, 2026

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks.

I'm fine with it for now, but I admit I find it hard to read too.

@pierrejeambrun
pierrejeambrun merged commit 7f653e6 into apache:main Oct 7, 2026
90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants