Skip to content

refactor: improve programmatic API code quality#1429

Merged
dyoshikawa merged 2 commits intodyoshikawa:mainfrom
tmchow:refactor/1076-api-code-quality
Apr 3, 2026
Merged

refactor: improve programmatic API code quality#1429
dyoshikawa merged 2 commits intodyoshikawa:mainfrom
tmchow:refactor/1076-api-code-quality

Conversation

@tmchow
Copy link
Copy Markdown
Contributor

@tmchow tmchow commented Apr 2, 2026

Summary

Applied all 4 code quality improvements from #1076 to src/index.ts.

Changes

  1. Include baseDir in error message - the checkRulesyncDirExists error now shows which directory failed
  2. Extract BaseOptions type - shared properties (configPath, verbose, silent, global) extracted into a common type that GenerateOptions and ImportOptions extend
  3. Explicit return types - added Promise<GenerateResult> and Promise<ImportResult> return type annotations to the public API functions
  4. Explicit features destructuring - features is now explicitly destructured in importFromTool and passed to ConfigResolver.resolve, making the data flow clearer

Testing

All changes are type-level or error message improvements. No behavioral changes to the API functions.

Fixes #1076

This contribution was developed with AI assistance (Claude Code).

1. Include baseDir in error message for checkRulesyncDirExists
2. Extract common BaseOptions type from GenerateOptions/ImportOptions
3. Add explicit return type annotations (Promise<GenerateResult>,
   Promise<ImportResult>) for public API functions
4. Explicitly destructure features in importFromTool

Fixes dyoshikawa#1076
@dyoshikawa
Copy link
Copy Markdown
Owner

@tmchow thank you. please check ci failure.

@dyoshikawa dyoshikawa merged commit 53fb62b into dyoshikawa:main Apr 3, 2026
6 checks passed
@dyoshikawa
Copy link
Copy Markdown
Owner

@tmchow Thank you!

@tmchow
Copy link
Copy Markdown
Contributor Author

tmchow commented Apr 3, 2026

Thanks for taking a look and merging!

@github-actions github-actions bot mentioned this pull request Apr 4, 2026
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.

refactor: improve programmatic API code quality (src/index.ts)

2 participants