Repository navigation
chore: harden ui eslint rules and enable tsc typechecking - #1672
VLukiantsev wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces UI typechecking via tsc to the pre-commit hook and adds a new typecheck script, along with updating ESLint rules and VS Code settings. Feedback on these changes includes removing the non-existent @angular-eslint/template/prefer-at-else rule which will break ESLint, restoring overrides for no-explicit-any and no-unused-vars in test and mock files to avoid overly verbose type assertions, and running the sequential tsc checks in parallel within the pre-commit hook to improve execution speed.
81b9dba to
6f25670
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the pre-commit githook to run TypeScript typechecking and optimize UI formatting and linting, introduces a new tsconfig.e2e.json configuration, and enhances ESLint rules for TypeScript and HTML templates. The review feedback suggests improving the git diff filters in the pre-commit hook to include renamed and copied files (ACMR and ACMRD) so they are not skipped during checks. Additionally, it is recommended to remove the max-lines rule from the HTML ESLint configuration as it is ineffective on Angular HTML templates.
6f25670 to
0d4aaf9
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances the pre-commit hook to support UI typechecking and refactors ESLint configurations, including adding new rules for TypeScript and Angular templates. The review feedback highlights two key issues: a bug in the pre-commit hook's regular expression that prevents typechecking from triggering when root configuration files (like tsconfig.json or package.json) are modified, and an inactive 'max-lines' rule configuration in the ESLint settings for HTML files, which is silently ignored due to the custom AST parser used for Angular templates.
0d4aaf9 to
3f3e6ae
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the pre-commit hook to improve UI file handling, introduces a new TypeScript type-checking step, and updates ESLint configurations with stricter rules and HTML template validations. It also adds a dedicated tsconfig.e2e.json for end-to-end tests. Feedback suggests adding @types/node to the UI package dependencies to prevent potential type-checking failures due to dependency hoisting.
3f3e6ae to
50a6d68
Compare
50a6d68 to
1642a35
Compare
7a6ced9 to
b01cf90
Compare
8649f00 to
ccfdced
Compare
ce31da0 to
ab5d147
Compare
ab5d147 to
0071503
Compare
9fc76be to
b59f2b8
Compare
b59f2b8 to
2c0b1ad
Compare
2c0b1ad to
f54f474
Compare
f54f474 to
68205b1
Compare
68205b1 to
91db96f
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the UI linting and type-checking configuration, including adding a new typecheck script, a tsconfig.e2e.json file, and expanding ESLint rules for TypeScript and HTML templates. The pre-commit runner is also refactored to support these checks. Feedback points out a cross-platform compatibility issue in the pre-commit runner where the ESLint binary path is hardcoded instead of using the dynamically resolved path.
91db96f to
779092b
Compare
Address PR #1672 review feedback (`4590816747`) by invoking the resolved `eslint` path from `gates.resolve_ui_binary(ctx, "eslint")` instead of hardcoding `./node_modules/.bin/eslint`, and assert the passed binary in `precommit_runner_test.py`. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances the UI linting and typechecking setup by adding HTML and JavaScript validation to VS Code, introducing a new TypeScript configuration for E2E tests, and updating ESLint rules. Additionally, the pre-commit runner is refactored to support selective ESLint execution and TypeScript typechecking. The review feedback identifies two important improvements: normalizing file paths to POSIX style in the pre-commit runner to ensure cross-platform compatibility on Windows, and running the tsc binary directly instead of through npm run to reduce process startup overhead.
| if run_typecheck and gates.resolve_ui_binary(ctx, "tsc"): | ||
| print("--> Running UI Typechecker (tsc)...") | ||
| if ( | ||
| gates.exec_cmd( | ||
| ["npm", "run", "--silent", "typecheck"], cwd=gates.REPO_ROOT / "cmd/ui" | ||
| ).returncode | ||
| != 0 | ||
| ): | ||
| ctx.fail("UI TypeScript typecheck failed.") |
There was a problem hiding this comment.
Instead of invoking npm run --silent typecheck which introduces significant startup overhead from npm (often 0.5 to 1.5 seconds), we can run the resolved tsc binary directly on each configuration file. This is much faster, avoids the extra process overhead, and aligns with how eslint and prettier are executed.
if run_typecheck and (tsc := gates.resolve_ui_binary(ctx, "tsc")):
print("--> Running UI Typechecker (tsc)...")
failed = False
for config in ("tsconfig.json", "tsconfig.spec.json", "tsconfig.e2e.json"):
if (
gates.exec_cmd(
[tsc, "--noEmit", "-p", config], cwd=gates.REPO_ROOT / "cmd/ui"
).returncode
!= 0
):
failed = True
break
if failed:
ctx.fail("UI TypeScript typecheck failed.")There was a problem hiding this comment.
Push Back: Intentionally keeping npm run --silent typecheck so the list of TypeScript project configs (tsconfig.json, tsconfig.spec.json, tsconfig.e2e.json) stays in a single source of truth inside cmd/ui/package.json shared with .github/workflows/lint.yml (Run TypeScript Typecheck), rather than duplicating the project list in tools/lint/precommit_runner.py where future configs could drift. This trade-off is documented in PR #1672 ## Assumptions.
…e tsc typechecking - Fix ESLint root-cwd glob matching in `cmd/ui/eslint.config.js` (`**/app/testing/**`, `**/index.html`, `**/dist/**`, `**/coverage/**`, `**/out-tsc/**`, `**/node_modules/**`), enforce `max-lines` and Angular template rules, and keep strict `no-explicit-any`/`no-unused-vars`/`unused-imports` checks enabled on tests and mocks. - Update `tools/lint/precommit_runner.py` (`check_ui`) to exclude `dist`/`coverage`/`out-tsc`, run ESLint from `cmd/ui`, delegate `npm run --silent typecheck`, and cover deletes/renames, `eslint.config.js`, `tsconfig*.json`, and `package*.json`. - Add `cmd/ui/tsconfig.e2e.json`, `npm run typecheck`, `.github/workflows/lint.yml` typecheck step, and `.vscode/settings.json` ESLint validators. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
Address PR #1672 review feedback (`4590816747`) by invoking the resolved `eslint` path from `gates.resolve_ui_binary(ctx, "eslint")` instead of hardcoding `./node_modules/.bin/eslint`, and assert the passed binary in `precommit_runner_test.py`. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
627c8bc to
5362ec2
Compare
Summary
Harden UI ESLint rules (
max-linesand Angular template quality/complexity checks, plus re-enablingunused-importsandno-unused-varschecks on tests/mocks with a.d.tsno-unused-varsexemption while preserving PR #1671's narrowno-explicit-anyexemptions) and wire stricttsctypechecking across production, unit-test, and Playwright E2E TypeScript configs into CI andtools/lint/precommit_runner.py.Motivation & Context
Closing remaining ESLint and TypeScript gaps in test, mock, E2E, and template code prevents agents from bypassing type checking, leaving dead imports, or introducing oversized templates and components.
Key Changes
Modified/added 7 file(s):
cmd/ui/eslint.config.js: Enforcemax-lines(300non-blank/non-comment lines for**/*.tsand**/*.htmlexcluding**/index.html;600for test,mock_*.ts,*.d.ts,**/testing/**, and**/screenshot_tests/**), add 6 Angular template rules (cyclomatic-complexitymax 10,conditional-complexitymax 4,no-inline-styleswithallowBindToStyle: true,no-any,prefer-at-else,no-interpolation-in-attributes), re-enableunused-imports/no-unused-importsand@typescript-eslint/no-unused-varson tests/mocks while keeping@typescript-eslint/no-unused-vars: 'off'on**/*.d.tsand preserving PR refactor(ui): remove explicit any and enforce lint rule in ui tests #1671's narrowno-explicit-anyexemption on**/app/testing/test.tsand**/app/protos/*.d.ts, and prefix**/dist/**,**/node_modules/**,**/coverage/**, and**/out-tsc/**ignores for cwd-independent matching.cmd/ui/tsconfig.e2e.json&cmd/ui/package.json: Add strict E2E tsconfig (extends: ./tsconfig.json,noEmit: true,types: ["node"]) coveringscreenshot_tests/**/*.tsandplaywright.config.ts, and add"typecheck"runningtsc --noEmitacrosstsconfig.json,tsconfig.spec.json, andtsconfig.e2e.json..github/workflows/lint.yml: AddRun TypeScript Typecheck(npm run typecheck) step whensteps.changes.outputs.ui == 'true'.tools/lint/precommit_runner.py&precommit_runner_test.py: Updatecheck_ui()/_run_ui_eslint()to excludedist/coverage/out-tsc, captureACMRchanges (including renames), run ESLint withcwd="cmd/ui"(full.when--checkorstaged_paths_match AM '^cmd/ui/eslint\.config\.js$', filtered.ts/.htmlotherwise skippingcmd/ui/index.html), and runnpm run --silent typecheckwhen--checkorstaged_paths_match AMDmatches UI.ts/tsconfig*.json/package.json/package-lock.jsonchanges, backed by unit tests intest_check_ui_and_license..vscode/settings.json: Expand"eslint.validate"from["typescript"]to["javascript", "typescript", "html"].Assumptions
mock_*.tsfixtures, screenshot specs, and non-*.d.tshelpers satisfyno-unused-varsandunused-imports/no-unused-importsalongside PR refactor(ui): remove explicit any and enforce lint rule in ui tests #1671'sno-explicit-anyenforcement, while**/*.d.tsretains@typescript-eslint/no-unused-vars: 'off'— ambient.d.tsdeclaration merging requires matching unused generic parameters, and ESLint passes acrosscmd/ui— future unused type parameters in.d.tsremain allowed, while unused imports/vars in tests and mocks will fail lint.max-lineslimits (300effective lines for prod TS/HTML,600for test/mock/.d.ts/**/testing/**/**/screenshot_tests/**) and template complexity caps (cyclomatic-complexity: 10,conditional-complexity: 4) establish enforceable size/complexity ceilings — current UI files passeslint .— oversized or branch-heavy components added later will fail lint until refactored.tsc --noEmitchecking ofcmd/ui/tsconfig.e2e.json(types: ["node"],noEmit: true) suffices in lint/pre-commit without executing Playwright browser runtime (npm run test:screenshot) — E2E specs import@playwright/testwhileplaywright.config.tsuses hoisted@types/nodeforprocess.env, and browser screenshot runs requireng build+ Chromium in the UI test job — removing hoisted@types/nodewill break statictypecheckuntil added todevDependencies, while Playwright browser runtime regressions would not be flagged by statictypecheckalone.tsc --noEmitprojects sequentially vianpm run --silent typecheck(cwd="cmd/ui") inprecommit_runner.pybalances commit speed and clean diagnostics —tscchecks all three configs in seconds sequentially — slower UI trees in the future will add sequential seconds to UI-touching commits, and pre-existing type errors in any of the three configs block unrelated UI commits.docs/developer.md/.agents/rules/languages/typescript_javascript.mdupdates fornpm run typecheckto dedicated docs updates keeps this check-enabling slice focused — PR chore: harden ui eslint rules and enable tsc typechecking #1672 only modifies lint/typecheck configs, runner, and CI — until updated, docs omitnpm run typecheckalongsidenpm run lint.Verification & Testing
./.githooks/pre-commit --check(includes full UI Prettier/ESLint/tsc,actionlint,golangci-lint,ruff,mypy,shellcheck, and Bazel tests viarun_affected_tests.py --skip-emulator-check)(cd cmd/ui && ./node_modules/.bin/eslint . && npm run --silent typecheck)bazel test --test_output=errors //tools/lint:precommit_runner_test //cmd/ui:ui_unit_testscmd/ui/eslint.config.jspreserving narrowtest.tsandapp/protos/*.d.tsno-explicit-anyexemption), with full./.githooks/pre-commit --check, ESLint,typecheck,//tools/lint:precommit_runner_test, and//cmd/ui:ui_unit_testspassing on the stack. Playwright browser screenshot runtime (npm run test:screenshot) was not executed locally.Related Issues / Bugs
N/A (part of automated linter and refactoring stack).
TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c