Skip to content

Add CI/CD quality updates - #19

Merged
rafaeelricco merged 4 commits into
mainfrom
add-ci-quality-updates
Apr 21, 2026
Merged

Add CI/CD quality updates#19
rafaeelricco merged 4 commits into
mainfrom
add-ci-quality-updates

Conversation

@rafaeelricco

Copy link
Copy Markdown
Owner

Motivation

Add a cognitive complexity check to CI/CD to block merging code that is too complicated.

What's New

ESLint Configuration

  • New eslint.config.js (flat config) with typescript-eslint parser and eslint-plugin-sonarjs
  • sonarjs/cognitive-complexity set to error at threshold 15
  • Scoped to index.ts and src/**/*.{ts,tsx}; ignores dist/, node_modules/, **/*.d.ts
  • lint and lint:ci scripts added to package.json (both run eslint .)
  • Dev deps: eslint@^9.39.4, eslint-plugin-sonarjs@^4.0.3, typescript-eslint@^8.59.0

CI Validation

  • New lint job (Cognitive complexity) in .github/workflows/pr-validate.yml
  • Runs on Node 24 with pnpm run lint:ci as a required PR check

Model Selector Refactor

  • Split monolithic useInput callback in src/infra/ui/model-selector.tsx into four handlers: handleLifecycle, handleNavigation, handleEdit, handleCursor
  • Each handler returns boolean to signal whether the key was consumed; useInput short-circuits through them
  • Import type Key from ink for handler signatures
  • Brings the component under the sonarjs/cognitive-complexity budget without changing keybindings

Utility Cleanups

  • Rewrite DateOnly.compare in src/libs/time.ts using Math.sign(year) || Math.sign(month) || Math.sign(day) instead of nested ternaries
  • Remove obsolete eslint-disable comments in src/libs/json/encoder.ts, src/libs/json/schema.ts, and src/libs/maybe.ts
  • Drop packageManager metadata from package.json

Testing & Feedback

  • Confirm the new lint job runs on PRs and fails when sonarjs/cognitive-complexity is exceeded
  • Run pnpm run lint locally against main to baseline existing files under the 15 threshold
  • Exercise the model selector keybindings end-to-end: Esc, Return, Up/Down, Left/Right, Option+Left/Right, Option+Backspace, Ctrl+W, Ctrl+U, Backspace, Delete, regular character input
  • Sanity-check DateOnly.compare on equal, earlier, and later dates across year/month/day boundaries

If you find any bugs or have recommendations for improvements, please open an issue and assign it to me.

- Add a new `eslint.config.js` for TypeScript source files with SonarJS and a cognitive complexity limit.
- Add `lint` and `lint:ci` scripts to run ESLint across the project.
- Add `eslint`, `typescript-eslint`, and `eslint-plugin-sonarjs` as development dependencies and update the lockfile.
- Add a new GitHub Actions job in `pr-validate.yml` to run `pnpm run lint:ci` on pull requests.
- Set up repository checkout, Node.js 24, pnpm installation, and dependency installation for the lint workflow.
- Keep the new job scoped to read-only repository contents permissions.
- Split `ModelSelector` keyboard handling into focused lifecycle, navigation, edit, and cursor helpers while preserving existing input behavior.
- Add the `Key` type import for Ink input handlers and keep character insertion logic in the main `useInput` callback.
- Remove obsolete ESLint suppression comments from JSON and maybe utilities.
- Simplify `DateOnly.compare` to use chained `Math.sign` comparisons.
@rafaeelricco rafaeelricco self-assigned this Apr 21, 2026
@rafaeelricco
rafaeelricco merged commit 5d87402 into main Apr 21, 2026
4 checks passed
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.

1 participant