Skip to content

chore(design): fix ESLint warnings - #584

Merged
uniqueg merged 5 commits into
devfrom
chore/583-eslint-warnings
Nov 16, 2026
Merged

uniqueg merged 5 commits into
devfrom
chore/583-eslint-warnings

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes the ESLint warnings of @elixir-cloud/design. The issue lists 10 of them. Since then, three more appeared: two in select.ts and one in events/ecc-button-clicked.ts. This PR fixes those too, so the package lints clean. There are no refactors and no dependency changes.

  • Non-null assertions (select, multi-select, collapsible):
    • In select and multi-select, the state map lookups are now explicit checks. The only runtime difference: a component that is already detached (its state entry deleted in disconnectedCallback) no longer re-creates a partial entry without onSelect. connectedCallback rebuilds the full entry when it is attached again.
    • In collapsible, the map value has the single field isOpen, so the entry is now written directly. Behaviour is identical.
  • any in the code editor: editor is typed Ace.Editor | undefined, using ace-builds' own types. ace-builds is already a runtime dependency. window.ace is typed as typeof import("ace-builds"), and updated() takes PropertyValues<this>.
  • any in the Ace theme: ace-builds doesn't type its AMD define or ace/lib/dom, so ace-theme.ts declares minimal local types for the parts it uses.
  • console.error: removed from the language fallback, which still falls back to text mode. Ace loads modes asynchronously, so this catch hardly ever runs.
  • ecc-button-clicked: the detail is typed { variant: string }, as documented in apps/documentation/pages/docs/design/components/pagination.mdx and as dispatched by pagination.
  • Lint script: the package's lint script now runs with --max-warnings 0, the optional item of the issue, so new warnings fail CI.
  • Changeset: a patch changeset is added.

Type-level notes for the reviewer:

  • editor (from any) and the ecc-button-clicked detail (from Record<string, any>) are narrower now. TypeScript consumers that use editor without a check, or read other keys from the detail, get type errors. Runtime behaviour is unchanged.
  • The in-repo clients annotate their handlers with plain CustomEvent, so they are unaffected. The package's own code.test.ts now uses el.editor?..
  • I chose a patch bump in the alpha series. Please say if you prefer minor.

Closes #583

Verification

  • npx eslint . --max-warnings 0 in packages/ecc-utils-design: no warnings (13 on dev).
  • npm run lint (turbo, includes the builds and tsc of the design package): 21/21 tasks successful.
  • npm run test, all packages: every test passed in Chromium and Firefox (design 19/18+1 skipped, tes 51, service-registry 46, cloud-registry 45, wes 7). WebKit isn't installed on the local machine, so it didn't run here; CI runs it.
  • CI: all checks green (Lint, Test on Node 22 and 24 incl. WebKit, PR title, Conflict markers, CodeQL, Read the Docs, CI passed).

Declined review findings

  • Unify the window cast in code.ts with the globalThis cast in ace-theme.ts: this would need a new global Window declaration, which is more than a minimal lint fix. ace-theme.ts uses globalThis for SSR (existing comment).
  • Tests for the detached select/multi-select path: the state map is module-private, so a test would need test hooks in the component. The guard only skips a write that re-created a broken entry.
  • Test for the setMode fallback: Ace's setMode with a mode name loads asynchronously and doesn't throw for unknown modes, so the catch can't be triggered reliably.

🤖 Generated with Claude Code

Summary by Sourcery

Clean the design package's ESLint warnings by strengthening types and state handling, removing unsafe assertions, and enforcing warning-free linting.

Bug Fixes:

  • Prevent detached select and multi-select components from recreating incomplete shared state entries.
  • Remove the code editor's error logging while preserving its text-mode fallback.

Enhancements:

  • Replace unsafe assertions with explicit state and DOM checks across design components and tests.
  • Use Ace and documented event-detail types instead of broad any-based types.
  • Type Ace theme integration without untyped values.

Build:

  • Make the design package lint command fail when any ESLint warnings are present.

Tests:

  • Update code editor tests for the optional editor type and improve shadow DOM query validation.

Chores:

  • Add a patch changeset for the design package.

uniqueg and others added 2 commits November 16, 2026 04:35
Replace non-null assertions in select, multi-select and collapsible
with explicit checks, type the code editor and its Ace theme with
Ace's types instead of `any`, type the `ecc-button-clicked` detail as
documented, and drop the `console.error` in the language fallback.
Lint of the design package now runs with `--max-warnings 0`.

Closes #583

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Write the collapsible state without spreading the old entry (its only
field is set anyway), access the editor optionally in the code editor
tests now that it is typed, and describe the guards in the changeset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg self-assigned this Nov 16, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

API

Narrow the public ecc-button-clicked event detail to the documented { variant: string } shape.

  • packages/ecc-utils-design/src/events/ecc-button-clicked.ts L1

Implementation

Replace unsafe shared-state assertions with guards so detached select and multi-select components do not recreate incomplete state entries.

  • packages/ecc-utils-design/src/components/multi-select/multi-select.ts L86-92, L125-128
  • packages/ecc-utils-design/src/components/select/select.ts L74-80, L114-117

Remove redundant state spreads in the collapsible component, type the Ace editor and lifecycle updates, and retain the plain-text fallback without logging.

  • packages/ecc-utils-design/src/components/code/ace-theme.ts L123-134, L140
  • packages/ecc-utils-design/src/components/code/code.ts L683-700 (+5 small edits)
  • packages/ecc-utils-design/src/components/collapsible/collapsible.ts L50 (removed lines), L72 (removed lines)

