chore(frontend): fix NG8113/NG8107 template diagnostics, add test, promote to errors#5985
Conversation
Automated Reviewer SuggestionsBased on the
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5985 +/- ##
============================================
- Coverage 56.23% 56.23% -0.01%
Complexity 2987 2987
============================================
Files 1120 1120
Lines 43167 43168 +1
Branches 4658 4657 -1
============================================
Hits 24274 24274
Misses 17472 17472
- Partials 1421 1422 +1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Two Angular extended-diagnostic warnings surfaced by the build: - NG8113: CardItemComponent listed NzWaveDirective in its standalone imports array but never used it in the template. Remove the unused import. - NG8107: computing-unit-selection.component.html used pve.name?.trim() where PveDraft.name is a non-nullable string, so the optional chaining is redundant. Extract the predicate into an isCreateDisabled(pve) component method bound via [disabled]="isCreateDisabled(pve)" and unit test it (empty / whitespace / valid / padded names). Closes apache#5984 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Set unusedStandaloneImports (NG8113) and optionalChainNotNullable (NG8107) to "error" so future regressions fail the prod build (build:ci) instead of emitting an easily-ignored warning. Placed in tsconfig.app.json rather than the base tsconfig because extendedDiagnostics requires strictTemplates, which the unit-test builds deliberately disable; tsconfig.test.json clears the inherited option to avoid NG4003. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31cc9e7 to
40724c2
Compare
There was a problem hiding this comment.
Pull request overview
This PR cleans up two remaining Angular extended-template diagnostic warnings in the frontend, adds unit coverage for the affected UI predicate, and upgrades both diagnostics to build errors so regressions fail CI during production builds.
Changes:
- Remove unused standalone
NzWaveDirectiveimport to resolve NG8113. - Replace redundant
pve.name?.trim()optional chaining in the template with a component predicateisCreateDisabled(pve)and add unit tests for name/whitespace handling (NG8107). - Promote
unusedStandaloneImportsandoptionalChainNotNullableextended diagnostics to"error"in the production app tsconfig, while explicitly clearing inherited diagnostics in the test build tsconfig.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/tsconfig.app.json | Enables/enforces the two extended diagnostics as build errors for production builds. |
| frontend/src/tsconfig.test.json | Clears inherited extendedDiagnostics for the test build that disables strictTemplates. |
| frontend/src/app/workspace/component/power-button/computing-unit-selection.component.ts | Introduces isCreateDisabled(pve) predicate used by the template. |
| frontend/src/app/workspace/component/power-button/computing-unit-selection.component.html | Switches [disabled] binding to isCreateDisabled(pve) to remove redundant optional chaining. |
| frontend/src/app/workspace/component/power-button/computing-unit-selection.component.spec.ts | Adds unit tests covering empty/whitespace/valid/padded names for isCreateDisabled. |
| frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.ts | Removes unused NzWaveDirective import/standalone inclusion to satisfy NG8113. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…omote to errors (apache#5985) ### What changes were proposed in this PR? Fix the two remaining Angular extended-diagnostic warnings surfaced by the frontend build, add a unit test for the affected logic, and promote both checks to build errors so regressions can't silently creep back in: - **NG8113** — `CardItemComponent` listed `NzWaveDirective` in its standalone `imports` array but never used it in the template. Removed the unused directive import. - **NG8107** — `computing-unit-selection.component.html` used `pve.name?.trim()`, but `PveDraft.name` is a non-nullable `string`, so the optional chaining is redundant. Extracted the predicate into an `isCreateDisabled(pve)` component method bound via `[disabled]="isCreateDisabled(pve)"`, and added unit tests covering empty / whitespace / valid / padded names (the create button stays disabled until the env name has non-whitespace content). - **Enforcement** — set `unusedStandaloneImports` (NG8113) and `optionalChainNotNullable` (NG8107) to `"error"` under `angularCompilerOptions.extendedDiagnostics.checks`. Placed in `tsconfig.app.json` (the prod build, `build:ci`) rather than the base tsconfig, because `extendedDiagnostics` requires `strictTemplates`, which the unit-test builds deliberately disable; `tsconfig.test.json` clears the inherited option to avoid `NG4003`. No runtime behavior change. ### Any related issues, documentation, discussions? Closes apache#5984 ### How was this PR tested? - `ng test` (the affected spec): **46 passed**, including the 4 new `isCreateDisabled` cases. - `ng build`: succeeds with **0** NG8113/NG8107 diagnostics (now configured as errors) and produces the normal bundle. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What changes were proposed in this PR?
Fix the two remaining Angular extended-diagnostic warnings surfaced by the frontend build, add a unit test for the affected logic, and promote both checks to build errors so regressions can't silently creep back in:
CardItemComponentlistedNzWaveDirectivein its standaloneimportsarray but never used it in the template. Removed the unused directive import.computing-unit-selection.component.htmlusedpve.name?.trim(), butPveDraft.nameis a non-nullablestring, so the optional chaining is redundant. Extracted the predicate into anisCreateDisabled(pve)component method bound via[disabled]="isCreateDisabled(pve)", and added unit tests covering empty / whitespace / valid / padded names (the create button stays disabled until the env name has non-whitespace content).unusedStandaloneImports(NG8113) andoptionalChainNotNullable(NG8107) to"error"underangularCompilerOptions.extendedDiagnostics.checks. Placed intsconfig.app.json(the prod build,build:ci) rather than the base tsconfig, becauseextendedDiagnosticsrequiresstrictTemplates, which the unit-test builds deliberately disable;tsconfig.test.jsonclears the inherited option to avoidNG4003.No runtime behavior change.
Any related issues, documentation, discussions?
Closes #5984
How was this PR tested?
ng test(the affected spec): 46 passed, including the 4 newisCreateDisabledcases.ng build: succeeds with 0 NG8113/NG8107 diagnostics (now configured as errors) and produces the normal bundle.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)