chore: fix ESLint suppressions and improve type safety#16
Open
dionmcm wants to merge 1 commit into
Open
Conversation
Remove the blanket no-unsafe-* rule suppressions from eslint.config.mjs for 8 source files, and fix the underlying type safety issues instead: - semantic-tokens.ts: Replace any-typed AST visitor with proper union types (VisitableNode) and typed AttributeNameNode parameter - server.ts: Type getConfiguration() results as unknown before narrowing - formatter.ts: Add explicit string types to regex callback parameters - parser/index.ts: Cast visitor.visit() return to ExpressionNode | null - extension.ts: Remove redundant type arguments from .get<string>() and .get<number>() calls, widen literal type for snomedVersion setting, add targeted no-unsafe-return suppression for LSP middleware boundary - embedded-core.ts: Replace non-null assertions with optional chaining Closes #15 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR removes broad ESLint suppressions around no-unsafe-* rules by tightening types and adding safer narrowing/casts at key boundaries (LSP config reads, AST traversal, and formatting callbacks), improving overall type safety without changing the underlying feature set.
Changes:
- Replace
any-heavy AST visitor usage in semantic token collection with explicit AST node union types andNodeTypeenum usage. - Treat
workspace.getConfiguration()results asunknownin server/client layers, then narrow/cast at explicit boundaries. - Remove the ESLint config override block that disabled unsafe rules for a list of files, keeping only targeted inline suppressions where appropriate.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ecl-lsp-server/src/server.ts | Narrows getConfiguration() results from unknown before use, reducing unsafe member access/assignment. |
| packages/ecl-core/src/semantic-tokens.ts | Replaces any visitor with a typed VisitableNode union and uses NodeType directly; tightens attribute-name node typing. |
| packages/ecl-core/src/parser/index.ts | Casts visitor.visit() to the expected ExpressionNode | null at the parse boundary. |
| packages/ecl-core/src/formatter/formatter.ts | Adds explicit string types to regex replace callback params to satisfy unsafe rule checks. |
| eslint.config.mjs | Removes the file-specific suppression block for unsafe TypeScript ESLint rules. |
| clients/vscode/src/extension.ts | Simplifies .get() calls via inference, adds a targeted no-unsafe-return suppression for LSP middleware boundary. |
| clients/vscode/src/embedded-core.ts | Replaces non-null assertions with optional chaining / nullish coalescing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Removes the blanket
no-unsafe-*ESLint rule suppressions for 8 source files and fixes the underlying type safety issues:any-typed AST visitor with a properVisitableNodeunion type and typedAttributeNameNodeparameter, removing bothno-explicit-anysuppressions and the redundantNTconstant (now uses theNodeTypeenum directly)getConfiguration()results asunknownbefore narrowing viaas Record<string, unknown>stringtypes to regex replace callback parametersvisitor.visit()return toExpressionNode | null<string>/<number>type arguments from.get()calls, widened literal type forsnomedVersionsetting, added targetedno-unsafe-returnsuppression at LSP middleware boundary!non-null assertions with optional chaining (?.)Net result: -15 lines, 2 remaining inline suppressions (both justified: LSP middleware
anyreturn, runtime null on typed AST nodes).Closes #15
Test plan
npm run compilepassesnpm run lintpasses (0 errors, 0 warnings)npm run format:checkpassesnpm testpasses (1867 tests across all packages)🤖 Generated with Claude Code