8000 feat(lint): enforce and clean unused dependencies across stack by VLukiantsev · Pull Request #1001 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

feat(lint): enforce and clean unused dependencies across stack - #1001

Merged
VLukiantsev merged 2 commits into
mainfrom
feat/enforce-and-clean-unused-dependencies
Sep 28, 2026
Merged

VLukiantsev merged 2 commits into
mainfrom
feat/enforce-and-clean-unused-dependencies

Conversation

@VLukiantsev
@VLukiantsev VLukiantsev commented Sep 28, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Enforces package- and code-level unused dependency checks across the stack (Go module dependencies via go mod tidy -diff, Bazel unused variables via Buildifier linter warnings, TypeScript unused imports via eslint-plugin-unused-imports) and cleans up dead parameters/variables across Go, Bazel, TypeScript, and Python.

Motivation & Context

Unused dependencies and dead parameters/variables degrade maintainability, clutter signatures, and can mask configuration rot. While go.mod was already clean, neither pre-commit hooks nor CI verified that go mod tidy produced no diffs. Similarly, Buildifier previously ran only in format-check mode (-mode=check), ignoring linter warnings like unused variables, and ESLint lacked automated unused import enforcement. This PR adds automated enforcement gates across all primary languages while cleaning existing dead variables and arguments.

Key Changes

  • Go Enforcement: Added go mod tidy -diff check to .githooks/pre-commit and .github/workflows/lint.yml.
  • Bazel Enforcement & Cleanup: Added -lint=warn -warnings=unused-variable to Buildifier in .githooks/pre-commit and .github/workflows/lint.yml; cleaned unused ctx parameter in import.bzl (_repo_import_impl).
  • TypeScript / UI Enforcement & Cleanup: Installed eslint-plugin-unused-imports in cmd/ui/package.json; enabled 'unused-imports/no-unused-imports': 'error' in cmd/ui/eslint.config.js; cleaned dead _period variable assignment in cmd/ui/app/resource_dashboard/resource_dashboard.ts.
  • Python Cleanup: Removed unused force parameter from _build_gh_release_cmd and publish_via_gh_cli in tools/release/github_release_client.py and callers in tools/release/publish_release.py; prefixed unused user_agent in _call_api_with_gh in tools/pr_review/github_utils.py.
  • UI Dependencies Audit: Evaluated cmd/ui/package.json (@angular/animations and @angular/compiler); verified that both are required at build-time by @angular/material and @angular/compiler-cli, preserving them intact.

Assumptions

  • None — requirements were fully specified.

Verification & Testing

  • Bazel Tests: Executed bazel test //tools/release/... //tools/pr_review/... (16 of 16 passed cleanly).
  • Bazel UI Tarball Build: Executed bazel build //cmd/ui:ui_image_tarball (Docker container build completed successfully).
  • UI Linters & Formatters: Ran npm run lint and npm run format:check in cmd/ui (passed cleanly).
  • Go Dependency Check: Ran go mod tidy -diff (clean, zero diffs).
  • Buildifier Lint Check: Ran buildifier -lint=warn -warnings=unused-variable -mode=check across all repo Bazel/bzl files (passed cleanly).
  • Python Quality: Ran ruff check and ruff format --check on touched Python files (passed cleanly).
  • Pre-commit Hooks: Executed ./.githooks/pre-commit (all checks passed cleanly).
  • Diff Sizing: Checked diff via ./tools/analyze_diff_size.py --base-ref origin/main (well below thresholds).

Related Issues / Bugs

N/A

TAG=agy
CONV=22009166-566e-4d4f-ace4-c924d7d32241

- Enforce Go module dependency cleanliness with `go mod tidy -diff` check in pre-commit hooks and GitHub Actions CI.
- Enforce Buildifier unused-variable lint checks (`-lint=warn -warnings=unused-variable`) in pre-commit and CI.
- Clean unused variable in `import.bzl` repository extension (`_ctx`).
- Clean unused parameters in Python release and PR review tools (`_build_gh_release_cmd`, `publish_via_gh_cli`, and `_call_api_with_gh`).

TAG=agy
CONV=22009166-566e-4d4f-ace4-c924d7d32241
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

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 adds unused-variable warnings to the Bazel buildifier pre-commit hook, introduces a Go module dependency check, resolves unused variable warnings in Starlark and Python files, and removes an unused 'force' parameter from the GitHub release client. A critical issue was identified in the pre-commit hook where 'go mod tidy -diff' is used, which is not supported by standard Go toolchains and will cause the check to fail; a workaround using 'git diff' with temporary backups of 'go.mod' and 'go.sum' was suggested.

Comment thread .githooks/pre-commit Resolved
- Add `eslint-plugin-unused-imports` to `cmd/ui/package.json` devDependencies.
- Configure `unused-imports/no-unused-imports: 'error'` in `cmd/ui/eslint.config.js`.
- Clean unused `_period` variable assignment in `ResourceDashboard` constructor effect.

TAG=agy
CONV=22009166-566e-4d4f-ace4-c924d7d32241
@VLukiantsev
VLukiantsev marked this pull request as ready for review September 28, 2026 12:43
@github-actions
github-actions Bot requested a review from AntonTyb September 28, 2026 12:43
@VLukiantsev
VLukiantsev added this pull request to the merge queue Sep 28, 2026
Merged via the queue into main with commit d65be10 Sep 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0