Add CI/CD quality updates - #19
Merged
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Add a cognitive complexity check to CI/CD to block merging code that is too complicated.
What's New
ESLint Configuration
eslint.config.js(flat config) withtypescript-eslintparser andeslint-plugin-sonarjssonarjs/cognitive-complexityset toerrorat threshold15index.tsandsrc/**/*.{ts,tsx}; ignoresdist/,node_modules/,**/*.d.tslintandlint:ciscripts added topackage.json(both runeslint .)eslint@^9.39.4,eslint-plugin-sonarjs@^4.0.3,typescript-eslint@^8.59.0CI Validation
lintjob (Cognitive complexity) in.github/workflows/pr-validate.ymlpnpm run lint:cias a required PR checkModel Selector Refactor
useInputcallback insrc/infra/ui/model-selector.tsxinto four handlers:handleLifecycle,handleNavigation,handleEdit,handleCursorbooleanto signal whether the key was consumed;useInputshort-circuits through themtype Keyfrominkfor handler signaturessonarjs/cognitive-complexitybudget without changing keybindingsUtility Cleanups
DateOnly.compareinsrc/libs/time.tsusingMath.sign(year) || Math.sign(month) || Math.sign(day)instead of nested ternarieseslint-disablecomments insrc/libs/json/encoder.ts,src/libs/json/schema.ts, andsrc/libs/maybe.tspackageManagermetadata frompackage.jsonTesting & Feedback
lintjob runs on PRs and fails whensonarjs/cognitive-complexityis exceededpnpm run lintlocally againstmainto baseline existing files under the15thresholdEsc,Return,Up/Down,Left/Right,Option+Left/Right,Option+Backspace,Ctrl+W,Ctrl+U,Backspace,Delete, regular character inputDateOnly.compareon equal, earlier, and later dates across year/month/day boundariesIf you find any bugs or have recommendations for improvements, please open an issue and assign it to me.