Configuration

Make the design package lint command fail when ESLint reports any warnings.

  • packages/ecc-utils-design/package.json L53

Add a patch changeset for the design package describing the lint fixes and their typing and state-guard changes.

  • .changeset/design-eslint-warnings.md L1-5

Tests

Update code-editor tests for the optional editor type and replace form-control test non-null assertions with checked shadow-DOM lookups.

  • packages/ecc-utils-design/src/components/code/code.test.ts L23-25, L32-34
  • packages/ecc-utils-design/src/form-controls.test.ts L29-38, L192-198 (+8 small edits)
  • packages/ecc-utils-design/src/utils/problem-details.test.ts L334

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.59184% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.57%. Comparing base (566471a) to head (dac0689).

Files with missing lines Patch % Lines
...kages/ecc-utils-design/src/components/code/code.ts 77.77% 4 Missing ⚠️
...design/src/components/multi-select/multi-select.ts 66.66% 3 Missing ⚠️
...s/ecc-utils-design/src/components/select/select.ts 66.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #584      +/-   ##
==========================================
+ Coverage   74.38%   74.57%   +0.19%     
==========================================
  Files          63       63              
  Lines       16792    16815      +23     
  Branches      922      927       +5     
==========================================
+ Hits        12490    12540      +50     
+ Misses       4286     4265      -21     
+ Partials       16       10       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@uniqueg
uniqueg marked this pull request as ready for review November 16, 2026 04:11
@uniqueg
uniqueg requested a review from anuragxxd as a code owner November 16, 2026 04:11
@sourcery-ai

sourcery-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit dac0689

#583 chore(design): fix ESLint warnings · 4 of 4 met

# Requirement Status Notes
1 Replace the non-null assertions with explicit checks or guarded element queries. ✅ Met Select and multi-select guard shared-state lookups, collapsible writes its single-field state directly, and the test queries use a helper that throws when an element is missing.
2 Replace the code editor and Ace theme any types with proper types, using Ace's types where available. ✅ Met The editor is typed as Ace.Editor | undefined; the theme declares minimal local types for the AMD APIs that ace-builds does not type.
3 Remove the console statement or replace it with an event or error reported by the component. ✅ Met The catch no longer logs and still falls back to text mode.
4 Lint the design package without warnings, optionally failing on new warnings. ✅ Met The package lint script uses --max-warnings 0; the PR reports that lint completed without warnings. It also addresses the additional select and event-type warnings.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/ecc-utils-design/src/components/code/code.ts" line_range="633" />
<code_context>
   @property({ type: Boolean }) disabled = false;

-  @state() editor: any;
+  @state() editor: Ace.Editor | undefined;

   firstUpdated() {
</code_context>
<issue_to_address>
**Editor type breaks consumers**

When a TypeScript consumer accesses `editor` without checking it or uses the package without installing `@types/ace`, `EccUtilsDesignCode.editor` is declared as `Ace.Editor | undefined`, so unchecked accesses fail type-checking and consumers without `@types/ace` cannot resolve the emitted declaration.

Keep the public `editor` declaration as `any` rather than exposing `Ace.Editor | undefined`.

Also at `packages/ecc-utils-design/src/components/code/code.ts:3`.
</issue_to_address>

### Comment 2
<location path="packages/ecc-utils-design/src/components/code/code.ts" line_range="719" />
<code_context>
-        `Failed to set mode for ${language}, falling back to text mode`,
-        error
-      );
+    } catch {
+      // Unknown mode: fall back to plain text
       this.editor.session.setMode("ace/mode/text");
</code_context>
<issue_to_address>
**Mode failures go unreported**

When ace throws while applying a requested language mode, `setEditorLanguage` catches the mode-setting exception and falls back to text without reporting it, so users lose syntax highlighting with no diagnostic and operators cannot distinguish a failure from an intentional text-mode choice.

Log or otherwise report the caught exception before falling back to text.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: packages/ecc-utils-design/src/components/code/code.ts:633, packages/ecc-utils-design/src/components/code/code.ts:719


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@uniqueg uniqueg mentioned this pull request Nov 16, 2026
8 tasks done

@anuragxxd anuragxxd 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.

LGTM, thanks. Needs a dev merge: small conflict in multi-select.ts with #576's invalid block (keep both).

uniqueg and others added 2 commits November 16, 2026 21:12
# Conflicts:
#	packages/ecc-utils-design/src/components/multi-select/multi-select.ts
#	packages/ecc-utils-design/src/components/select/select.ts
The tests that came in with #576 use non-null assertions, which this
branch's `--max-warnings 0` lint rejects. Query shadow DOM elements
through a helper that throws when an element is missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@read-the-docs-community

read-the-docs-community Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

@uniqueg

uniqueg commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Thanks! Merged dev into the branch:

CI is green on dac0689: Lint, Test on Node 22 and 24, CodeQL, Codecov, Read the Docs and Sourcery all pass. Could you take another look?

@uniqueg
uniqueg requested a review from anuragxxd November 16, 2026 20:27
@uniqueg
uniqueg merged commit 47fd42d into dev Nov 16, 2026
19 checks passed
@uniqueg
uniqueg deleted the chore/583-eslint-warnings branch November 16, 2026 21:55
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.

chore(design): fix ESLint warnings

2 participants