@ttsc/lint 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/go.mod +2 -2
- package/linthost/ast_helpers.go +2 -2
- package/linthost/base_chain_walk_crosses_generic_boundary_test.go +3 -3
- package/linthost/check_observations.go +14 -14
- package/linthost/check_observations_retains_failed_program_and_raw_inputs_test.go +3 -2
- package/linthost/command_check_preserves_compiler_argument_cwd_test.go +2 -2
- package/linthost/comment_scan_handles_malformed_parser_recovery_test.go +2 -1
- package/linthost/comment_scan_uses_parser_lexical_ranges_across_source_modes_test.go +2 -1
- package/linthost/compile.go +5 -8
- package/linthost/config.go +4 -2
- package/linthost/config_loader_sources_escape_every_literal_percent_test.go +2 -1
- package/linthost/contributor_diagnostic_ranges_are_bounded_test.go +19 -19
- package/linthost/contributor_range_fix_bounds_diagnostic_independently_from_edit_test.go +2 -2
- package/linthost/contributor_report_related_reaches_finding_test.go +1 -1
- package/linthost/engine.go +1 -1
- package/linthost/engine_quarantines_panicking_rule_per_file_test.go +4 -4
- package/linthost/engine_run_parallel_matches_serial_finding_set_test.go +1 -1
- package/linthost/fix.go +1 -1
- package/linthost/helpers_test.go +5 -4
- package/linthost/host.go +130 -52
- package/linthost/imported_tsx_source_joins_the_read_scope_test.go +1 -1
- package/linthost/input_observation.go +24 -27
- package/linthost/invalid_contributor_range_cannot_panic_inline_directive_filtering_test.go +1 -1
- package/linthost/lint_corpus_filename_separators_share_materialized_source_identity_test.go +1 -1
- package/linthost/load_config_resolver_compact_globs_preserve_entry_policy_test.go +2 -2
- package/linthost/load_program_keeps_checker_pool_for_type_aware_rules_test.go +4 -4
- package/linthost/lsp.go +10 -5
- package/linthost/no_floating_promises_javascript_generic_defaults_test.go +1 -1
- package/linthost/no_floating_promises_rejects_inapplicable_generic_receiver_branches_test.go +1 -1
- package/linthost/project_engine.go +1 -1
- package/linthost/project_rule_sources_apply_only_global_ignores_test.go +1 -1
- package/linthost/project_rule_sources_include_imported_sibling_source_test.go +2 -2
- package/linthost/project_source_files_follow_tsconfig_selection_test.go +2 -2
- package/linthost/project_source_selection_preserves_explicit_bundled_roots_test.go +6 -5
- package/linthost/resident_whole_corpus_matches_cold_load_test.go +1 -1
- package/linthost/rules_boundaries.go +7 -7
- package/linthost/rules_boundaries_dependencies.go +9 -9
- package/linthost/rules_format_declaration_header.go +11 -4
- package/linthost/rules_gap.go +1 -1
- package/linthost/rules_jsdoc.go +1 -1
- package/linthost/rules_logic.go +2 -2
- package/linthost/rules_nextjs.go +1 -1
- package/linthost/rules_no_loop_func.go +4 -4
- package/linthost/rules_no_promise_executor_return.go +1 -1
- package/linthost/rules_promise.go +16 -16
- package/linthost/rules_react_perf.go +1 -1
- package/linthost/rules_react_refresh.go +2 -2
- package/linthost/rules_security.go +4 -4
- package/linthost/rules_storybook.go +1 -1
- package/linthost/rules_testing_library.go +1 -1
- package/linthost/rules_ts_no_base_to_string.go +1 -1
- package/linthost/rules_ts_no_deprecated.go +3 -3
- package/linthost/rules_ts_no_unnecessary_qualifier.go +4 -4
- package/linthost/rules_ts_no_unnecessary_type_arguments.go +2 -2
- package/linthost/rules_ts_no_unsafe_assignment.go +1 -1
- package/linthost/rules_ts_no_unsafe_enum_comparison.go +1 -1
- package/linthost/rules_ts_prefer_readonly.go +1 -1
- package/linthost/rules_ts_switch_exhaustiveness_check.go +2 -2
- package/linthost/rules_ts_unbound_method.go +1 -1
- package/linthost/rules_unicorn_consistent_destructuring.go +2 -2
- package/linthost/rules_unicorn_consistent_existence_index_check.go +2 -2
- package/linthost/rules_unicorn_consistent_function_scoping.go +7 -7
- package/linthost/rules_unicorn_filename_case.go +1 -1
- package/linthost/rules_unicorn_isolated_functions.go +3 -3
- package/linthost/rules_unicorn_no_typeof_undefined.go +1 -1
- package/linthost/rules_unicorn_no_unnecessary_polyfills.go +1 -1
- package/linthost/rules_unicorn_no_unused_properties.go +3 -3
- package/linthost/rules_unicorn_prefer_number_properties.go +1 -1
- package/linthost/rules_unicorn_prefer_simple_condition_first.go +1 -1
- package/linthost/rules_unicorn_prevent_abbreviations.go +7 -7
- package/linthost/rules_var.go +1 -1
- package/linthost/solid_helpers_test.go +1 -1
- package/linthost/type_alias_reference_node_uses_borrowed_builder_context_test.go +2 -2
- package/linthost/type_instantiation_mappers_reach_runtime_endpoints_test.go +3 -3
- package/linthost/user_source_files_exclude_imported_declarations_and_javascript_test.go +2 -2
- package/linthost/user_source_files_span_program_typescript_sources_test.go +1 -1
- package/linthost/windows_project_source_selection_preserves_physical_aliases_test.go +5 -4
- package/package.json +2 -2
|
@@ -88,7 +88,7 @@ func preferReadonlyRecordTarget(ctx *Context, target *shimast.Node, written map[
|
|
|
88
88
|
}
|
|
89
89
|
record := func(symbol *shimast.Symbol) {
|
|
90
90
|
if symbol != nil {
|
|
91
|
-
for _, decl := range symbol
|
|
91
|
+
for _, decl := range shimast.SymbolDeclarationsOf(symbol) {
|
|
92
92
|
if decl != nil && decl.Kind == shimast.KindPropertyDeclaration {
|
|
93
93
|
written[decl] = true
|
|
94
94
|
}
|
|
@@ -362,8 +362,8 @@ func switchExhaustivenessCheckTypeName(
|
|
|
362
362
|
if name := shimchecker.Checker_symbolToValueString(checker, symbol, location); name != "" {
|
|
363
363
|
return "typeof " + name
|
|
364
364
|
}
|
|
365
|
-
if symbol
|
|
366
|
-
return "typeof " + symbol
|
|
365
|
+
if shimast.SymbolNameOf(symbol) != "" {
|
|
366
|
+
return "typeof " + shimast.SymbolNameOf(symbol)
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
}
|
|
@@ -106,7 +106,7 @@ func unboundMethodSymbolIsClassMethod(symbol *shimast.Symbol) bool {
|
|
|
106
106
|
if symbol == nil {
|
|
107
107
|
return false
|
|
108
108
|
}
|
|
109
|
-
for _, decl := range symbol
|
|
109
|
+
for _, decl := range shimast.SymbolDeclarationsOf(symbol) {
|
|
110
110
|
if decl == nil {
|
|
111
111
|
continue
|
|
112
112
|
}
|
|
@@ -612,8 +612,8 @@ func (s *unicornConsistentDestructuringState) resolveValueSymbol(
|
|
|
612
612
|
if symbol == nil {
|
|
613
613
|
return nil
|
|
614
614
|
}
|
|
615
|
-
if symbol
|
|
616
|
-
symbol = symbol
|
|
615
|
+
if shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsExportValue != 0 && shimast.SymbolExportSymbolOf(symbol) != nil {
|
|
616
|
+
symbol = shimast.SymbolExportSymbolOf(symbol)
|
|
617
617
|
}
|
|
618
618
|
return s.ctx.Checker.GetMergedSymbol(symbol)
|
|
619
619
|
}
|
|
@@ -197,10 +197,10 @@ func unicornConsistentExistenceIndexCheckIsIndexBinding(
|
|
|
197
197
|
identifier *shimast.Node,
|
|
198
198
|
) bool {
|
|
199
199
|
symbol := canonicalValueSymbol(ctx, identifier)
|
|
200
|
-
if symbol == nil || symbol
|
|
200
|
+
if symbol == nil || shimast.SymbolValueDeclarationOf(symbol) == nil {
|
|
201
201
|
return false
|
|
202
202
|
}
|
|
203
|
-
declaration := symbol
|
|
203
|
+
declaration := shimast.SymbolValueDeclarationOf(symbol)
|
|
204
204
|
if declaration.Kind != shimast.KindVariableDeclaration ||
|
|
205
205
|
declaration.Parent == nil ||
|
|
206
206
|
declaration.Parent.Kind != shimast.KindVariableDeclarationList {
|
|
@@ -168,7 +168,7 @@ func unicornConsistentFunctionScopingIsImplicitArguments(
|
|
|
168
168
|
symbol *shimast.Symbol,
|
|
169
169
|
) bool {
|
|
170
170
|
return node.Kind == shimast.KindIdentifier && identifierText(node) == "arguments" &&
|
|
171
|
-
symbol
|
|
171
|
+
shimast.SymbolValueDeclarationOf(symbol) == nil && len(shimast.SymbolDeclarationsOf(symbol)) == 0
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
func (analysis *unicornConsistentFunctionScopingAnalysis) isReference(node *shimast.Node) bool {
|
|
@@ -244,10 +244,10 @@ func unicornConsistentFunctionScopingIsDeclarationName(
|
|
|
244
244
|
if node == nil || symbol == nil {
|
|
245
245
|
return false
|
|
246
246
|
}
|
|
247
|
-
if declaration := symbol
|
|
247
|
+
if declaration := shimast.SymbolValueDeclarationOf(symbol); declaration != nil && declaration.Name() == node {
|
|
248
248
|
return true
|
|
249
249
|
}
|
|
250
|
-
for _, declaration := range symbol
|
|
250
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
251
251
|
if declaration != nil && declaration.Name() == node {
|
|
252
252
|
return true
|
|
253
253
|
}
|
|
@@ -340,10 +340,10 @@ func unicornConsistentFunctionScopingSymbolDeclaredInside(
|
|
|
340
340
|
if symbol == nil || function == nil {
|
|
341
341
|
return false
|
|
342
342
|
}
|
|
343
|
-
if symbol
|
|
343
|
+
if shimast.SymbolValueDeclarationOf(symbol) != nil && noLoopFuncNodeContains(function, shimast.SymbolValueDeclarationOf(symbol)) {
|
|
344
344
|
return true
|
|
345
345
|
}
|
|
346
|
-
for _, declaration := range symbol
|
|
346
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
347
347
|
if declaration != nil && noLoopFuncNodeContains(function, declaration) {
|
|
348
348
|
return true
|
|
349
349
|
}
|
|
@@ -358,10 +358,10 @@ func unicornConsistentFunctionScopingSymbolDeclaredInScopes(
|
|
|
358
358
|
if symbol == nil {
|
|
359
359
|
return false
|
|
360
360
|
}
|
|
361
|
-
if unicornConsistentFunctionScopingDeclarationPins(symbol
|
|
361
|
+
if unicornConsistentFunctionScopingDeclarationPins(shimast.SymbolValueDeclarationOf(symbol), scopes) {
|
|
362
362
|
return true
|
|
363
363
|
}
|
|
364
|
-
for _, declaration := range symbol
|
|
364
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
365
365
|
if unicornConsistentFunctionScopingDeclarationPins(declaration, scopes) {
|
|
366
366
|
return true
|
|
367
367
|
}
|
|
@@ -242,7 +242,7 @@ func (unicornFilenameCase) Check(ctx *Context, _ *shimast.Node) {
|
|
|
242
242
|
caseFunctions = append(caseFunctions, unicornFilenameCaseFunction(chosen))
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
segments := unicornFilenameCasePathSegments(ctx.CurrentDirectory, fileName)
|
|
245
|
+
segments := unicornFilenameCasePathSegments(ctx.CurrentDirectory, string(fileName))
|
|
246
246
|
for _, segment := range segments {
|
|
247
247
|
for _, pattern := range options.ignore {
|
|
248
248
|
if pattern.MatchString(segment) {
|
|
@@ -629,7 +629,7 @@ func (a *unicornIsolatedFunctionsAnalysis) checkReference(
|
|
|
629
629
|
} else {
|
|
630
630
|
symbol = canonicalValueSymbol(a.ctx, identifier)
|
|
631
631
|
if symbol != nil {
|
|
632
|
-
for _, declaration := range symbol
|
|
632
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
633
633
|
if declaration != nil && declaration != function &&
|
|
634
634
|
declaration.Pos() >= function.Pos() && declaration.End() <= function.End() {
|
|
635
635
|
return
|
|
@@ -674,10 +674,10 @@ func (a *unicornIsolatedFunctionsAnalysis) checkReference(
|
|
|
674
674
|
// top-level bindings resolve globally but are real source declarations, so
|
|
675
675
|
// they stay reported like upstream's script-mode captures.
|
|
676
676
|
func unicornIsolatedFunctionsIsAmbientGlobal(ctx *Context, name string, symbol *shimast.Symbol) bool {
|
|
677
|
-
if len(symbol
|
|
677
|
+
if len(shimast.SymbolDeclarationsOf(symbol)) == 0 {
|
|
678
678
|
return true
|
|
679
679
|
}
|
|
680
|
-
for _, declaration := range symbol
|
|
680
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
681
681
|
if declaration == nil {
|
|
682
682
|
return false
|
|
683
683
|
}
|
|
@@ -184,7 +184,7 @@ func unicornNoTypeofUndefinedIsGlobal(ctx *Context, operand *shimast.Node) bool
|
|
|
184
184
|
if symbol == nil {
|
|
185
185
|
return true
|
|
186
186
|
}
|
|
187
|
-
for _, declaration := range symbol
|
|
187
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
188
188
|
if declaration == nil {
|
|
189
189
|
continue
|
|
190
190
|
}
|
|
@@ -209,7 +209,7 @@ func unicornNoUnnecessaryPolyfillsSpecifier(node *shimast.Node) *shimast.Node {
|
|
|
209
209
|
// no targets resolve, which silences the rule like upstream's early returns
|
|
210
210
|
// and catch blocks.
|
|
211
211
|
func unicornNoUnnecessaryPolyfillsUnavailableSet(ctx *Context, options unicornNoUnnecessaryPolyfillsOptions) (map[string]struct{}, bool) {
|
|
212
|
-
dirname := filepath.Dir(ctx.File.FileName())
|
|
212
|
+
dirname := filepath.Dir(string(ctx.File.FileName()))
|
|
213
213
|
browserslistOptions := browserslistOpts{path: dirname, env: "production"}
|
|
214
214
|
|
|
215
215
|
var targets interface{}
|
|
@@ -206,7 +206,7 @@ func unusedPropertiesCollectReferences(
|
|
|
206
206
|
names := make(map[string]struct{}, len(candidates))
|
|
207
207
|
for _, candidate := range candidates {
|
|
208
208
|
symbol := unusedPropertiesDeclaredSymbol(ctx, candidate)
|
|
209
|
-
if symbol == nil || len(symbol
|
|
209
|
+
if symbol == nil || len(shimast.SymbolDeclarationsOf(symbol)) != 1 || bySymbol[symbol] != nil {
|
|
210
210
|
candidate.container = nil
|
|
211
211
|
continue
|
|
212
212
|
}
|
|
@@ -286,8 +286,8 @@ func unusedPropertiesSymbolAtIdentifier(
|
|
|
286
286
|
if symbol == nil {
|
|
287
287
|
return nil
|
|
288
288
|
}
|
|
289
|
-
if symbol
|
|
290
|
-
symbol = symbol
|
|
289
|
+
if shimast.SymbolFlagsOf(symbol)&shimast.SymbolFlagsExportValue != 0 && shimast.SymbolExportSymbolOf(symbol) != nil {
|
|
290
|
+
symbol = shimast.SymbolExportSymbolOf(symbol)
|
|
291
291
|
}
|
|
292
292
|
return ctx.Checker.GetMergedSymbol(symbol)
|
|
293
293
|
}
|
|
@@ -206,7 +206,7 @@ func unicornPreferNumberPropertiesResolvesGlobal(ctx *Context, node *shimast.Nod
|
|
|
206
206
|
if resolved != global {
|
|
207
207
|
return false
|
|
208
208
|
}
|
|
209
|
-
for _, declaration := range resolved
|
|
209
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(resolved) {
|
|
210
210
|
if declaration != nil &&
|
|
211
211
|
shimast.GetSourceFileOfNode(declaration) == ctx.File &&
|
|
212
212
|
unicornPreferNumberPropertiesDeclarationIntroducesValue(declaration) {
|
|
@@ -372,7 +372,7 @@ func unicornPreferSimpleConditionFirstIsGlobalBooleanCall(
|
|
|
372
372
|
if resolved != global {
|
|
373
373
|
return false
|
|
374
374
|
}
|
|
375
|
-
for _, declaration := range resolved
|
|
375
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(resolved) {
|
|
376
376
|
if declaration != nil && shimast.GetSourceFileOfNode(declaration) == ctx.File &&
|
|
377
377
|
unicornPreferSimpleConditionFirstDeclarationIntroducesValue(declaration) {
|
|
378
378
|
return false
|
|
@@ -572,7 +572,7 @@ func collectUnicornPreventAbbreviationsBindings(
|
|
|
572
572
|
bindings = append(bindings, binding)
|
|
573
573
|
bySymbol[symbol] = binding
|
|
574
574
|
byDeclaration[node] = binding
|
|
575
|
-
for _, declaration := range symbol
|
|
575
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
576
576
|
byDeclaration[declaration] = binding
|
|
577
577
|
}
|
|
578
578
|
})
|
|
@@ -918,7 +918,7 @@ func collectUnicornPreventAbbreviationsReferences(
|
|
|
918
918
|
}
|
|
919
919
|
binding := bySymbol[symbol]
|
|
920
920
|
if binding == nil {
|
|
921
|
-
for _, declaration := range symbol
|
|
921
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
922
922
|
if candidate := byDeclaration[declaration]; candidate != nil {
|
|
923
923
|
binding = candidate
|
|
924
924
|
break
|
|
@@ -1168,7 +1168,7 @@ func unicornPreventAbbreviationsCanRenameBinding(
|
|
|
1168
1168
|
if binding == nil || len(binding.references) == 0 || unicornPreventAbbreviationsBindingIsExternallyVisible(ctx, binding) {
|
|
1169
1169
|
return false
|
|
1170
1170
|
}
|
|
1171
|
-
if strings.EqualFold(filepath.Ext(ctx.File.FileName()), ".vue") {
|
|
1171
|
+
if strings.EqualFold(filepath.Ext(string(ctx.File.FileName())), ".vue") {
|
|
1172
1172
|
return false
|
|
1173
1173
|
}
|
|
1174
1174
|
parameter := unicornPreventAbbreviationsEnclosingParameter(binding.declaration)
|
|
@@ -1196,9 +1196,9 @@ func unicornPreventAbbreviationsBindingIsExternallyVisible(
|
|
|
1196
1196
|
if ctx == nil || ctx.File == nil || binding == nil || binding.symbol == nil || ctx.File.IsDeclarationFile {
|
|
1197
1197
|
return true
|
|
1198
1198
|
}
|
|
1199
|
-
declarations := make([]*shimast.Node, 0, len(binding.symbol
|
|
1199
|
+
declarations := make([]*shimast.Node, 0, len(shimast.SymbolDeclarationsOf(binding.symbol))+1)
|
|
1200
1200
|
declarations = append(declarations, binding.declaration)
|
|
1201
|
-
declarations = append(declarations, binding.symbol
|
|
1201
|
+
declarations = append(declarations, shimast.SymbolDeclarationsOf(binding.symbol)...)
|
|
1202
1202
|
seen := make(map[*shimast.Node]struct{}, len(declarations))
|
|
1203
1203
|
for _, declaration := range declarations {
|
|
1204
1204
|
if declaration == nil {
|
|
@@ -1704,10 +1704,10 @@ func reportUnicornPreventAbbreviationsFilename(
|
|
|
1704
1704
|
options unicornPreventAbbreviationsOptions,
|
|
1705
1705
|
) {
|
|
1706
1706
|
filenameWithPath := ctx.File.FileName()
|
|
1707
|
-
if filenameWithPath == "" || unicornPreventAbbreviationsIsVirtualFilename(filenameWithPath) {
|
|
1707
|
+
if filenameWithPath == "" || unicornPreventAbbreviationsIsVirtualFilename(string(filenameWithPath)) {
|
|
1708
1708
|
return
|
|
1709
1709
|
}
|
|
1710
|
-
filename := filepath.Base(filenameWithPath)
|
|
1710
|
+
filename := filepath.Base(string(filenameWithPath))
|
|
1711
1711
|
extension := unicornPreventAbbreviationsFilenameExtension(filename)
|
|
1712
1712
|
basename := strings.TrimSuffix(filename, extension)
|
|
1713
1713
|
replacements := getUnicornPreventAbbreviationsNameReplacements(basename, options, 3)
|
package/linthost/rules_var.go
CHANGED
|
@@ -970,7 +970,7 @@ func preferConstSymbolIsLocalToScope(symbol *shimast.Symbol, scope *shimast.Node
|
|
|
970
970
|
if symbol == nil || scope == nil {
|
|
971
971
|
return false
|
|
972
972
|
}
|
|
973
|
-
for _, declaration := range symbol
|
|
973
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
974
974
|
if preferConstDeclarationScope(declaration) == scope {
|
|
975
975
|
return true
|
|
976
976
|
}
|
|
@@ -61,7 +61,7 @@ func assertSolidCheckerFindings(
|
|
|
61
61
|
t.Fatalf("user source files = %d, want 1", len(files))
|
|
62
62
|
}
|
|
63
63
|
wanted := filepath.ToSlash(filepath.Join("src", fileName))
|
|
64
|
-
if got := filepath.ToSlash(files[0].FileName()); !strings.HasSuffix(got, wanted) {
|
|
64
|
+
if got := filepath.ToSlash(string(files[0].FileName())); !strings.HasSuffix(got, wanted) {
|
|
65
65
|
t.Fatalf("user source file = %q, want one ending in %q", got, wanted)
|
|
66
66
|
}
|
|
67
67
|
assertSolidExpectations(t, files[0], program.runLintCycle(engine), expected)
|
|
@@ -48,10 +48,10 @@ func TestTypeAliasReferenceNodeUsesBorrowedBuilderContext(t *testing.T) {
|
|
|
48
48
|
t.Fatal("Pair<string> alias metadata missing")
|
|
49
49
|
}
|
|
50
50
|
alias := value.Alias()
|
|
51
|
-
if alias.Symbol() == nil || alias.Symbol()
|
|
51
|
+
if alias.Symbol() == nil || shimast.SymbolNameOf(alias.Symbol()) != "Pair" || len(alias.TypeArguments()) != 1 || prog.checker.TypeToString(alias.TypeArguments()[0]) != "string" {
|
|
52
52
|
t.Fatal("authored alias identity or argument missing")
|
|
53
53
|
}
|
|
54
|
-
enclosing := classSymbol(t, prog, "Holder")
|
|
54
|
+
enclosing := shimast.SymbolDeclarationsOf(classSymbol(t, prog, "Holder"))[0]
|
|
55
55
|
emit := shimprinter.NewEmitContext()
|
|
56
56
|
assertReference := func(node *shimast.Node) {
|
|
57
57
|
t.Helper()
|
|
@@ -189,7 +189,7 @@ func declaredClassTypeParameters(
|
|
|
189
189
|
symbol *shimast.Symbol,
|
|
190
190
|
) []*shimchecker.Type {
|
|
191
191
|
t.Helper()
|
|
192
|
-
for _, declaration := range symbol
|
|
192
|
+
for _, declaration := range shimast.SymbolDeclarationsOf(symbol) {
|
|
193
193
|
if declaration == nil ||
|
|
194
194
|
(declaration.Kind != shimast.KindClassDeclaration && declaration.Kind != shimast.KindClassExpression) {
|
|
195
195
|
continue
|
|
@@ -202,12 +202,12 @@ func declaredClassTypeParameters(
|
|
|
202
202
|
}
|
|
203
203
|
typ := checker.GetTypeAtLocation(node)
|
|
204
204
|
if typ == nil {
|
|
205
|
-
t.Fatalf("GetTypeAtLocation returned nil for a type parameter of %s", symbol
|
|
205
|
+
t.Fatalf("GetTypeAtLocation returned nil for a type parameter of %s", shimast.SymbolNameOf(symbol))
|
|
206
206
|
}
|
|
207
207
|
result = append(result, typ)
|
|
208
208
|
}
|
|
209
209
|
return result
|
|
210
210
|
}
|
|
211
|
-
t.Fatalf("class declaration for %q not found", symbol
|
|
211
|
+
t.Fatalf("class declaration for %q not found", shimast.SymbolNameOf(symbol))
|
|
212
212
|
return nil
|
|
213
213
|
}
|
|
@@ -52,7 +52,7 @@ func TestUserSourceFilesExcludeImportedDeclarationsAndJavaScript(t *testing.T) {
|
|
|
52
52
|
defer prog.close()
|
|
53
53
|
imported := map[string]int{"src/helper.js": 0, "src/shapes.d.ts": 0}
|
|
54
54
|
for _, file := range prog.tsProgram.SourceFiles() {
|
|
55
|
-
name := filepath.ToSlash(filepath.Clean(file.FileName()))
|
|
55
|
+
name := filepath.ToSlash(filepath.Clean(string(file.FileName())))
|
|
56
56
|
for expected := range imported {
|
|
57
57
|
if name == filepath.ToSlash(filepath.Join(root, expected)) {
|
|
58
58
|
imported[expected]++
|
|
@@ -67,7 +67,7 @@ func TestUserSourceFilesExcludeImportedDeclarationsAndJavaScript(t *testing.T) {
|
|
|
67
67
|
|
|
68
68
|
names := make([]string, 0)
|
|
69
69
|
for _, file := range prog.userSourceFiles() {
|
|
70
|
-
rel, err := filepath.Rel(root, file.FileName())
|
|
70
|
+
rel, err := filepath.Rel(root, string(file.FileName()))
|
|
71
71
|
if err != nil {
|
|
72
72
|
t.Fatal(err)
|
|
73
73
|
}
|
|
@@ -57,7 +57,7 @@ func TestUserSourceFilesSpanProgramTypeScriptSources(t *testing.T) {
|
|
|
57
57
|
|
|
58
58
|
names := make([]string, 0)
|
|
59
59
|
for _, file := range prog.userSourceFiles() {
|
|
60
|
-
rel, err := filepath.Rel(root, file.FileName())
|
|
60
|
+
rel, err := filepath.Rel(root, string(file.FileName()))
|
|
61
61
|
if err != nil {
|
|
62
62
|
t.Fatal(err)
|
|
63
63
|
}
|
|
@@ -6,6 +6,7 @@ import (
|
|
|
6
6
|
"path/filepath"
|
|
7
7
|
"testing"
|
|
8
8
|
|
|
9
|
+
shimtspath "github.com/microsoft/typescript-go/shim/tspath"
|
|
9
10
|
"github.com/samchon/ttsc/packages/ttsc/driver/windowsjunction"
|
|
10
11
|
)
|
|
11
12
|
|
|
@@ -32,16 +33,16 @@ func TestWindowsProjectSourceSelectionPreservesPhysicalAliases(t *testing.T) {
|
|
|
32
33
|
t.Fatalf("load: err=%v diagnostics=%v", err, diags)
|
|
33
34
|
}
|
|
34
35
|
defer prog.close()
|
|
35
|
-
configured := prog.tsProgram.GetSourceFile(filepath.ToSlash(filepath.Join(root, "owned", "main.ts")))
|
|
36
|
-
imported := prog.tsProgram.GetSourceFile(filepath.ToSlash(filepath.Join(root, "alias", "main.ts")))
|
|
36
|
+
configured := prog.tsProgram.GetSourceFile(shimtspath.RootedFilePath(filepath.ToSlash(filepath.Join(root, "owned", "main.ts"))))
|
|
37
|
+
imported := prog.tsProgram.GetSourceFile(shimtspath.RootedFilePath(filepath.ToSlash(filepath.Join(root, "alias", "main.ts"))))
|
|
37
38
|
if configured == nil || imported == nil || configured == imported {
|
|
38
39
|
t.Fatal("fixture must load distinct configured and imported AST spellings")
|
|
39
40
|
}
|
|
40
41
|
roots := prog.projectSourceFileNames()
|
|
41
|
-
if _, direct := roots[canonicalProjectPath(root, imported.FileName())]; direct {
|
|
42
|
+
if _, direct := roots[canonicalProjectPath(root, string(imported.FileName()))]; direct {
|
|
42
43
|
t.Fatal("alternate spelling must exercise physical fallback, not direct lookup")
|
|
43
44
|
}
|
|
44
|
-
if !prog.selectedByProject(roots, imported.FileName()) {
|
|
45
|
+
if !prog.selectedByProject(roots, string(imported.FileName())) {
|
|
45
46
|
t.Error("physical alias lost selected-file ownership")
|
|
46
47
|
}
|
|
47
48
|
if prog.selectedByProject(roots, filepath.Join(root, "outside.ts")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttsc/lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Reference ttsc plugin: ESLint-style lint rules over the TypeScript-Go Program used by the type-check pass.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/node": "^25.3.0",
|
|
39
39
|
"rimraf": "^6.1.2",
|
|
40
40
|
"typescript": "^7.0.2",
|
|
41
|
-
"ttsc": "0.
|
|
41
|
+
"ttsc": "0.34.0"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|