Skip to content

Commit 43d5ced

Browse files
committed
refactor(lint): 用类型收窄替代非空断言
`quoteSource(source!)` 改为在 `if (source && syntaxFault)` 内由编译器收窄, 去掉本文件注释自己反对的 `!` 断言。行为不变。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3
1 parent 200126c commit 43d5ced

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/lint/src/validate-visibility-predicates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,15 +565,15 @@ function checkElement(
565565
// fault (ADR-0032 via `validateExpression`); this surface is the one that had
566566
// no such gate, so a `===` shipped clean and then failed OPEN in the console.
567567
const syntaxFault = source ? celSyntaxFault(source) : null;
568-
if (syntaxFault) {
568+
if (source && syntaxFault) {
569569
findings.push({
570570
severity: 'error',
571571
rule: VISIBILITY_PREDICATE_SYNTAX,
572572
where,
573573
path,
574574
message:
575575
`visibility predicate is not valid CEL — ${syntaxFault.detail} ` +
576-
`(predicate: \`${quoteSource(source!)}\`). A predicate that does not parse can never ` +
576+
`(predicate: \`${quoteSource(source)}\`). A predicate that does not parse can never ` +
577577
`evaluate, and the console falls OPEN: the element renders unconditionally and looks ` +
578578
`exactly like one with no predicate at all (#5149).`,
579579
hint: syntaxFault.token

0 commit comments

Comments
 (0)