Repository navigation
chore(design): fix ESLint warnings - #584
Conversation
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]>
Reviewer's GuideAPINarrow the public
ImplementationReplace unsafe shared-state assertions with guards so detached select and multi-select components do not recreate incomplete state entries.
Remove redundant state spreads in the collapsible component, type the Ace editor and lifecycle updates, and retain the plain-text fallback without logging.
ConfigurationMake the design package lint command fail when ESLint reports any warnings.
Add a patch changeset for the design package describing the lint fixes and their typing and state-guard changes.
TestsUpdate code-editor tests for the optional editor type and replace form-control test non-null assertions with checked shadow-DOM lookups.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit dac0689 #583 chore(design): fix ESLint warnings · 4 of 4 met
|
There was a problem hiding this comment.
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
# 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]>
Documentation build overview
49 files changed ·
|
|
Thanks! Merged
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? |
Summary
Fixes the ESLint warnings of
@elixir-cloud/design. The issue lists 10 of them. Since then, three more appeared: two inselect.tsand one inevents/ecc-button-clicked.ts. This PR fixes those too, so the package lints clean. There are no refactors and no dependency changes.disconnectedCallback) no longer re-creates a partial entry withoutonSelect.connectedCallbackrebuilds the full entry when it is attached again.isOpen, so the entry is now written directly. Behaviour is identical.anyin the code editor:editoris typedAce.Editor | undefined, using ace-builds' own types. ace-builds is already a runtime dependency.window.aceis typed astypeof import("ace-builds"), andupdated()takesPropertyValues<this>.anyin the Ace theme: ace-builds doesn't type its AMDdefineorace/lib/dom, soace-theme.tsdeclares 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 inapps/documentation/pages/docs/design/components/pagination.mdxand as dispatched by pagination.lintscript now runs with--max-warnings 0, the optional item of the issue, so new warnings fail CI.Type-level notes for the reviewer:
editor(fromany) and theecc-button-clickeddetail (fromRecord<string, any>) are narrower now. TypeScript consumers that useeditorwithout a check, or read other keys from the detail, get type errors. Runtime behaviour is unchanged.CustomEvent, so they are unaffected. The package's owncode.test.tsnow usesel.editor?..Closes #583
Verification
npx eslint . --max-warnings 0inpackages/ecc-utils-design: no warnings (13 ondev).npm run lint(turbo, includes the builds andtscof 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.Declined review findings
windowcast incode.tswith theglobalThiscast inace-theme.ts: this would need a new globalWindowdeclaration, which is more than a minimal lint fix.ace-theme.tsusesglobalThisfor SSR (existing comment).setModefallback: Ace'ssetModewith 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:
Enhancements:
Build:
Tests:
Chores: