Skip to content

Conversation

jchris
Copy link
Contributor

@jchris jchris commented Sep 17, 2025

Summary

  • Upgrades ESLint configuration from basic strict/stylistic rules to type-checked rules
  • Demonstrates the massive scope of cleanup needed for stricter type checking
  • Exposes 2,304 lint violations that need to be addressed

Changes

  • eslint.config.mjs: Switch to strictTypeChecked, stylisticTypeChecked, recommendedTypeChecked
  • Added TypeScript project configuration for type-aware linting
  • Added @typescript-eslint/prefer-readonly rule

Test Results

Running pnpm lint after this change reveals 2,304 errors including:

  • @typescript-eslint/no-unsafe-assignment - lots of any type issues
  • @typescript-eslint/no-unsafe-member-access - unsafe property access
  • @typescript-eslint/prefer-nullish-coalescing - using || instead of ??
  • @typescript-eslint/prefer-readonly - class members that should be readonly
  • @typescript-eslint/require-await - async functions without await
  • Plus many more strict typing violations

Context

This PR demonstrates that PR #465 is essentially just the ESLint config upgrade plus the massive cleanup of all resulting violations. The "real" change is this config file - everything else in #465 is cleanup.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Upgraded linting configuration to use type-aware rules for TypeScript, improving static analysis and code consistency.
    • Refined ignore patterns and introduced targeted per-file overrides to streamline developer workflow and reduce false positives.
    • No user-facing changes; application behavior remains unchanged.

This change upgrades from basic strict/stylistic configs to type-checked
configs (strictTypeChecked, stylisticTypeChecked, recommendedTypeChecked).
The stricter type-checking rules expose 2,304 lint violations that need
to be addressed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@jchris jchris mentioned this pull request Sep 17, 2025
@jchris
Copy link
Contributor Author

jchris commented Sep 17, 2025

Note for potential contributors: This would actually be an excellent way for a new contributor to learn the Fireproof codebase!

Working through these 2,304 lint violations would require:

  • Reading and understanding code across the entire project
  • Learning the type system and architecture
  • Making systematic improvements to type safety
  • Getting familiar with the build tools and development workflow

Each fix is relatively small and focused, but collectively they'd give you deep familiarity with how Fireproof works internally. Plus you'd be making a real contribution to code quality and maintainability.

