Skip to content

feat: add basic monorepo linter to enforce GTS standards - #8446

Merged
shivanee-p merged 25 commits into
mainfrom
shivaneep-monorepo-linter
Jul 1, 2026
Merged

shivanee-p merged 25 commits into
mainfrom
shivaneep-monorepo-linter

Conversation

@shivanee-p

@shivanee-p shivanee-p commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

This PR refactors the monorepo linter bin/linter.mjs to run checks on files modified in a PR, with formatting, static linting, and TypeScript compilation checks. This is done via the local CLI binaries directly via execFileSync, avoiding complex programmatic configurations.

  • Added getGitTarget() to check for the base branch in order of priority: origin/<base> -> <base> -> HEAD~1. This prevents linter failures in shallow-cloned or detached-HEAD CI environments (like GitHub Actions) and avoids comparing against outdated local branches.
  • Configured ESLint to run Prettier formatting checks directly as a lint rule by extending plugin:prettier/recommended in the root .eslintrc.json.
  • Installed eslint-plugin-import and eslint-plugin-promise to enforce best practices.
  • Configured the rules as blocking errors in .eslintrc.json (only checked against touched files in the PR) import/no-extraneous-dependencies, promise/catch-or-return, and promise/always-return
  • Implements checkTypeSafety() which runs tsc --noEmit on parent packages using node_modules/typescript/bin/tsc
  • Any compilation or type safety failures in modified packages are blocking and will fail the linter execution.
  • Added early exit logging No TypeScript files changed. Skipping checks. to provide immediate feedback when no .ts files are touched.

@shivanee-p
shivanee-p requested a review from a team as a code owner June 5, 2026 19:41

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new linter script (bin/linter.mjs) that uses Prettier to check formatting on changed files, and updates package.json to run this script during the lint step. The review feedback highlights critical security and robustness improvements: specifically, replacing execSync with execFileSync to prevent command injection vulnerabilities and handle filenames with spaces or special characters safely, and dynamically resolving the base branch using process.env.GITHUB_BASE_REF to support CI environments.

Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
@shivanee-p

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new linter script, bin/linter.mjs, which runs Prettier to check formatting on changed files against a base branch, and updates the lint script in package.json to execute it. Feedback on the implementation highlights two issues: potential failures in CI environments if the local base branch is missing (suggesting a fallback to the remote tracking branch), and cross-platform compatibility issues on Windows when executing npx via execFileSync (suggesting dynamically resolving the command to npx.cmd).

Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
@shivanee-p
shivanee-p force-pushed the shivaneep-monorepo-linter branch 2 times, most recently from c7ebcda to efb3794 Compare June 8, 2026 16:29
@shivanee-p
shivanee-p requested review from feywind and removed request for a team June 22, 2026 21:14
Comment thread bin/linter.mjs Outdated
@shivanee-p
shivanee-p force-pushed the shivaneep-monorepo-linter branch 2 times, most recently from 154c45f to d9dac40 Compare June 29, 2026 20:06
@shivanee-p

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new linter script (bin/linter.mjs) that checks changed TypeScript files using Prettier and ESLint, and updates package.json to run this script. The review feedback highlights several robustness issues when running the script from subdirectories or within CI environments. It recommends dynamically resolving the repository root directory, executing Git and the linter binaries relative to this root, and using remote tracking branches for the base branch in CI.

Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
@shivanee-p

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a custom linter script (bin/linter.mjs) that programmatically runs Prettier and ESLint on changed TypeScript files, and updates package.json to use this script and include the necessary devDependencies. The review feedback suggests several improvements to make the linter more robust for CI environments: dynamically resolving the git diff reference to prevent failures when the base branch is not fetched, rethrowing programmatic ESLint errors to avoid silent failures, and running Prettier and ESLint sequentially rather than concurrently to ensure clean console output and complete execution of both tools.

Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
Comment thread bin/linter.mjs Outdated
@shivanee-p
shivanee-p force-pushed the shivaneep-monorepo-linter branch from 02e687d to 906c498 Compare June 30, 2026 14:58
@shivanee-p
shivanee-p requested a review from pearigee June 30, 2026 20:00
Comment thread bin/linter.mjs
@shivanee-p
shivanee-p merged commit 69dcf47 into main Jul 1, 2026
42 checks passed
@shivanee-p
shivanee-p deleted the shivaneep-monorepo-linter branch July 1, 2026 02:30
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.

2 participants