Skip to content

Lint missing diagnostic formatting arguments - #65103

Merged
Ryan Cavanaugh (RyanCavanaugh) merged 8 commits into
mainfrom
copilot/fix-ts18000-circularity-error
Nov 2, 2026
Merged

Ryan Cavanaugh (RyanCavanaugh) merged 8 commits into
mainfrom
copilot/fix-ts18000-circularity-error

Conversation

Copilot AI commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

TS18000 leaves {0} unsubstituted because its diagnostic constructor receives no formatting arguments. This adds preventive linting without changing circular-config behavior.

  • Rule: Derive required argument counts from diagnostic text and check message, args... calls and localization methods. Allow extra arguments; skip unknown messages and expanded slices.
  • Coverage: Golden fixtures cover missing arguments, repeated and sparse placeholders, wrappers, and localization calls.
  • Scope: Narrow exclusions preserve the known circularity defect and an existing checker mismatch.

Copilot AI and others added 3 commits November 2, 2026 16:40
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
…pers

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TS18000 circularity message placeholder Lint missing diagnostic formatting arguments Nov 2, 2026
Comment thread .golangci.yml Resolved
@RyanCavanaugh

Copy link
Copy Markdown
Member

Copilot Fix the missing argument as described here

tsc/internal/checker/checker.go:9477:20: diagnosticargs: diagnostic Type_0_does_not_satisfy_the_constraint_1 requires at least 2 formatting arguments, got 0 (customlint)
diagnostic = ast.NewDiagnosticChain(diagnostic, diagnostics.Type_0_does_not_satisfy_the_constraint_1)

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
@RyanCavanaugh

Copy link
Copy Markdown
Member

Copilot you should be using a baseline test, not a unit test, for this change

Copilot AI commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Copilot Fix the missing argument as described here

tsc/internal/checker/checker.go:9477:20: diagnosticargs: diagnostic Type_0_does_not_satisfy_the_constraint_1 requires at least 2 formatting argum...

Fixed in e9f7e8c: the diagnostic now receives the type argument and instantiated constraint. Added a regression test that fails before the fix. All tests passed; validate --all now fails only on the separate, unchanged TS18000 circularity call.

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>

Copilot AI commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Copilot you should be using a baseline test, not a unit test, for this change

Replaced the unit test and test-only checker export with a compiler fixture and diagnostic/type/symbol baselines in 91eb495. Tests pass; npx hereby validate remains blocked only by the unchanged TS18000 circularity lint error.

@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) marked this pull request as ready for review November 2, 2026 20:38
Copilot AI balanced review requested due to automatic review settings November 2, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The lint rule misses missing formatting arguments in method-expression localization calls and named callback calls, leaving production usage patterns unchecked.

2 open issues
What changed in this PR

Adds preventive linting for missing diagnostic formatting arguments in the native TypeScript compiler and fixes argument formatting in a type-constraint diagnostic chain. Circular-config behavior remains unchanged.

Changes:

  • Registers an analyzer that derives required argument counts from diagnostic placeholders.
  • Adds golden fixtures for diagnostic calls, wrappers, and localization methods.
  • Supplies type and constraint arguments in the checker, with compiler regression coverage.
File Description
tsc/​testdata/​tests/​cases/​compiler/​typeArgumentConstraintDiagnostic.ts Adds type-constraint diagnostic cases.
tsc/​testdata/​baselines/​reference/​compiler/​typeArgumentConstraintDiagnostic.types Records inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​typeArgumentConstraintDiagnostic.symbols Records symbol bindings.
tsc/​testdata/​baselines/​reference/​compiler/​typeArgumentConstraintDiagnostic.errors.txt Records expected constraint errors.
tsc/​internal/​checker/​checker.go Supplies missing diagnostic formatting arguments.
tools/​customlint/​testdata/​internal/​diagnostics/​diagnostics.go.golden Records the diagnostic fixture baseline.
tools/​customlint/​testdata/​internal/​diagnostics/​diagnostics.go Defines diagnostic messages for lint tests.
tools/​customlint/​testdata/​diagnosticargs/​diagnosticargs.go.golden Records expected lint reports.
tools/​customlint/​testdata/​diagnosticargs/​diagnosticargs.go Exercises formatting-argument checks and exclusions.
tools/​customlint/​plugin.go Registers the new analyzer.
tools/​customlint/​diagnosticargs.go Implements diagnostic formatting-argument checks.

Review effort: Balanced

if call.Ellipsis.IsValid() {
return
}
signature, ok := pass.TypesInfo.TypeOf(call.Fun).(*types.Signature)
Comment on lines +133 to +136
if selection != nil && selection.Kind() == types.MethodVal &&
isDiagnosticMessage(selection.Recv()) && selector.Sel.Name == "Localize" {
check(call, selector.X, len(call.Args)-fixed)
}
@jakebailey

Copy link
Copy Markdown
Member

Copilot review will repeatedly come back with infinite lint rule tweaks; feel free to decide a stopping point and say "good enough"

@RyanCavanaugh

Copy link
Copy Markdown
Member

This found one true positive and zero false positives so that's my "good enough"

@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 988d468 Nov 2, 2026
35 checks passed
@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) deleted the copilot/fix-ts18000-circularity-error branch November 2, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TS18000 circularity message prints its {0} placeholder instead of the config chain

4 participants