@inthedark/dxlint 0.0.0-stage → 0.1.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.
Files changed (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -2
  3. package/bin/dxlint +15 -0
  4. package/bin/dxlint-linux-x64 +0 -0
  5. package/bin/dxlint-win32-x64.exe +0 -0
  6. package/package.json +29 -4
  7. package/rules/conventions.dx +34 -0
  8. package/rules/correctness.dx +33 -0
  9. package/rules/es-no-semi.dx +11 -0
  10. package/rules/format.dx +49 -0
  11. package/rules/recommended.dx +51 -0
  12. package/rules/suspicious.dx +31 -0
  13. package/rules/types.dx +21 -0
  14. package/std/c.dx +23 -0
  15. package/std/core/lines.dx +51 -0
  16. package/std/core/lists.dx +76 -0
  17. package/std/core.dx +30 -0
  18. package/std/css.dx +17 -0
  19. package/std/dx.dx +31 -0
  20. package/std/json.dx +104 -0
  21. package/std/markdown.dx +11 -0
  22. package/std/python.dx +21 -0
  23. package/std/rust/format.dx +316 -0
  24. package/std/rust.dx +34 -0
  25. package/std/toml.dx +19 -0
  26. package/std/ts/arithmetic.dx +87 -0
  27. package/std/ts/assertions.dx +477 -0
  28. package/std/ts/calls.dx +246 -0
  29. package/std/ts/comments.dx +10 -0
  30. package/std/ts/conditions.dx +531 -0
  31. package/std/ts/constants.dx +335 -0
  32. package/std/ts/deprecation.dx +185 -0
  33. package/std/ts/directives.dx +60 -0
  34. package/std/ts/effects.dx +219 -0
  35. package/std/ts/enums.dx +233 -0
  36. package/std/ts/expression-fixes.dx +67 -0
  37. package/std/ts/expressions.dx +270 -0
  38. package/std/ts/flow.dx +2 -0
  39. package/std/ts/format.dx +755 -0
  40. package/std/ts/globals.dx +106 -0
  41. package/std/ts/grammar.dx +488 -0
  42. package/std/ts/helpers.dx +102 -0
  43. package/std/ts/import-attributes.dx +88 -0
  44. package/std/ts/import-no-deprecated.dx +73 -0
  45. package/std/ts/indentation.dx +442 -0
  46. package/std/ts/jsx.dx +646 -0
  47. package/std/ts/layout/blocks.dx +281 -0
  48. package/std/ts/layout/calls.dx +79 -0
  49. package/std/ts/layout/expressions.dx +213 -0
  50. package/std/ts/layout/literals.dx +114 -0
  51. package/std/ts/layout/separators.dx +184 -0
  52. package/std/ts/layout/shared.dx +203 -0
  53. package/std/ts/layout/text.dx +142 -0
  54. package/std/ts/layout/types.dx +182 -0
  55. package/std/ts/layout.dx +9 -0
  56. package/std/ts/license.dx +54 -0
  57. package/std/ts/literal-text.dx +3 -0
  58. package/std/ts/literals.dx +95 -0
  59. package/std/ts/methods.dx +69 -0
  60. package/std/ts/modules.dx +268 -0
  61. package/std/ts/names.dx +348 -0
  62. package/std/ts/naming.dx +169 -0
  63. package/std/ts/narrowing.dx +96 -0
  64. package/std/ts/parentheses.dx +262 -0
  65. package/std/ts/precedence.dx +25 -0
  66. package/std/ts/problems/calls.dx +34 -0
  67. package/std/ts/problems/classes.dx +39 -0
  68. package/std/ts/problems/control-flow.dx +257 -0
  69. package/std/ts/problems/declarations.dx +67 -0
  70. package/std/ts/problems/duplicates.dx +70 -0
  71. package/std/ts/problems/expressions.dx +154 -0
  72. package/std/ts/problems/helpers.dx +22 -0
  73. package/std/ts/problems/imports.dx +43 -0
  74. package/std/ts/problems/non-null.dx +78 -0
  75. package/std/ts/problems/numeric-precision.dx +66 -0
  76. package/std/ts/problems/regexp.dx +66 -0
  77. package/std/ts/problems/statements.dx +36 -0
  78. package/std/ts/problems/typescript.dx +55 -0
  79. package/std/ts/problems/whitespace.dx +40 -0
  80. package/std/ts/problems.dx +20 -0
  81. package/std/ts/regex/checks.dx +249 -0
  82. package/std/ts/regex/findings.dx +209 -0
  83. package/std/ts/regex/grammar.dx +80 -0
  84. package/std/ts/regex/suggestions.dx +94 -0
  85. package/std/ts/regex/values.dx +378 -0
  86. package/std/ts/regex.dx +5 -0
  87. package/std/ts/restrictions/comments.dx +76 -0
  88. package/std/ts/restrictions.dx +811 -0
  89. package/std/ts/scopes.dx +68 -0
  90. package/std/ts/scoping/atomic.dx +40 -0
  91. package/std/ts/scoping/bindings.dx +126 -0
  92. package/std/ts/scoping/constness.dx +72 -0
  93. package/std/ts/scoping/globals.dx +52 -0
  94. package/std/ts/scoping/loops.dx +86 -0
  95. package/std/ts/scoping/member-uses.dx +111 -0
  96. package/std/ts/scoping/receivers.dx +107 -0
  97. package/std/ts/scoping/shadowing.dx +202 -0
  98. package/std/ts/scoping/usage.dx +393 -0
  99. package/std/ts/scoping.dx +842 -0
  100. package/std/ts/selectors.dx +10 -0
  101. package/std/ts/spreads.dx +97 -0
  102. package/std/ts/structure/declarations.dx +52 -0
  103. package/std/ts/structure/lines.dx +79 -0
  104. package/std/ts/structure/lists.dx +144 -0
  105. package/std/ts/structure/padding.dx +258 -0
  106. package/std/ts/structure.dx +963 -0
  107. package/std/ts/style/classes.dx +157 -0
  108. package/std/ts/style/comments.dx +75 -0
  109. package/std/ts/style/declarations.dx +82 -0
  110. package/std/ts/style/expressions.dx +125 -0
  111. package/std/ts/style/imports.dx +44 -0
  112. package/std/ts/style/ordering.dx +192 -0
  113. package/std/ts/style/returns.dx +152 -0
  114. package/std/ts/style/signatures.dx +308 -0
  115. package/std/ts/style/type-exports.dx +62 -0
  116. package/std/ts/style/type-imports.dx +166 -0
  117. package/std/ts/style/types.dx +474 -0
  118. package/std/ts/style.dx +29 -0
  119. package/std/ts/suggestions/accessors.dx +138 -0
  120. package/std/ts/suggestions/builtins.dx +110 -0
  121. package/std/ts/suggestions/comparisons.dx +41 -0
  122. package/std/ts/suggestions/computed-keys.dx +20 -0
  123. package/std/ts/suggestions/constructors.dx +54 -0
  124. package/std/ts/suggestions/control-flow.dx +204 -0
  125. package/std/ts/suggestions/curly.dx +124 -0
  126. package/std/ts/suggestions/directives.dx +79 -0
  127. package/std/ts/suggestions/errors.dx +106 -0
  128. package/std/ts/suggestions/expressions.dx +230 -0
  129. package/std/ts/suggestions/functions.dx +260 -0
  130. package/std/ts/suggestions/globals.dx +187 -0
  131. package/std/ts/suggestions/helpers.dx +17 -0
  132. package/std/ts/suggestions/object-shorthand.dx +148 -0
  133. package/std/ts/suggestions/object-spread.dx +96 -0
  134. package/std/ts/suggestions/regexp.dx +59 -0
  135. package/std/ts/suggestions/renames.dx +50 -0
  136. package/std/ts/suggestions/strings.dx +47 -0
  137. package/std/ts/suggestions/templates.dx +104 -0
  138. package/std/ts/suggestions.dx +24 -0
  139. package/std/ts/template-fixes.dx +22 -0
  140. package/std/ts/tokens.dx +124 -0
  141. package/std/ts/type-specifiers.dx +93 -0
  142. package/std/ts/typed/assignments.dx +154 -0
  143. package/std/ts/typed/awaitability.dx +157 -0
  144. package/std/ts/typed/boolean-comparisons.dx +82 -0
  145. package/std/ts/typed/defaults.dx +97 -0
  146. package/std/ts/typed/enum-consistency.dx +68 -0
  147. package/std/ts/typed/enums.dx +52 -0
  148. package/std/ts/typed/errors.dx +32 -0
  149. package/std/ts/typed/floating-promises.dx +147 -0
  150. package/std/ts/typed/for-in-arrays.dx +21 -0
  151. package/std/ts/typed/includes.dx +102 -0
  152. package/std/ts/typed/nullish-coalescing.dx +149 -0
  153. package/std/ts/typed/optional-chains.dx +317 -0
  154. package/std/ts/typed/promises.dx +205 -0
  155. package/std/ts/typed/qualifiers.dx +108 -0
  156. package/std/ts/typed/readonly-members.dx +159 -0
  157. package/std/ts/typed/readonly-parameters.dx +121 -0
  158. package/std/ts/typed/redundant-constituents.dx +171 -0
  159. package/std/ts/typed/regexp-exec.dx +79 -0
  160. package/std/ts/typed/rejection-handlers.dx +91 -0
  161. package/std/ts/typed/return-await.dx +116 -0
  162. package/std/ts/typed/return-this.dx +67 -0
  163. package/std/ts/typed/strict-void-return.dx +121 -0
  164. package/std/ts/typed/string-boundaries.dx +153 -0
  165. package/std/ts/typed/switches.dx +147 -0
  166. package/std/ts/typed/template-expressions.dx +127 -0
  167. package/std/ts/typed/template-values.dx +88 -0
  168. package/std/ts/typed/transfers.dx +106 -0
  169. package/std/ts/typed/type-arguments.dx +337 -0
  170. package/std/ts/typed/type-constituents.dx +143 -0
  171. package/std/ts/typed/type-conversions.dx +82 -0
  172. package/std/ts/typed/type-parameters.dx +280 -0
  173. package/std/ts/typed/unbound-method.dx +167 -0
  174. package/std/ts/typed/unsafe-calls.dx +73 -0
  175. package/std/ts/typed/unsafe-members.dx +36 -0
  176. package/std/ts/typed/void-expressions.dx +101 -0
  177. package/std/ts/typed.dx +585 -0
  178. package/std/ts/values/arguments.dx +13 -0
  179. package/std/ts/values/enums.dx +104 -0
  180. package/std/ts/values/inspection.dx +274 -0
  181. package/std/ts/values.dx +1217 -0
  182. package/std/ts.dx +77 -0
  183. package/std/whitespace.dx +37 -0
@@ -0,0 +1,107 @@
1
+ define {
2
+
3
+ fn scoping_array_factory(callee) = {
4
+ value member: unparenthesised_node(callee)
5
+ value object: unparenthesised_node(member.object.node)
6
+ value object is ts_identifier
7
+ && (member.static_name == "from" && ends_with(object.text, "Array")
8
+ || member.static_name == "fromAsync" && object.text == "Array")
9
+ }
10
+ fn scoping_receiver_immediate(n) = {
11
+ value outer: n.scoping_outer_parens
12
+ value if outer.parent is ts_call && outer.parent.callee.node == outer then outer.parent.node else null
13
+ }
14
+ fn scoping_receiver_destination_next(n) =
15
+ if n.parent is (ts_parenthesized, ts_logical, ts_conditional) then n.parent.node
16
+ else if n.parent is ts_return then {
17
+ value owners: walk(n.parent.node, current => current.parent.node)
18
+ value owner: { value owners; filter (current) current is ts_function_like; first }
19
+ value scoping_receiver_immediate(owner)
20
+ }
21
+ else if n is ts_arrow.body then scoping_receiver_immediate(n.parent.node)
22
+ else null
23
+ fn scoping_receiver_nullish(n) = {
24
+ value bare: unparenthesised_node(n)
25
+ value bare is ts_null || bare is ts_identifier && bare.text == "undefined"
26
+ || bare is ts_unary && bare.operator == "void"
27
+ }
28
+ fn scoping_receiver_uppercase(n) = n is ts_identifier && re_test(n.text, /^\p{Uppercase}/)
29
+ fn scoping_receiver_callback(call, callback, array_factory) = {
30
+ value callee: unparenthesised_node(call.callee.node)
31
+ value object: unparenthesised_node(callee.object.node)
32
+ value arguments: [] call.argument.nodes
33
+ value index: if object.text == "Reflect" && callee.static_name == "apply"
34
+ && count(arguments) == 3 && first(arguments) == callback then 1
35
+ else if array_factory && count(arguments) == 3
36
+ && { value arguments; slice 1 2; first } == callback then 2
37
+ else if count(arguments) == 2 && first(arguments) == callback
38
+ && contains(["every", "filter", "find", "findIndex", "findLast", "findLastIndex", "flatMap", "forEach", "map", "some"], callee.static_name) then 1
39
+ else null
40
+ value if index == null then null else { value arguments; slice index (index + 1); first }
41
+ }
42
+ fn scoping_receiver_assigned(function, constructor) = {
43
+ value current: { value function; walk (n) scoping_receiver_destination_next(n); last }
44
+ value parent: current.parent.node
45
+ value named: function.name != null
46
+ value callee: unparenthesised_node(parent.callee.node)
47
+ value array_factory: scoping_array_factory(callee)
48
+ value receiver: scoping_receiver_callback(parent, current, array_factory)
49
+ value if constructor && scoping_receiver_uppercase(function.name.node) then true
50
+ else if parent is (ts_property, ts_class_property) then !constructor && current is (ts_property.value, ts_class_property.init)
51
+ else if parent is (ts_assignment, ts_assignment_pattern) then
52
+ if constructor then !named && scoping_receiver_uppercase(parent.left.node) else parent.left is (ts_member, ts_index)
53
+ else if parent is (ts_declarator, ts_parameter) then constructor && !named
54
+ && current is (ts_declarator.init, ts_parameter.init) && scoping_receiver_uppercase(parent.name.node)
55
+ else if parent is (ts_member, ts_index) && current is (ts_member.object, ts_index.object) then {
56
+ value call: scoping_receiver_immediate(parent)
57
+ value receiver: first([] call.argument.nodes)
58
+ value !constructor && contains(["bind", "call", "apply"], parent.static_name)
59
+ && receiver != null && !scoping_receiver_nullish(receiver)
60
+ }
61
+ else parent is ts_call && !constructor && receiver != null && !scoping_receiver_nullish(receiver)
62
+ }
63
+
64
+ in ts_program let scoping_receiver_comments descendants(ts_comment)
65
+ in ts_node let scoping_receiver_comments parent.scoping_receiver_comments
66
+ fn scoping_receiver_comment(comment) = {
67
+ value body: { value comment.text; re_replace /^\/[\/*]/ ""; re_replace /\*\/$/ "" }
68
+ value lines: split(body, "\n")
69
+ value any(lines, line => re_test(line, /^[\s*]*@this/))
70
+ }
71
+ in ts_node let scoping_receiver_documented
72
+ any(scoping_receiver_comments, comment => comment.end_offset <= offset
73
+ && { value source; byte_slice comment.end_offset offset; trim } == ""
74
+ && scoping_receiver_comment(comment))
75
+ || parent not (ts_function_like, ts_block, ts_program, ts_call, ts_new)
76
+ && parent.scoping_receiver_documented == true
77
+ in ts_function let scoping_receiver_function_context {
78
+ valid: scoping_strict_code != true || any([] parameter.nodes, parameter => parameter.name == "this")
79
+ || scoping_receiver_documented || scoping_receiver_assigned(node, false),
80
+ constructor: scoping_receiver_assigned(node, true)
81
+ }
82
+ in ts_node let scoping_receiver_context
83
+ if parent is ts_static_block || is (ts_method.body, ts_method.parameter, ts_class_property.init)
84
+ then { valid: true, constructor: false }
85
+ else if parent is ts_function then parent.scoping_receiver_function_context
86
+ else parent.scoping_receiver_context
87
+ in ts_program let scoping_receiver_context {
88
+ value source_type: ts_source_type(node)
89
+ value {
90
+ valid: source_type == "script" || source_type == "commonjs" && scoping_strict_code != true,
91
+ constructor: false
92
+ }
93
+ }
94
+
95
+ in ts_node let scoping_receiver_read is (ts_this, ts_super) || any(children.nodes, child => child.scoping_receiver_read)
96
+ in ts_function, ts_method, ts_static_block, ts_class_property let scoping_receiver_read false
97
+ in ts_class let scoping_receiver_read
98
+ any([] decorator.nodes, item => item.scoping_receiver_read)
99
+ || any([] extends.nodes, item => item.scoping_receiver_read)
100
+ || any([] member.nodes, item => item.key is ts_computed_key && item.key.scoping_receiver_read)
101
+ in ts_method let scoping_receiver_used body.scoping_receiver_read == true
102
+ in ts_class_property let scoping_receiver_used {
103
+ value value: unparenthesised_node(init.node)
104
+ value if value is ts_function then value.body.scoping_receiver_read == true else value.scoping_receiver_read == true
105
+ }
106
+
107
+ }
@@ -0,0 +1,202 @@
1
+ define {
2
+
3
+ fn scoping_typed(program) = re_test(program.file, /\.(ts|tsx|mts|cts)$/)
4
+ in ts_identifier let scoping_indexed_declarations {
5
+ value scope: first(scoping_declaration_scopes)
6
+ value name_scope_declarations(node, scope.id, identifier_name)
7
+ filter (site) site.node is ts_identifier
8
+ && any(site.classes, class => contains(["value", "type", "query"], class))
9
+ }
10
+ fn scoping_scope_sites(n, scope) = {
11
+ value if scope.id == first(n.scoping_declaration_scopes).id
12
+ then (n.declaration.node ?? n).scoping_indexed_declarations
13
+ else name_scope_declarations(n, scope.id, n.identifier_name)
14
+ filter (site) site.node is ts_identifier
15
+ && any(site.classes, class => contains(["value", "type", "query"], class))
16
+ }
17
+ fn scoping_redeclaration_context(n) = {
18
+ value scope: first(n.scoping_declaration_scopes)
19
+ value if scope == null then null else {
20
+ value program: n.scoping_program
21
+ value typed: scoping_typed(program)
22
+ value sites: {
23
+ value scoping_scope_sites(n, scope)
24
+ filter (site) !(typed && site.node.parent is ts_function && site.node.parent.body == null)
25
+ map (site) site.node
26
+ }
27
+ value if !contains(sites, n) then null else {
28
+ value duplicate: any(sites, site => site.offset < n.offset)
29
+ value merge_report: if !typed || !duplicate then false else {
30
+ value kinds: map(sites, site => site.scoping_site_kind)
31
+ value category: if all(kinds, kind => contains(["class", "interface", "namespace"], kind)) then "class"
32
+ else if all(kinds, kind => contains(["function", "namespace"], kind)) then "function"
33
+ else if all(kinds, kind => contains(["enum", "namespace"], kind)) then "enum"
34
+ else null
35
+ value merge_all: all(kinds, kind => kind == "interface") || all(kinds, kind => kind == "namespace")
36
+ value if merge_all then false else if category != null
37
+ then n.scoping_site_kind == category && any(sites, site => site.offset < n.offset && site.scoping_site_kind == category)
38
+ else duplicate
39
+ }
40
+ value script: scoping_script_scope(scope)
41
+ value setting: if script then ts_global_setting(program, n.identifier_name) else null
42
+ value builtin: script && ts_global_implicit(program, n.identifier_name)
43
+ && contains(["readonly", "writable"], setting)
44
+ value {
45
+ duplicate: duplicate, safe_merge: typed && !merge_report, builtin: builtin,
46
+ comment: typed && script && ts_global_commented(program, n.identifier_name) && !builtin
47
+ }
48
+ }
49
+ }
50
+ }
51
+ fn scoping_shadow_scope_name(n, scope) = {
52
+ value sites: {
53
+ value scoping_scope_sites(n, scope)
54
+ map (site) site.node
55
+ filter (site) site.declaration.node == site || site.declaration.declaration_kind == "function_name"
56
+ }
57
+ value secondary: {
58
+ value sites
59
+ filter (site) site.declaration.declaration_kind == "function_name" && site.declaration.node != site
60
+ first
61
+ }
62
+ value secondary ?? first(sites)
63
+ }
64
+ fn scoping_shadow_value(n) = {
65
+ value canonical: n.declaration.node ?? n
66
+ value classes: name_role_classes(canonical, "declaration")
67
+ value n == null || contains(classes, "value")
68
+ }
69
+ fn scoping_shadow_ambient(n) = {
70
+ value owner: {
71
+ value n.parent.node
72
+ walk (current) if current is (ts_variable_declaration, ts_class, ts_enum, ts_namespace, ts_function, ts_parameter)
73
+ then null else current.parent.node
74
+ last
75
+ }
76
+ value re_test(n.file, /\.d\.(ts|cts|mts)$/)
77
+ && (contains(owner.modifier, "declare") || owner is ts_function && owner.body == null)
78
+ }
79
+ fn scoping_shadow_namespace(n, outer) = {
80
+ value import: {
81
+ value outer.parent.node
82
+ walk (current) if current is ts_import then null else current.parent.node
83
+ last
84
+ }
85
+ value n
86
+ walk (current) current.parent.node
87
+ any (current) current is ts_namespace
88
+ && (current.kind == "global" || current.name.text == "global"
89
+ || !scoping_shadow_value(outer) && import is ts_import
90
+ && js_string(import.from.text) == js_string(current.name.text))
91
+ }
92
+ fn scoping_shadow_initializer_children(n) =
93
+ if n is (ts_function, ts_arrow, ts_method, ts_class, ts_import) then null else n.parent.node
94
+ fn scoping_shadow_initializer(n, outer) = {
95
+ value outer
96
+ walk (current) scoping_shadow_initializer_children(current)
97
+ map (current) if current is (ts_declarator, ts_parameter) then current.init.node
98
+ else if current is ts_assignment_pattern then current.right.node
99
+ else if current is ts_pattern_property && current.value is ts_assignment_pattern then current.value.right.node
100
+ else if current is ts_variable_declaration && current.parent is (ts_for_in, ts_for_of) then current.parent.right.node
101
+ else null
102
+ filter (init) scoping_within(n, init)
103
+ first
104
+ }
105
+ fn scoping_shadow_callback(n, outer, init) = {
106
+ value scopes: n.scoping_declaration_scopes
107
+ value scope: {
108
+ value scopes
109
+ filter (scope) scope.owner is (ts_function, ts_arrow, ts_method, ts_program)
110
+ first
111
+ }
112
+ value declared: first(outer.scoping_declaration_scopes)
113
+ value parent_scope: {
114
+ value result: {
115
+ value scopes
116
+ fold ({ started: false, parent: null }) (state, candidate)
117
+ if state.parent != null then state
118
+ else if candidate.id == scope.id then { started: true, parent: null }
119
+ else if state.started && candidate.owner != scope.owner && scoping_value_scope(candidate)
120
+ then { started: true, parent: candidate }
121
+ else state
122
+ }
123
+ value result.parent
124
+ }
125
+ value route: {
126
+ value scope.owner.parent.node
127
+ walk (current) if !scoping_within(current, init) || current is (ts_call, ts_function, ts_arrow, ts_method)
128
+ then null else current.parent.node
129
+ last
130
+ }
131
+ value scope.owner is (ts_function, ts_arrow)
132
+ && any(scopes, candidate => candidate.owner == parent_scope.owner
133
+ && scoping_value_scope(candidate) && candidate.id == declared.id)
134
+ && route is ts_call && scoping_within(route, init)
135
+ }
136
+ fn scoping_shadow_name_initializer(n, canonical, init) = {
137
+ value expression: {
138
+ value n.parent.node
139
+ walk (current) if current.parent is (ts_parenthesized, ts_logical)
140
+ || current.parent is ts_conditional && !(current is ts_conditional.test)
141
+ then current.parent.node else null
142
+ last
143
+ }
144
+ value unwrapped: unparenthesised_node(expression)
145
+ value initializer: unparenthesised_node(init)
146
+ value n == canonical && contains(["function_name", "class_name"], canonical.declaration_kind)
147
+ && unwrapped == initializer
148
+ }
149
+ fn scoping_shadow_context(n, builtins) = {
150
+ value enum_member: n is ts_enum_member.name
151
+ value scope_node: if enum_member then n.parent.parent.name.node else n
152
+ value scopes: scope_node.scoping_declaration_scopes
153
+ value scope: first(scopes)
154
+ value canonical: n.declaration.node ?? n
155
+ value named_function: canonical.declaration_kind == "function_name"
156
+ value if scope == null || canonical != n && !named_function || n.identifier_name == "this"
157
+ || scoping_shadow_ambient(n) then null else {
158
+ value outer: if named_function && canonical != n then canonical else {
159
+ value scopes
160
+ filter (candidate) enum_member || candidate.id != scope.id
161
+ map (candidate) scoping_shadow_scope_name(n, candidate)
162
+ filter (site) site != null
163
+ first
164
+ }
165
+ value if outer == null && !builtins then null else {
166
+ value program: n.scoping_program
167
+ value typed: scoping_typed(program)
168
+ value setting: if outer == null && builtins && (!scoping_script_scope(scope) || typed)
169
+ then ts_global_setting(program, n.identifier_name) else null
170
+ value builtin: outer == null && (!scoping_script_scope(scope) || typed)
171
+ && contains(["readonly", "writable"], setting)
172
+ value if outer == null && !builtin || scoping_shadow_namespace(n, outer) then null else {
173
+ value owner: {
174
+ value n.parent.node
175
+ walk (current) if current is (ts_parameter, ts_type_parameter) then current.parent.node else null
176
+ last
177
+ }
178
+ value static_generic: canonical.declaration_kind == "type_parameter" && owner is ts_method && contains(owner.modifier, "static")
179
+ value if static_generic then null else {
180
+ value init: scoping_shadow_initializer(n, outer)
181
+ value if init != null && scoping_shadow_name_initializer(n, canonical, init) then null else {
182
+ value position: position(outer.offset)
183
+ value {
184
+ global: builtin, enum_member: typed && enum_member,
185
+ line: if outer == null then 1 else position.js_line,
186
+ column: if outer == null then 1 else position.js_column,
187
+ kind: outer.declaration_kind ?? "",
188
+ early: outer != null && n.end_offset < outer.offset,
189
+ type_value: (if enum_member then true else scoping_shadow_value(n)) != scoping_shadow_value(outer),
190
+ function_type: canonical.declaration_kind == "parameter"
191
+ && (owner is (ts_function_type, ts_method_signature, ts_call_signature)
192
+ || owner is (ts_function, ts_method) && owner.body == null),
193
+ initializing: init != null && !(typed && named_function) && scoping_shadow_callback(n, outer, init)
194
+ }
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }
200
+ }
201
+
202
+ }