If anyone is interested in taking this on (either the whole thing or chunks of it), it would be very welcome! 🙏

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines 14 to +19
languageOptions: {
globals: {
queueMicrotask: "readonly",
parserOptions: {
sourceType: "module",
project: "./tsconfig.json",
// projectService: true,
tsconfigRootDir: import.meta.dirname,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Ensure all linted TS files are covered by project config

The new type‑checked config sets parserOptions.project: "./tsconfig.json", but that tsconfig only includes core, cloud, cli, dashboard, and tests. Directories like use-fireproof/ and smoke/npm/ still contain TypeScript files and are not ignored. Running pnpm lint against those files will now fail with Parsing error: File ... is not included in the project before any of the intended rule diagnostics are emitted. Consider adding a dedicated tsconfig.eslint.json that references every package or explicitly ignoring the out-of-project folders so lint can complete.

Useful? React with 👍 / 👎.

Copy link
Contributor

coderabbitai bot commented Sep 17, 2025

Walkthrough

Replaced ESLint base presets with TypeScript type-checked variants, updated language options to use parserOptions with project-based type info, revised ignore patterns, and added per-file overrides for JS and TS/TSX (including a new readonly rule for TS). Existing export default options remain unchanged.

Changes

Cohort / File(s) Change summary
ESLint config modernization
eslint.config.mjs
Switched to strictTypeChecked/stylisticTypeChecked/recommendedTypeChecked; set parserOptions (sourceType: module, project, tsconfigRootDir); adjusted ignores (added dist/**, coverage/, etc.; removed cache-related patterns); per-file overrides: JS uses disableTypeChecked, TS enforces @typescript-eslint/prefer-readonly; preserved export default opts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Upgrade to type-checked ESLint rules (demonstrates scope of PR 465)" directly describes the primary change (switching to type-checked ESLint rules) and adds brief contextual scope, matching the modifications in eslint.config.mjs and the PR objectives; it is concise, specific, and not noisy. The parenthetical note about PR 465 provides useful context without obscuring the main intent. Overall the title would be clear to a reviewer scanning the repository history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jchris/test-strict-eslint

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
eslint.config.mjs (4)

10-12: Avoid stacking both strictTypeChecked and recommendedTypeChecked (redundant).

strictTypeChecked already supersets recommendedTypeChecked. Keeping both is noisy and can make rule provenance unclear. Pick one (I’d keep strict + stylistic for maximal signal).

Apply this diff:

   ...tseslint.configs.strictTypeChecked,
   ...tseslint.configs.stylisticTypeChecked,
-  ...tseslint.configs.recommendedTypeChecked,

24-43: Consolidate ignores; remove duplicates and cover nested dirs.

**/dist/ + dist/** and **/scripts/ + scripts/ are redundant; coverage/ only ignores at repo root.

Apply this diff:

   ignores: [
     "babel.config.cjs",
     "prettier.config.js",
     "jest.config.js",
     "setup.*.js",
     "to-esm.js",
     "vitest.*.ts",
     "**/.esm-cache/**",
-    "**/dist/",
-    "dist/**",
+    "**/dist/**",
     "**/pubdir/",
     "**/node_modules/",
-    "**/scripts/",
+    "**/scripts/**",
     "**/examples/",
-    "scripts/",
-    "coverage/",
+    "**/coverage/**",
     "smoke/react/",
     "src/missingTypes/lib.deno.d.ts",
   ],

70-75: Set prefer‑readonly to warn (initially) or scope it, to avoid noisy churn.

This rule can explode changes across params/props; consider onboarding as warn first, or limit to src/**.

Example diff (warn):

   files: ["**/*.ts", "**/*.tsx"],
   rules: {
-    "@typescript-eslint/prefer-readonly": "error",
+    "@typescript-eslint/prefer-readonly": "warn",
   },

15-20: Prefer projectService and compute __dirname for tsconfigRootDir

Verified multiple tsconfig.json files across the repo (monorepo) and a nested .mjs ESLint file (smoke/react/eslint.config.mjs). Change eslint.config.mjs (lines ~15–20) as follows:

  parserOptions: {
    sourceType: "module",
-    project: "./tsconfig.json",
-    //        projectService: true,
-    tsconfigRootDir: import.meta.dirname,
+    projectService: true,
+    tsconfigRootDir: __dirname,
  },

Add once at top of the file:

import { fileURLToPath } from "node:url";
import { dirname } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55fcdff and 7cc49a2.

📒 Files selected for processing (1)
  • eslint.config.mjs (2 hunks)

Comment on lines +45 to +47
files: ["**/*.js", "*.mjs"],
extends: [tseslint.configs.disableTypeChecked],
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

🧩 Analysis chain

JS override misses nested .mjs and all .cjs files.

This leaves type‑checked rules active in those files. Expand globs.

Apply this diff:

-  files: ["**/*.js", "*.mjs"],
+  files: ["**/*.js", "**/*.mjs", "**/*.cjs"],

Quick check:


🏁 Script executed:

#!/bin/bash
echo "Any nested .mjs/.cjs files not matched by '*.mjs'?"; fd -t f -e mjs -e cjs | sed '1,1d' || true

Length of output: 113


Expand override globs to include nested .mjs and all .cjs files

"*.mjs" only matches top-level .mjs and misses nested .mjs/.cjs — fd lists smoke/npm/patch-package.json.mjs and smoke/react/eslint.config.mjs.

File: eslint.config.mjs (lines 45-47)

-  files: ["**/*.js", "*.mjs"],
+  files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
files: ["**/*.js", "*.mjs"],
extends: [tseslint.configs.disableTypeChecked],
},
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
extends: [tseslint.configs.disableTypeChecked],
},
🤖 Prompt for AI Agents
In eslint.config.mjs around lines 45 to 47, the override's files globs only
include "**/*.js" and "*.mjs", which misses nested .mjs and any .cjs files;
update the files array to use recursive globs such as "**/*.mjs" and "**/*.cjs"
(and keep "**/*.js") so nested module files and CommonJS files are covered,
e.g., replace "*.mjs" with "**/*.mjs" and add "**/*.cjs" to the list.

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.

1 participant