Repository navigation
refactor(ui): remove explicit any and enforce lint rule in ui tests - #1671
VLukiantsev wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves type safety across various Angular and ECharts test files by replacing loose "as any" type assertions with explicit, strongly-typed interfaces and models (such as ActivatedRouteSnapshot, HealthStatusResponse, and ECharts component options). The feedback recommends further simplifying these assertions: first, by using TypeScript's bracket notation to access private component members in artifacts_list_test.ts instead of defining a verbose helper interface; and second, by removing a redundant intersection type when casting xAxis in bar_options_builder_test.ts since XAXisComponentOption already includes the data property.
7398404 to
4d043a7
Compare
|
/gemini review |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves type safety across multiple Angular test files by replacing loose any types with explicit, strongly-typed interfaces and classes. The changes span various guards, components, and mock data files. Feedback on these changes suggests removing redundant as ArtifactSingle type assertions in artifacts_list_test.ts where the underlying observables are already strongly typed, and simplifying a type assertion in bar_options_builder_test.ts by removing an unnecessary intersection type on XAXisComponentOption.
4d043a7 to
b655a92
Compare
b655a92 to
1c03423
Compare
363aa57 to
b9a047b
Compare
cbb31ee to
3c236a4
Compare
3c236a4 to
0fb0516
Compare
991cb23 to
70211c2
Compare
70211c2 to
b876599
Compare
b876599 to
da38716
Compare
da38716 to
f628ef3
Compare
f628ef3 to
59beb55
Compare
59beb55 to
3702af1
Compare
3702af1 to
74ddc0a
Compare
Remove `@typescript-eslint/no-explicit-any: 'off'` from the broad test override in `cmd/ui/eslint.config.js` so `any` cannot be reintroduced into UI tests, mocks, harnesses, or screenshot specs in PR #1671, narrow the legacy override to `**/app/testing/test.ts` and `**/app/protos/*.d.ts`, and replace `any` in `cmd/ui/app/testing/testing.d.ts` with `unknown`. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
74ddc0a to
3d23293
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request removes the use of "any" across various TypeScript test files, mock data, and guards, replacing them with explicit types and interfaces to enforce stronger type safety. It also updates the ESLint configuration to enable the "@typescript-eslint/no-explicit-any" rule, except for specific test and proto files. The review feedback suggests improving the robustness of the tests in "scatter_options_builder_test.ts" by using optional chaining when accessing "markLineData" elements, preventing potential runtime "TypeError"s if the data is undefined.
8510954 to
e797374
Compare
e797374 to
dd94307
Compare
dd94307 to
5a1fedc
Compare
Replace explicit `any` casts and annotations across 16 UI unit test and mock files with concrete Angular Router, ECharts, ComponentFixture, Subject, and proto types, using `ArtifactsList` bracket access in `artifacts_list_test.ts`. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
Remove `@typescript-eslint/no-explicit-any: 'off'` from the broad test override in `cmd/ui/eslint.config.js` so `any` cannot be reintroduced into UI tests, mocks, harnesses, or screenshot specs in PR #1671, narrow the legacy override to `**/app/testing/test.ts` and `**/app/protos/*.d.ts`, and replace `any` in `cmd/ui/app/testing/testing.d.ts` with `unknown`. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
…test Address PR #1671 review feedback (`4590818105`, `4590818117`) by typing `markLineData` as `| undefined` and asserting `markLineData?.[0]?.yAxis` in `scatter_options_builder_test.ts`. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
5a1fedc to
2646abf
Compare
Summary
Replace explicit
anycasts and annotations across 16 UI unit test/mock files andcmd/ui/app/testing/testing.d.tswith concrete Angular Router, ECharts, ComponentFixture, Subject,unknown, and proto types, and remove'@typescript-eslint/no-explicit-any': 'off'from the test/mock ESLint override incmd/ui/eslint.config.jsso explicitanyis immediately enforced as an error.Motivation & Context
Removing
anywithout enabling the lint rule leaves unit tests and mocks open to regressions. Enforcing@typescript-eslint/no-explicit-anydirectly incmd/ui/eslint.config.jslocks down all*_test.ts,*.spec.ts,mock_*.ts,screenshot_tests/**, component/servicetesting/harnesses, andtesting.d.tsagainst silent type drift.Key Changes
Modified 18 file(s):
cmd/ui/eslint.config.js: Remove'@typescript-eslint/no-explicit-any': 'off'from the general test/mock/screenshot override and restrict the exemption strictly to['**/app/testing/test.ts', '**/app/protos/*.d.ts'].cmd/ui/app/testing/testing.d.ts: ReplaceanywithunknownonAsyncMatchers.toEmitandtoEmitSequence.cmd/ui/app/admin_panel.guard_test.tscmd/ui/app/admin_panel/admin_panel_test.tscmd/ui/app/auth.guard_test.tscmd/ui/app/common/components/artifacts_list/artifacts_list_test.tscmd/ui/app/common/components/dashboard/bar_options_builder_test.tscmd/ui/app/common/components/dashboard/echarts_options_builder_test.tscmd/ui/app/common/components/dashboard/scatter_options_builder_test.tscmd/ui/app/common/components/loading_bar/loading_bar_test.tscmd/ui/app/common/mock_data.tscmd/ui/app/guest.guard_test.tscmd/ui/app/pages/dashboards/dashboards_page_test.tscmd/ui/app/performance_dashboard.guard_test.tscmd/ui/app/resource_dashboard.guard_test.tscmd/ui/app/service/dashboard_normalizer_test.tscmd/ui/app/service/testing/mock_health_service.tscmd/ui/app/side_panel/contents/queue_jobs_table/queue_jobs_pipes_test.tsAssumptions
as unknown as <Type>only on intentionally partial proto mocks preserves strict static checking without requiring dummy fields for optional nested submessages — verified by bothtsconfig.jsonandtsconfig.spec.json— any future proto break triggers a compile error.'@typescript-eslint/no-explicit-any': 'off'scoped tocmd/ui/app/testing/test.tsandcmd/ui/app/protos/*.d.tsdoes not expose tests or mocks to regressions — it preserves existing Angularbootstrap()/cleanState()/get()test helper ergonomics and proto stub declarations without rewriting 44 test callers or generated.d.tsfiles — if new code is added totest.tsor new proto.d.tsfiles, explicitanyremains allowed there until those files are typed cleanly.Verification & Testing
npx prettier --check eslint.config.js app/testing/testing.d.ts,npm run lint(eslint .+ root-cwdeslintcheck),npx tsc -p tsconfig.json --noEmit,npx tsc -p tsconfig.spec.json --noEmit,bazel test --test_output=errors //cmd/ui:ui_unit_tests,./.githooks/pre-commiton commit, andpython3 ./tools/analyze_diff_size.py --base-ref refactor/fix-ui-templates-and-unused-lint.//cmd/ui:ui_unit_tests(Karma), Prettier, ESLint (with@typescript-eslint/no-explicit-anyenabled across UI tests/mocks/harnesses/testing.d.ts), and bothtscbuilds passed; diff size is6prod lines /159test lines (165total,threshold_exceeded: false).Related Issues / Bugs
N/A
TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c