-
Notifications
You must be signed in to change notification settings - Fork 50
Upgrade to type-checked ESLint rules (demonstrates scope of PR 465) #1159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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]>
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:
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! 🙏 |
There was a problem hiding this 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".
languageOptions: { | ||
globals: { | ||
queueMicrotask: "readonly", | ||
parserOptions: { | ||
sourceType: "module", | ||
project: "./tsconfig.json", | ||
// projectService: true, | ||
tsconfigRootDir: import.meta.dirname, |
There was a problem hiding this comment.
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 👍 / 👎.
WalkthroughReplaced 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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.
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. Comment |
There was a problem hiding this 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 supersetsrecommendedTypeChecked
. 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 tsconfigRootDirVerified 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));
files: ["**/*.js", "*.mjs"], | ||
extends: [tseslint.configs.disableTypeChecked], | ||
}, |
There was a problem hiding this comment.
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.
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.
Summary
Changes
eslint.config.mjs
: Switch tostrictTypeChecked
,stylisticTypeChecked
,recommendedTypeChecked
@typescript-eslint/prefer-readonly
ruleTest Results
Running
pnpm lint
after this change reveals 2,304 errors including:@typescript-eslint/no-unsafe-assignment
- lots ofany
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 awaitContext
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