Skip to content

chore: add git hooks, ESLint/Prettier, and commitlint#57

Open
andrefelizardo wants to merge 28 commits intodevelopfrom
feat/SDK-85-pre-commit
Open

chore: add git hooks, ESLint/Prettier, and commitlint#57
andrefelizardo wants to merge 28 commits intodevelopfrom
feat/SDK-85-pre-commit

Conversation

@andrefelizardo
Copy link
Collaborator

  • Add Husky-based git hooks: pre-commit runs pnpm lint-staged and commit-msg runs pnpm commitlint --edit "$1" for conventional commits.
  • Configure lint-staged for auto-fix DX: run eslint --fix then prettier --write on staged TS/JS files and prettier --write on staged markdown.
  • Introduce shared lint/format tooling: add root .eslintrc.cjs, .eslintignore, prettier.config.cjs, .prettierignore and wire @oaknetwork/api scripts (lint, lint:fix, format, typecheck).
  • Tighten CI checks: add a CI commitlint job and a pnpm typecheck step in build-and-test to run tsc --noEmit in workspaces.
  • Docs: update README.md to describe git hooks, ESLint/Prettier usage, pnpm typecheck, and the CI enforcement flow.

Test plan

  • pnpm install
  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • Make a small change, stage it, and run git commit:
    • Verify ESLint/Prettier auto-fix staged files.
    • Verify bad commit messages are rejected and valid conventional commits pass.

…ged configurations for improved code quality
… formatting and typecheck scripts for improved code quality
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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: eb94e420cc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["./packages/api/tsconfig.build.json"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include test files in typed ESLint project

The ESLint config restricts parserOptions.project to packages/api/tsconfig.build.json, but that tsconfig excludes __tests__ while packages/api/package.json now lints __tests__/**/*.{ts,tsx}. Because plugin:@typescript-eslint/recommended-requiring-type-checking is enabled, ESLint will raise parsing errors for those test files not being in the configured TS project, so pnpm lint and the CI lint step will fail until tests are covered by a referenced tsconfig (or removed from the lint target).

Useful? React with 👍 / 👎.

Comment on lines +47 to +49
"packages/contracts/**/*.{ts,tsx,js,jsx}": [
"eslint --fix",
"prettier --write"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop lint-staged from ESLinting contracts with API tsconfig

This pre-commit rule runs eslint --fix for staged files under packages/contracts, but the only configured TypeScript project for ESLint is ./packages/api/tsconfig.build.json in .eslintrc.cjs. Staging any contracts .ts file will therefore trigger the TypeScript-ESLint "file was not found in any of the provided projects" parsing failure, blocking commits that modify the contracts package.

Useful? React with 👍 / 👎.

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