better ts lint
@jchris if you want help here is something!
It's a lot of editing, but it should not be hard. pls do not use any casts or ignore comments. If something is not clear how to resolve -> ask.
Summary by CodeRabbit
Release Notes
Overview
This release includes multiple improvements and refinements across the Fireproof codebase, focusing on type safety, error handling, and code clarity.
Key Changes
-
Type Safety Enhancements
- Simplified type definitions in multiple modules
- Removed unnecessary type assertions
- Enhanced type checking for generic parameters
-
Configuration Updates
- Updated TypeScript configuration to exclude
node_modules - Refined ESLint rules to focus on type-checked configurations
- Added new development dependencies, including TypeScript type definitions for
semver
- Updated TypeScript configuration to exclude
-
Code Refinement
- Improved error handling across various modules
- Removed optional chaining in favor of direct property access
- Streamlined function signatures and return types
-
Testing
- Updated test configurations to reflect direct property access
- Improved test case syntax and consistency
Development Dependencies
- Added TypeScript type definitions for
semver
Compatibility
- Minor adjustments to support broader type compatibility
- Maintained existing functionality across modules
Walkthrough
This pull request introduces a comprehensive set of type refinements, code simplifications, and configuration updates across the Fireproof project. The changes primarily focus on enhancing type safety, removing unnecessary type assertions, and streamlining type definitions. Key modifications include updating ESLint configurations, adjusting TypeScript configurations, and making subtle changes to type handling in various source and test files. The modifications aim to improve code clarity, reduce potential runtime errors, and leverage TypeScript's type inference capabilities more effectively.
Changes
| File | Change Summary |
|---|---|
eslint.config.mjs |
Updated ESLint configuration with type-checked configurations, expanded ignore patterns, and new type-checking rules. |
src/blockstore/* |
Simplified type definitions, removed generic type parameters, modified promise handling, and adjusted method signatures. |
src/crdt.ts, src/ledger.ts |
Adjusted method return types and callback handling. |
src/runtime/* |
Refined type definitions for database and file system interactions, updated property visibility, and modified error handling. |
tests/* |
Removed type assertions, simplified type handling in test cases, and updated property access patterns. |
tsconfig.json |
Added exclude patterns, updated include patterns, and removed ts-node configuration. |
package.json |
Added @types/semver type definitions. |
| Various config files | Updated import statements, added type assertions for plugins, and modified file extensions from .ts to .js. |
.gitignore |
Added entry to ignore .esm-cache directory. |
.prettierignore |
Added entry to ignore files in .esm-cache directory. |
publish-package.ts |
Improved error handling and logic for environment variable checks. |
setup.indexdb.ts |
Added return type annotation for a function. |
version-copy-package.ts |
Introduced a new interface for package JSON structure and refined function signatures. |
vitest.*.config.ts |
Updated import statements and type assertions for plugins. |
Sequence Diagram
sequenceDiagram
participant Developer
participant TypeScript
participant ESLint
participant Project
Developer->>TypeScript: Modify type definitions
TypeScript->>Project: Apply stricter type checking
Project->>ESLint: Enforce new type rules
ESLint->>Developer: Provide type-related feedback
Developer->>Project: Refine code based on feedback
This diagram illustrates the iterative process of type refinement, where developers modify type definitions, TypeScript applies stricter checking, ESLint enforces rules, and developers further refine the code based on the feedback.
📜 Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 0ee506c01ed0997d84cf5cef813818a30e81fb06 and ed5d19d0f697297a9a81e0ce7e438947feccbd04.
📒 Files selected for processing (1)
.gitignore(1 hunks)
🔇 Additional comments (1)
.gitignore (1)
2-2: LGTM! Good practice to ignore ESM cache directories.The addition of
**/.esm-cache/**is appropriate as these directories contain temporary build artifacts from ES module processing that should not be version controlled.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
I've created a demonstration PR that shows the scope of this change: #1159
That PR contains only the eslint.config.mjs changes from this PR, and running pnpm lint reveals 2,304 lint errors. This confirms that this PR (#465) is essentially:
- The core change: Upgrading ESLint to type-checked rules (in
eslint.config.mjs) - The massive cleanup: Fixing all 2,304+ resulting lint violations across 39 files
So yes, eslint.config.mjs is really the only "change" - everything else is cleanup to handle the new stricter linting rules. The scope is enormous but it's all automated fixes for type safety violations.
See #1159 for the isolated config change and full error breakdown.