refactor: improve type safety with proper type guards and add ESLint#6
Merged
refactor: improve type safety with proper type guards and add ESLint#6
Conversation
- Add eslint-for-ai configuration with recommended rules - Replace type assertions with proper type guard functions (isBaseQuery, isQueryValue) - Refactor compileDatadogQuery to use internal helper for cleaner separation - Fix return type from 'any' to 'unknown' in queryBuilder - Update test types to use 'satisfies' instead of explicit annotations - Add lint and lint:fix npm scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: fbd411c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR improves type safety by replacing type assertions with proper type guard functions and adds ESLint configuration for better code quality enforcement in AI-assisted development.
Key changes:
- Introduced type guard functions (
isBaseQuery(),isQueryValue(),isOperator()) to replace unsafe type assertions - Extracted query compilation logic into
compileQueryInternal()helper for better separation of concerns - Changed
queryBuilderreturn type fromanytounknownfor stricter type checking
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.ts | Core refactoring with type guards replacing type assertions, new internal compilation function, and improved type safety with unknown return type |
| src/index.test-d.ts | Updated type tests to use satisfies operator instead of explicit type annotations for better type inference |
| package.json | Added ESLint packages and configuration, including eslint-for-ai, TypeScript parser, and resolver |
| eslint.config.js | New ESLint configuration file using eslint-for-ai recommended rules |
| bun.lock | Lock file updates for new ESLint-related dependencies |
| .changeset/smooth-lions-dance.md | Changeset documenting the patch-level changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merged
eli0shin
pushed a commit
that referenced
this pull request
Dec 26, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## barkql@0.1.2 ### Patch Changes - [#6](#6) [`2850afe`](2850afe) Thanks [@eli0shin](https://github.com/eli0shin)! - Refactor to use type guards instead of type assertions for improved type safety, and add ESLint configuration with TypeScript resolver support. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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
Changes
ESLint Configuration:
Type Safety Improvements:
isBaseQuery(),isQueryValue(), andisOperator()anytounknownfor better type safetyCode Refactoring:
compileQueryInternal()helper functioncompileDatadogQuery()to use the new internal helpersatisfiesinstead of explicit type annotationsTest plan
🤖 Generated with Claude Code