Skip to content

feat: migrate generated packages to root ESLint config and ignore current violations#8067

Open
shivanee-p wants to merge 14 commits intomainfrom
shivaneep-generated-packages-linter
Open

feat: migrate generated packages to root ESLint config and ignore current violations#8067
shivanee-p wants to merge 14 commits intomainfrom
shivaneep-generated-packages-linter

Conversation

@shivanee-p
Copy link
Copy Markdown
Contributor

@shivanee-p shivanee-p commented Apr 16, 2026

This PR migrates the generated libraries in the monorepo to use a centralized ESLint configuration based on Google TypeScript Style (GTS) standards. The previous linter checks were not sufficient to maintain consistent code quality across all packages.
Addresses #7920 🦕

Key Changes

  • Centralized Configuration: Moved ESLint and TypeScript configurations to the repository root, removing package-specific .eslintrc.json files.
  • GTS Adoption: Configured ESLint to extend ./node_modules/gts, applying these rules to files in packages/ via overrides.
  • Ignore Handwritten: Explicitly ignored the handwritten/ directory in the root .eslintignore to avoid affecting those libraries in this phase.
  • Baselining: Automated the discovery of existing violations and add ESLint disable comments to affected TypeScript files to baseline the project state.
  • Generator Update: Added prettier as a dependency to gapic-generator-typescript and updated templater.ts to run Prettier on generated TypeScript files in memory before returning them to protoc
  • CI Check: Added ESLint check for changed packages whenever a PR is opened (doesn't apply to handwritten libraries for right now)

Next Steps

  1. Regenerate clients using the updated generator to verify reduction in linter violations.
  2. Update and apply the same standards to the handwritten libraries.

@shivanee-p shivanee-p requested a review from a team as a code owner April 16, 2026 16:08
Copy link
Copy Markdown
Contributor

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

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 baselining mechanism for ESLint violations, including a new script baseline-from-output.mjs to automate the addition of eslint-disable comments and updates to the ESLint configuration. While the goal is to manage existing linting errors across the monorepo, the review identifies several critical issues in the script's implementation. Specifically, the script is susceptible to Out-Of-Memory (OOM) errors when processing large files because it reads entire contents into memory. Furthermore, the regex-based parsing of ESLint output is unreliable, as evidenced by malformed comments in the diff that contain code snippets instead of valid rule IDs. It is highly recommended to refactor the script to use streams for file I/O and ESLint's JSON formatter for robust data extraction.

Comment thread packages/baseline-from-output.mjs Outdated
Comment thread packages/baseline-from-output.mjs Outdated
Comment thread packages/baseline-from-output.mjs Outdated
Comment thread packages/google-cloud-compute/src/v1/network_endpoint_groups_client.ts Outdated
@shivanee-p shivanee-p requested a review from quirogas April 16, 2026 16:13
@shivanee-p
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 centralizes ESLint configuration by removing individual package-level configurations and adding a root-level override in .eslintrc.json. It also introduces a baseline-from-output.mjs script designed to automate the addition of eslint-disable comments to files based on ESLint JSON output, which has been applied across numerous generated client files to suppress prettier/prettier and eol-last warnings. Feedback is provided to ensure the baselining script produces deterministic results by sorting rule IDs and to optimize the TypeScript project configuration for better performance and reliability within a monorepo structure.

Comment thread packages/baseline-from-output.mjs Outdated
Comment thread .eslintrc.json Outdated
@shivanee-p
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 integrates Prettier formatting into the TypeScript GAPIC generator and adds a script to baseline ESLint violations across packages. The baselining script was criticized for using blocking synchronous I/O and for having fragile logic that doesn't account for shebangs or existing headers. Additionally, it was suggested to include the file path in the Prettier formatting call to improve configuration inference.

Comment thread packages/baseline-from-output.mjs Outdated
Comment thread .github/workflows/eslint.yaml Fixed
@shivanee-p shivanee-p removed the request for review from quirogas April 16, 2026 17:44

try {
console.log(`Running ESLint...`);
execSync(`node packages/run-eslint-root.mjs ${pkg}`, { stdio: 'inherit' });
execSync(`node packages/run-eslint-root.mjs ${pkg}`, { stdio: 'inherit' });

console.log(`Baselining violations...`);
execSync(`node packages/baseline-from-output.mjs ${pkg}`, { stdio: 'inherit' });
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