-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: improve project structure and type safety #6
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
Conversation
- Add optional row mapping to query methods in NameDatabase - Update extractedAt type to use z.iso.datetime in Publication type - Refactor timeout handling for better readability in fetch tools - Improve type definitions in parseArgs and question-handler utilities
- Add new prettier plugin for sorting imports - Clean up import statements for better readability - Improve code organization in various modules
- Add JSDoc comments to classes and methods for better clarity - Improve error messages in URL validation and fetch operations - Refactor ESLint rules for stricter type checks and template expressions
- Replace relative imports with absolute paths using path aliases - Delete unused index.ts file in tools directory
- Add ESLint rule to restrict deep relative imports - Update AGENTS.md and README.md to prefer path aliases
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.
Pull request overview
This PR refactors the codebase to improve type safety, code organization, and maintainability by introducing stricter linting rules, enforcing TypeScript path aliases, and standardizing code style patterns.
Changes:
- Added TypeScript path aliases (
~tools,~clients,~utils) and enforced their use via ESLint - Converted all
interfacedeclarations totypefor consistency - Converted all
functiondeclarations to arrow functions (const) - Added comprehensive JSDoc comments across the codebase
- Introduced stricter ESLint rules including
strictTypeChecked,curly: "all", andfunc-style: "expression" - Added Prettier plugin for automatic import sorting
- Improved Zod type definitions (
z.ZodTypeAny→z.ZodType) - Added
.npmrcfor exact version pinning - Updated documentation (README, AGENTS.md) to reflect new conventions
Reviewed changes
Copilot reviewed 45 out of 48 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tsconfig.json |
Added path aliases configuration for ~tools, ~clients, ~utils |
vitest.config.ts |
Added path alias resolution for test environment |
prettier.config.ts |
Added import sorting plugin with custom order configuration |
eslint.config.ts |
Added strict type checking, curly braces, arrow function enforcement, and path alias rules |
package.json |
Added prettier import sorting plugin and lint:fix script |
.npmrc |
Added exact version pinning configuration |
src/**/*.ts |
Converted interfaces to types, functions to arrows, relative imports to aliases, added JSDoc |
src/cli/scrape-publications/types/index.ts |
Updated Zod schemas (contains critical bug with z.iso API) |
src/cli/name-explorer/constants.ts |
Extracted FIRST_DECADE and LAST_DECADE constants |
src/tools/index.ts |
Removed barrel export file in favor of direct imports |
README.md, AGENTS.md |
Updated documentation with path alias conventions |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
src/cli/scrape-publications/types/index.ts:28
- The Zod API
z.iso.datetime()does not exist. The correct Zod API for datetime validation isz.string().datetime(). Thez.isonamespace is not a valid Zod API. This will cause runtime errors when validating Publication objects.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
package.json
Outdated
| "devDependencies": { | ||
| "@eslint/compat": "2.0.1", | ||
| "@eslint/js": "9.39.2", | ||
| "@ianvs/prettier-plugin-sort-imports": "^4.7.0", |
Copilot
AI
Jan 24, 2026
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.
The PR description claims "No new dependencies" under the security review section, but this is incorrect. The PR adds a new devDependency: @ianvs/prettier-plugin-sort-imports version ^4.7.0. While this is a devDependency (not a runtime dependency) and appears to be a legitimate Prettier plugin, the security review statement is inaccurate.
package.json
Outdated
| "devDependencies": { | ||
| "@eslint/compat": "2.0.1", | ||
| "@eslint/js": "9.39.2", | ||
| "@ianvs/prettier-plugin-sort-imports": "^4.7.0", |
Copilot
AI
Jan 24, 2026
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.
The .npmrc configuration specifies save-exact=true and save-prefix= (empty) to enforce exact version pinning without carets or tildes. However, the new dependency @ianvs/prettier-plugin-sort-imports uses ^4.7.0 with a caret prefix. This conflicts with the project's versioning policy. The version should be 4.7.0 without the caret to match the .npmrc configuration.
| "@ianvs/prettier-plugin-sort-imports": "^4.7.0", | |
| "@ianvs/prettier-plugin-sort-imports": "4.7.0", |
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 automated review suggestions for this pull request.
Reviewed commit: 24a8cdada5
ℹ️ 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
- 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 address that feedback".
.npmrc
Outdated
| save-prefix= # Don't use caret (^) or tilde (~) in package versions | ||
| save-exact=true # Always save exact versions No newline at end of file |
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.
Move npmrc comments onto their own lines
When tools like pnpm add or npm install --save read .npmrc, inline comments are not stripped, so the # … text becomes part of the value. That means save-prefix will be set to a literal string containing the comment and save-exact won’t parse as a boolean, which can cause dependency adds to write invalid version strings or ignore the “exact versions” intent. Put comments on separate lines so the values are just save-prefix= and save-exact=true.
Useful? React with 👍 / 👎.
What
Enhance the overall structure and type safety of the project by clarifying the organization of files and improving code readability. This includes the addition of new lint rules, better error handling, and improved documentation. The refactor also enforces the use of TypeScript path aliases for imports, which simplifies import statements across the codebase.
Refactored code for better readability and organization in various modules.
Added new lint rules and a Prettier plugin for sorting imports.
Enhanced type safety in query methods and improved type definitions.
Updated documentation with JSDoc comments for clarity.
Introduced
.npmrcfor package management configuration.How to test
Run
pnpm lintto check for linting issues.Execute
pnpm typecheckto ensure type safety across the codebase.Run
pnpm testto verify that all tests pass.Expected results include no linting errors, successful type checks, and passing tests.
Security review
Secrets / env vars: not changed.
Auth / session: not changed.
Network / API calls: not changed.
Data handling / PII: not changed.
Dependencies: added/updated. New dependencies include a Prettier plugin for sorting imports.
No security-impacting changes identified.
No new dependencies and no network calls.
No env var changes and no auth/session logic touched.