Add eslint precommit#96
Conversation
|
Warning Review limit reached
More reviews will be available in 53 minutes and 25 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds ESLint flat configuration, husky pre-commit hook with lint-staged, and a CI lint job. Applies the resulting single-quote style rule across all source files. ChangesESLint Setup and Single-Quote Style Enforcement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/commands/export.js (1)
69-80: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winEscape embedded quotes before writing CSV.
item.commandcan legitimately contain". Right now Line 75 wraps the field in quotes but never doubles embedded quotes, so commands likegit commit -m "msg"produce malformed CSV that Excel/Sheets and other parsers won't round-trip correctly.Proposed fix
function exportAsCSV(data, total) { try { + const escapeCsv = (value) => `"${String(value).replace(/"/g, '""')}"`; let csvContent = 'category,command,date\n'; for (const [category, commands] of Object.entries(data)) { for (const item of commands) { const date = new Date(item.time).toLocaleDateString(); - csvContent += `${category},"${item.command}",${date}\n`; + csvContent += [ + escapeCsv(category), + escapeCsv(item.command), + escapeCsv(date) + ].join(',') + '\n'; } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/commands/export.js` around lines 69 - 80, The CSV export in export.js writes item.command directly inside quoted fields, so embedded double quotes can break the output. Update the CSV generation inside the loop that builds csvContent to escape/double any quotes in item.command before concatenating it, keeping the rest of the export flow and filePath/writeFileSync logic unchanged.
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
14-31: 🩺 Stability & Availability | 🔵 TrivialBroaden CI beyond lint-only coverage.
npm run lintplus the current--versionsmoke test still won't execute subcommand handlers, so regressions like thesrc/commands/clear.jsreplacement can merge unnoticed. Adding one lightweight invocation per command module here would catch that class of breakage much earlier.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/ci.yml around lines 14 - 31, The CI workflow is only running linting, so it can miss regressions in command handlers like the recent clear command change. Update the lint job in the workflow to add at least one lightweight execution for each command module, alongside the existing npm run lint step, so the handlers are actually exercised during CI. Use the existing command entry points and module names such as clear and the other subcommand modules to wire in these smoke invocations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/commands/clear.js`:
- Around line 1-30: The module currently exports ESLint config instead of the
clear command, so restore the command implementation in clearCommand and keep
this file exporting that handler again; move the ESLint array into
eslint.config.js (or equivalent config entry) so bin/tracker.js can still import
clearCommand and invoke tracker clear without runtime failure. Locate the
affected export by the clearCommand symbol and replace the config export with
the original command logic.
In `@src/commands/init.js`:
- Around line 148-149: The fallback .gitignore guidance in the init flow is
incomplete because it only mentions .tracker/ while the init command also treats
tracker-export.json and tracker-export.csv as local-only artifacts. Update the
warning message in the init command’s fallback logging so it tells users to
ignore all three paths, keeping the guidance consistent with the rest of the
export handling in init.js and preventing accidental commits of exported
history.
- Around line 128-135: The init flow is appending duplicate .gitignore content
because `entriesToAdd` is already written in the `init.js` logic and then
`trackerEntry` is appended again immediately after. Remove the second
`fs.appendFileSync(gitignorePath, trackerEntry)` in this block so the
`entriesToAdd` write is the only .gitignore update, keeping the existing log
messages tied to the single append.
In `@src/commands/search.js`:
- Around line 79-81: The search highlighting in the command matching flow builds
a RegExp directly from user input, which can break on special characters and
produce incorrect matches. Update the logic in the search command path around
the item.command replace call to escape the searchTerm before passing it to new
RegExp, keeping isValidQuery as-is and ensuring the highlighted output still
uses the escaped pattern safely.
In `@src/commands/stats.js`:
- Around line 52-71: The package-managers category key is inconsistent across
statsCommand and the shared category contract, so the icon lookup falls back to
the default. Update the icons map in statsCommand to use the same lowercase key
as src/utils/validator.js and src/commands/list.js (the packagemanagers symbol)
so the category resolves to the intended icon instead of others. Use the
existing statsCommand icons object as the place to align the key name.
---
Outside diff comments:
In `@src/commands/export.js`:
- Around line 69-80: The CSV export in export.js writes item.command directly
inside quoted fields, so embedded double quotes can break the output. Update the
CSV generation inside the loop that builds csvContent to escape/double any
quotes in item.command before concatenating it, keeping the rest of the export
flow and filePath/writeFileSync logic unchanged.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 14-31: The CI workflow is only running linting, so it can miss
regressions in command handlers like the recent clear command change. Update the
lint job in the workflow to add at least one lightweight execution for each
command module, alongside the existing npm run lint step, so the handlers are
actually exercised during CI. Use the existing command entry points and module
names such as clear and the other subcommand modules to wire in these smoke
invocations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2d89fedb-905c-4962-bd8d-55f3290ef666
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (19)
.github/workflows/ci.yml.husky/pre-commitbin/tracker.jseslint.config.jspackage.jsonsrc/commands/clear.jssrc/commands/export.jssrc/commands/favorite.jssrc/commands/hook.jssrc/commands/init.jssrc/commands/list.jssrc/commands/save.jssrc/commands/search.jssrc/commands/stats.jssrc/index.jssrc/utils/categorizer.jssrc/utils/hook.jssrc/utils/storage.jssrc/utils/validator.js
|
* chore: bump version to 1.0.1 [skip ci] * chore: trigger publish workflow * chore: bump version to 1.0.2 [skip ci] * chore: add ESLint v9 with flat config, pre-commit hook, and CI lint job * test hook * chore: add prepare script for Husky auto-install * remove : git add from lint * chore: clean up husky pre-commit hook for v10 compatibility * refactor: get clear.js back * fix: add missing @eslint/js dev dep --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>



What this PR does
closes #95
This PR adds a complete ESLint v9 setup with pre-commit hooks and CI linting to enforce code quality across the project.
Changes made
1. ESLint v9 with Flat Config
.eslintrc.json(deprecated in v9) to moderneslint.config.js(flat config)caughtErrors: "none"to ignore unused variables incatchblocks (avoids unnecessary code changes)2. Pre-commit Hook (Husky + lint-staged)
.jsfileseslint --fixon staged files before committing3. CI/CD Integration
lintjob to.github/workflows/ci.ymlnpm run linton every PR4. Fixed All Existing Lint Errors
npm run lint:fix(quotes, indentation, semicolons)catchblock insrc/utils/hook.js5. Developer Experience
"prepare": "husky install"script topackage.jsonnpm installgit addcommandCommands added
Summary by CodeRabbit
New Features
Bug Fixes
Chores