Create and test package.json verifier#80
Conversation
Create validate-package-json.js. Add it to the package.json as a script so we can add it to the workflow ci.yml. Need to verify with dev about what fields are needed before creating any testing.
Added initial comments for personal use. Will neaten up once done testing.
Changed the js file to cjs to allow testing. Made a testing file for the package check.
Update readme to include the new script folder for testing and rename the test file to maintain style.
|
Warning Review limit reached
More reviews will be available in 51 minutes and 39 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 refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit 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 selected for processing (2)
📝 WalkthroughWalkthroughAdds Changespackage.json Validation Script
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
I see why the ci failed, forgot to change the scripts name in the package.json when I changed for testing. Making the change and will re submit after the code rabbit scan is done as well. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/README.md (1)
43-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor formatting: simplify tree structure whitespace.
The two blank lines (43–44) create unnecessary separation in the tree diagram. Consider removing them to maintain visual continuity, or explicitly group sections if this spacing was intentional.
✨ Suggested cleanup
├── Formatter.test.ts # Output formatting tests -│ -│ -├── scripts `#General` script testing +├── scripts # General script testing │ ├── ValidatePackageJson.test.ts `#Package.json` check tests ├── transports/ # Transport implementation tests🤖 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 `@tests/README.md` around lines 43 - 46, In the tree diagram structure of the README.md file, there are two consecutive blank lines appearing before the scripts section (which contains the ValidatePackageJson.test.ts reference). Remove these extra blank lines to maintain visual continuity and improve the readability of the tree structure diagram. Keep only necessary single-line spacing between logical sections if needed for grouping.
🤖 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 `@package.json`:
- Around line 37-38: The check-package-schema npm script is referencing an
incorrect file path. Update the check-package-schema script value in
package.json from pointing to scripts/check-package-schema.js to the actual
validation script location of scripts/validate-package-json.cjs to ensure the
npm script executes the correct file and resolves the file not found error.
In `@tests/scripts/ValidatePackageJson.test.ts`:
- Around line 1-9: Replace the require() call at the beginning of the test file
with ES import syntax. Convert the destructured require statement that imports
getNestedValue, packageSchema, validate, validateExportEntry, and
validateExportPath from "../../scripts/validate-package-json.cjs" into a
standard ES import statement using the import keyword. This will resolve the
`@typescript-eslint/no-require-imports` ESLint violation.
---
Nitpick comments:
In `@tests/README.md`:
- Around line 43-46: In the tree diagram structure of the README.md file, there
are two consecutive blank lines appearing before the scripts section (which
contains the ValidatePackageJson.test.ts reference). Remove these extra blank
lines to maintain visual continuity and improve the readability of the tree
structure diagram. Keep only necessary single-line spacing between logical
sections if needed for grouping.
🪄 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: 12e7cb45-d390-4bc1-b111-4c90e614d8d6
📒 Files selected for processing (5)
.github/workflows/ci.ymlpackage.jsonscripts/validate-package-json.cjstests/README.mdtests/scripts/ValidatePackageJson.test.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Tested locally, works. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
Merged and issue closed |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Adds a script that validates the structure of package.json and a Jest test file for the validation logic.
This helps catch missing fields, incorrect value types, and invalid export paths before they cause build or publishing problems.
No new dependencies are required. The tests use the project’s existing Jest setup.
Fixes #78
Type of Change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Test Configuration:
Checklist
Additional Notes
Add any other context or screenshots about the pull request here.
This is my first public open-source contribution, so please let me know if any changes are needed. I apologize for the commit message formatting, I didnt realize till too late they needed to be formatted as well, I thought it was only the pull.
I added tests, comments, and updated the testing documentation. AI was used as a supporting tool for coding and documentation, not as a replacement for understanding or reviewing the work.
Summary by CodeRabbit
Chores
Tests