@ttsc/lint 0.18.4 → 0.19.1

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 (188) hide show
  1. package/README.md +125 -43
  2. package/go.mod +5 -4
  3. package/internal/rulecode/rulecode.go +88 -0
  4. package/lib/index.d.ts +10 -1
  5. package/lib/index.js +45 -17
  6. package/lib/index.js.map +1 -1
  7. package/lib/structures/ITtscLintConfig.d.ts +3 -0
  8. package/lib/structures/TtscLintRuleSetting.d.ts +3 -2
  9. package/lib/structures/format/ITtscLintFormat.d.ts +3 -2
  10. package/lib/structures/format/ITtscLintFormatSortImports.d.ts +20 -4
  11. package/lib/structures/rules/ITtscLintBoundariesRuleOptions.d.ts +80 -8
  12. package/lib/structures/rules/ITtscLintBoundariesRules.d.ts +6 -8
  13. package/lib/structures/rules/ITtscLintContributorRules.d.ts +18 -2
  14. package/lib/structures/rules/ITtscLintCoreRuleOptions.d.ts +347 -0
  15. package/lib/structures/rules/ITtscLintCoreRuleOptions.js +3 -0
  16. package/lib/structures/rules/ITtscLintCoreRuleOptions.js.map +1 -0
  17. package/lib/structures/rules/ITtscLintCoreRules.d.ts +101 -67
  18. package/lib/structures/rules/ITtscLintRegexpRules.d.ts +7 -2
  19. package/lib/structures/rules/ITtscLintRuleOptionsMap.d.ts +53 -7
  20. package/lib/structures/rules/ITtscLintRules.d.ts +6 -2
  21. package/lib/structures/rules/ITtscLintSolidRules.d.ts +0 -8
  22. package/lib/structures/rules/ITtscLintTypeScriptRuleOptions.d.ts +206 -0
  23. package/lib/structures/rules/ITtscLintTypeScriptRuleOptions.js +8 -0
  24. package/lib/structures/rules/ITtscLintTypeScriptRuleOptions.js.map +1 -0
  25. package/lib/structures/rules/ITtscLintTypeScriptRules.d.ts +55 -42
  26. package/lib/structures/rules/ITtscLintUnicornRuleOptions.d.ts +276 -0
  27. package/lib/structures/rules/ITtscLintUnicornRuleOptions.js +3 -0
  28. package/lib/structures/rules/ITtscLintUnicornRuleOptions.js.map +1 -0
  29. package/lib/structures/rules/ITtscLintUnicornRules.d.ts +44 -36
  30. package/lib/structures/rules/index.d.ts +3 -0
  31. package/lib/structures/rules/index.js +3 -0
  32. package/lib/structures/rules/index.js.map +1 -1
  33. package/linthost/ast_helpers.go +521 -23
  34. package/linthost/ast_selector_matcher.go +1628 -0
  35. package/linthost/ast_selector_parser.go +628 -0
  36. package/linthost/comment_scan.go +154 -0
  37. package/linthost/compile.go +129 -79
  38. package/linthost/config.go +352 -88
  39. package/linthost/config_format.go +15 -1
  40. package/linthost/contrib_adapter.go +47 -8
  41. package/linthost/declaration_rules.go +12 -11
  42. package/linthost/directives.go +9 -67
  43. package/linthost/dispatch.go +37 -3
  44. package/linthost/engine.go +368 -53
  45. package/linthost/escape_string.go +77 -0
  46. package/linthost/fix.go +133 -23
  47. package/linthost/flags_gen.go +18 -17
  48. package/linthost/format.go +73 -167
  49. package/linthost/format_editor_settings.go +134 -26
  50. package/linthost/grapheme_tables_gen.go +1920 -0
  51. package/linthost/host.go +159 -61
  52. package/linthost/literal_escape_scan.go +117 -0
  53. package/linthost/lsp.go +545 -98
  54. package/linthost/numeric_literal_precision.go +228 -0
  55. package/linthost/polyfill_browserslist.go +1439 -0
  56. package/linthost/polyfill_browserslist_config.go +603 -0
  57. package/linthost/polyfill_corejs.go +750 -0
  58. package/linthost/polyfill_data.go +113 -0
  59. package/linthost/polyfill_data_gen.json +39868 -0
  60. package/linthost/print_nodes_array.go +7 -1
  61. package/linthost/print_nodes_object.go +7 -1
  62. package/linthost/project_engine.go +231 -0
  63. package/linthost/project_rules.go +78 -0
  64. package/linthost/regex_clean.go +191 -0
  65. package/linthost/regex_tree.go +1544 -0
  66. package/linthost/regex_tree_optimizer.go +1685 -0
  67. package/linthost/regexp_cache.go +44 -0
  68. package/linthost/rule_codes.go +105 -0
  69. package/linthost/rule_codes.json +745 -0
  70. package/linthost/rules_ban_ts_comment.go +312 -0
  71. package/linthost/rules_boundaries.go +128 -43
  72. package/linthost/rules_boundaries_dependencies.go +1013 -0
  73. package/linthost/rules_core_extra.go +62 -92
  74. package/linthost/rules_cypress.go +1 -1
  75. package/linthost/rules_default_case.go +87 -11
  76. package/linthost/rules_dupes.go +38 -13
  77. package/linthost/rules_empty.go +188 -20
  78. package/linthost/rules_escape.go +62 -48
  79. package/linthost/rules_format_arrow_parens.go +19 -5
  80. package/linthost/rules_format_bracket_spacing.go +1 -1
  81. package/linthost/rules_format_clause_join.go +1 -1
  82. package/linthost/rules_format_declaration_header.go +31 -19
  83. package/linthost/rules_format_indent.go +1 -1
  84. package/linthost/rules_format_jsdoc.go +1 -1
  85. package/linthost/rules_format_orphan_semi.go +1 -1
  86. package/linthost/rules_format_parameter_properties.go +17 -7
  87. package/linthost/rules_format_print_width.go +1 -1
  88. package/linthost/rules_format_quote_props.go +1 -1
  89. package/linthost/rules_format_quotes.go +1 -1
  90. package/linthost/rules_format_semi.go +106 -79
  91. package/linthost/rules_format_sort_imports.go +79 -45
  92. package/linthost/rules_format_statement_split.go +1 -1
  93. package/linthost/rules_format_ternary_nullish_parens.go +1 -1
  94. package/linthost/rules_format_trailing_comma.go +64 -1
  95. package/linthost/rules_format_whitespace.go +1 -1
  96. package/linthost/rules_functional.go +21 -22
  97. package/linthost/rules_gap.go +80 -3
  98. package/linthost/rules_grouped_accessor_pairs.go +84 -25
  99. package/linthost/rules_guard_for_in.go +64 -147
  100. package/linthost/rules_jsx_a11y.go +232 -22
  101. package/linthost/rules_logic.go +84 -38
  102. package/linthost/rules_nextjs.go +105 -16
  103. package/linthost/rules_no_class_assign.go +70 -0
  104. package/linthost/rules_no_duplicate_imports.go +266 -0
  105. package/linthost/rules_no_else_return.go +156 -38
  106. package/linthost/rules_no_extend_native.go +113 -17
  107. package/linthost/rules_no_fallthrough.go +1013 -0
  108. package/linthost/rules_no_func_assign.go +70 -0
  109. package/linthost/rules_no_import_assign.go +278 -86
  110. package/linthost/rules_no_inner_declarations.go +186 -0
  111. package/linthost/rules_no_loop_func.go +438 -53
  112. package/linthost/rules_no_mixed_operators.go +208 -52
  113. package/linthost/rules_no_param_reassign.go +376 -61
  114. package/linthost/rules_no_promise_executor_return.go +156 -0
  115. package/linthost/rules_no_restricted_imports.go +1013 -57
  116. package/linthost/rules_no_restricted_syntax.go +190 -26
  117. package/linthost/rules_no_useless_constructor.go +6 -36
  118. package/linthost/rules_problems.go +154 -311
  119. package/linthost/rules_promise.go +2578 -109
  120. package/linthost/rules_react_extras.go +71 -45
  121. package/linthost/rules_react_hooks.go +18 -2
  122. package/linthost/rules_react_perf.go +1 -0
  123. package/linthost/rules_react_refresh.go +1 -1
  124. package/linthost/rules_regexp.go +230 -14
  125. package/linthost/rules_security.go +45 -19
  126. package/linthost/rules_self.go +21 -1
  127. package/linthost/rules_solid.go +13 -7
  128. package/linthost/rules_storybook.go +1 -1
  129. package/linthost/rules_suggestions.go +490 -84
  130. package/linthost/rules_testing_library.go +12 -1
  131. package/linthost/rules_ts.go +227 -54
  132. package/linthost/rules_ts_async.go +0 -131
  133. package/linthost/rules_ts_no_base_to_string.go +3 -4
  134. package/linthost/rules_ts_no_misused_promises.go +817 -0
  135. package/linthost/rules_ts_no_restricted_types.go +320 -34
  136. package/linthost/rules_ts_no_unnecessary_qualifier.go +132 -55
  137. package/linthost/rules_ts_no_unsafe_assignment.go +608 -60
  138. package/linthost/rules_ts_require_array_sort_compare.go +5 -5
  139. package/linthost/rules_ts_switch_exhaustiveness_check.go +556 -86
  140. package/linthost/rules_unicorn_better_regex.go +224 -16
  141. package/linthost/rules_unicorn_consistent_destructuring.go +1002 -7
  142. package/linthost/rules_unicorn_consistent_existence_index_check.go +208 -29
  143. package/linthost/rules_unicorn_consistent_function_scoping.go +1041 -8
  144. package/linthost/rules_unicorn_consistent_template_literal_escape.go +178 -7
  145. package/linthost/rules_unicorn_escape_case.go +30 -19
  146. package/linthost/rules_unicorn_filename_case.go +763 -16
  147. package/linthost/rules_unicorn_import_style.go +783 -17
  148. package/linthost/rules_unicorn_isolated_functions.go +934 -14
  149. package/linthost/rules_unicorn_no_hex_escape.go +26 -11
  150. package/linthost/rules_unicorn_no_typeof_undefined.go +234 -25
  151. package/linthost/rules_unicorn_no_unnecessary_polyfills.go +376 -21
  152. package/linthost/rules_unicorn_no_unused_properties.go +756 -19
  153. package/linthost/rules_unicorn_number_literal_case.go +58 -39
  154. package/linthost/rules_unicorn_prefer_at.go +7 -3
  155. package/linthost/rules_unicorn_prefer_number_properties.go +381 -48
  156. package/linthost/rules_unicorn_prefer_optional_catch_binding.go +24 -24
  157. package/linthost/rules_unicorn_prefer_simple_condition_first.go +597 -19
  158. package/linthost/rules_unicorn_prefer_string_raw.go +147 -16
  159. package/linthost/rules_unicorn_prevent_abbreviations.go +1963 -95
  160. package/linthost/rules_unicorn_string_content.go +611 -15
  161. package/linthost/rules_unicorn_switch_case_break_position.go +172 -15
  162. package/linthost/rules_unicorn_template_indent.go +923 -18
  163. package/linthost/rules_unicorn_text_encoding_identifier_case.go +202 -42
  164. package/linthost/rules_unicorn_throw_new_error.go +218 -26
  165. package/linthost/rules_var.go +829 -142
  166. package/linthost/string_length.go +222 -0
  167. package/package.json +4 -3
  168. package/rule/project.go +206 -0
  169. package/rule/rule.go +58 -1
  170. package/src/index.ts +58 -17
  171. package/src/structures/ITtscLintConfig.ts +3 -0
  172. package/src/structures/TtscLintRuleSetting.ts +3 -2
  173. package/src/structures/format/ITtscLintFormat.ts +3 -2
  174. package/src/structures/format/ITtscLintFormatSortImports.ts +21 -4
  175. package/src/structures/rules/ITtscLintBoundariesRuleOptions.ts +122 -8
  176. package/src/structures/rules/ITtscLintBoundariesRules.ts +6 -8
  177. package/src/structures/rules/ITtscLintContributorRules.ts +18 -2
  178. package/src/structures/rules/ITtscLintCoreRuleOptions.ts +465 -0
  179. package/src/structures/rules/ITtscLintCoreRules.ts +122 -67
  180. package/src/structures/rules/ITtscLintRegexpRules.ts +7 -2
  181. package/src/structures/rules/ITtscLintRuleOptionsMap.ts +88 -7
  182. package/src/structures/rules/ITtscLintRules.ts +7 -2
  183. package/src/structures/rules/ITtscLintSolidRules.ts +0 -9
  184. package/src/structures/rules/ITtscLintTypeScriptRuleOptions.ts +248 -0
  185. package/src/structures/rules/ITtscLintTypeScriptRules.ts +64 -42
  186. package/src/structures/rules/ITtscLintUnicornRuleOptions.ts +350 -0
  187. package/src/structures/rules/ITtscLintUnicornRules.ts +60 -36
  188. package/src/structures/rules/index.ts +3 -0
@@ -1,80 +1,236 @@
1
- // noMixedOperators flags expressions that mix operators from different
2
- // precedence families without explicit parentheses around the inner
3
- // expression. The classic gotcha is `a && b || c` readers expect
4
- // left-to-right grouping, but `&&` binds tighter than `||`, so the
5
- // parse tree is actually `(a && b) || c`. Wrapping the inner
6
- // sub-expression in parens removes the ambiguity for both the parser
7
- // and the reader.
1
+ // noMixedOperators is a faithful port of ESLint's no-mixed-operators. It
2
+ // flags an unparenthesized binary sub-expression whose operator is mixed with
3
+ // a different operator from the SAME configured group, unless the two share a
4
+ // precedence and allowSamePrecedence is on. The classic gotcha is `a && b ||
5
+ // c`: readers expect left-to-right grouping, but `&&` binds tighter than `||`,
6
+ // so the parse is `(a && b) || c`. Wrapping the inner sub-expression in parens
7
+ // removes the ambiguity.
8
8
  //
9
- // The conservative baseline fires only on the highest-confusion mixes:
10
- // logical mixed with a different logical, logical mixed with bitwise,
11
- // and bitwise mixed with comparison. Same-operator chains (`a && b &&
12
- // c`) and parenthesized inner children (`(a && b) || c`) never fire.
9
+ // The default groups mirror ESLint's DEFAULT_GROUPS arithmetic, bitwise,
10
+ // comparison, logical, relational and a mix is only reportable when both
11
+ // operators live in one group. So `a + b * c` (arithmetic × arithmetic,
12
+ // different precedence) IS flagged, while `a | b && c` (bitwise × logical,
13
+ // different groups) is NOT: the earlier port had this exactly backwards,
14
+ // pairing across groups and omitting arithmetic. Ternary ("?:") and coalesce
15
+ // ("??") are in no default group, so a mix involving either is only considered
16
+ // when a custom `groups` option lists it.
17
+ //
18
+ // Because the TypeScript AST models parentheses as explicit
19
+ // ParenthesizedExpression nodes, a wrapped inner expression (`(a && b) || c`)
20
+ // has a non-binary parent and is skipped without ESLint's token-level paren
21
+ // probe. The `groups` and `allowSamePrecedence` options are honored.
13
22
  // https://eslint.org/docs/latest/rules/no-mixed-operators
14
23
  package linthost
15
24
 
16
25
  import shimast "github.com/microsoft/typescript-go/shim/ast"
17
26
 
18
- type noMixedOperators struct{}
27
+ // noMixedOperatorsDefaultGroups mirrors ESLint's DEFAULT_GROUPS. Each inner
28
+ // slice is one precedence family; a mix is only reportable when both operators
29
+ // belong to the same family. "~" never appears as a binary operator token but
30
+ // is retained so the bitwise family matches ESLint's BITWISE_OPERATORS
31
+ // verbatim. Ternary and coalesce are intentionally absent.
32
+ var noMixedOperatorsDefaultGroups = [][]string{
33
+ {"+", "-", "*", "/", "%", "**"},
34
+ {"&", "|", "^", "~", "<<", ">>", ">>>"},
35
+ {"==", "!=", "===", "!==", ">", ">=", "<", "<="},
36
+ {"&&", "||"},
37
+ {"in", "instanceof"},
38
+ }
39
+
40
+ // noMixedOperatorsTernarySymbol is the operator name ESLint assigns to a
41
+ // ConditionalExpression parent. No default group contains it.
42
+ const noMixedOperatorsTernarySymbol = "?:"
19
43
 
20
- const (
21
- mixedGroupLogical = 1
22
- mixedGroupBitwise = 2
23
- mixedGroupComparison = 3
24
- )
44
+ // noMixedOperatorsMemoKey caches the file-resolved options so the JSON option
45
+ // blob is decoded once per file instead of once per visited binary node.
46
+ type noMixedOperatorsMemoKey struct{}
47
+
48
+ // noMixedOperatorsResolved is the normalized option set for one file.
49
+ type noMixedOperatorsResolved struct {
50
+ groups [][]string
51
+ allowSamePrecedence bool
52
+ }
53
+
54
+ // noMixedOperatorsOptions is the wire shape of the rule's single options
55
+ // object, mirroring ESLint's schema. A nil AllowSamePrecedence keeps the
56
+ // default (true); empty Groups falls back to the default groups.
57
+ type noMixedOperatorsOptions struct {
58
+ Groups [][]string `json:"groups"`
59
+ AllowSamePrecedence *bool `json:"allowSamePrecedence"`
60
+ }
61
+
62
+ type noMixedOperators struct{ optionsRule }
25
63
 
26
64
  func (noMixedOperators) Name() string { return "no-mixed-operators" }
27
65
  func (noMixedOperators) Visits() []shimast.Kind { return []shimast.Kind{shimast.KindBinaryExpression} }
66
+
28
67
  func (noMixedOperators) Check(ctx *Context, node *shimast.Node) {
29
- expr := node.AsBinaryExpression()
30
- if expr == nil || expr.OperatorToken == nil {
68
+ parent := node.Parent
69
+ if parent == nil {
70
+ return
71
+ }
72
+ childOp, ok := noMixedOperatorsBinarySymbol(node)
73
+ if !ok {
31
74
  return
32
75
  }
33
- parent := noMixedOperatorsGroup(expr.OperatorToken.Kind)
34
- if parent == 0 {
76
+ parentOp, ok := noMixedOperatorsParentSymbol(parent)
77
+ if !ok {
35
78
  return
36
79
  }
37
- op := expr.OperatorToken.Kind
38
- if noMixedOperatorsConflicts(parent, op, expr.Left) ||
39
- noMixedOperatorsConflicts(parent, op, expr.Right) {
40
- ctx.Report(node, "Unexpected mix of different operators. Wrap the inner expression in parentheses to make the grouping explicit.")
80
+ // isMixedWithParent: a different operator. A parenthesized child has a
81
+ // ParenthesizedExpression parent and never reaches here, so ESLint's
82
+ // token-level parenthesization probe is unnecessary.
83
+ if childOp == parentOp {
84
+ return
85
+ }
86
+
87
+ resolved := noMixedOperatorsResolveOptions(ctx)
88
+ // shouldIgnore: skip unless both operators share a group AND, when they do,
89
+ // they differ in precedence (or allowSamePrecedence is off).
90
+ if !noMixedOperatorsIncludesBothInAGroup(resolved.groups, childOp, parentOp) {
91
+ return
41
92
  }
93
+ if resolved.allowSamePrecedence &&
94
+ shimast.GetExpressionPrecedence(node) == shimast.GetExpressionPrecedence(parent) {
95
+ return
96
+ }
97
+ ctx.Report(node, "Unexpected mix of different operators. Wrap the inner expression in parentheses to make the grouping explicit.")
98
+ }
99
+
100
+ // noMixedOperatorsResolveOptions decodes and caches the file's options. The
101
+ // engine reuses one Context per (file, rule), so the memo is keyed on the
102
+ // shared per-file table; a Context built outside the engine (focused unit
103
+ // tests) has no memo and transparently re-decodes.
104
+ func noMixedOperatorsResolveOptions(ctx *Context) noMixedOperatorsResolved {
105
+ if cached, ok := ctx.fileValue(noMixedOperatorsMemoKey{}); ok {
106
+ return cached.(noMixedOperatorsResolved)
107
+ }
108
+ resolved := noMixedOperatorsResolved{
109
+ groups: noMixedOperatorsDefaultGroups,
110
+ allowSamePrecedence: true,
111
+ }
112
+ var opts noMixedOperatorsOptions
113
+ if err := ctx.DecodeOptions(&opts); err == nil {
114
+ // ESLint's normalizeOptions treats a missing OR empty groups array as "use
115
+ // the defaults"; a non-empty array replaces them wholesale.
116
+ if len(opts.Groups) > 0 {
117
+ resolved.groups = opts.Groups
118
+ }
119
+ if opts.AllowSamePrecedence != nil {
120
+ resolved.allowSamePrecedence = *opts.AllowSamePrecedence
121
+ }
122
+ }
123
+ ctx.setFileValue(noMixedOperatorsMemoKey{}, resolved)
124
+ return resolved
42
125
  }
43
126
 
44
- // noMixedOperatorsConflicts returns true when `child` is an
45
- // unparenthesized BinaryExpression whose operator group is confusing
46
- // next to the parent group. Same operator never conflicts.
47
- func noMixedOperatorsConflicts(parent int, parentOp shimast.Kind, child *shimast.Node) bool {
48
- if child == nil || child.Kind != shimast.KindBinaryExpression {
49
- return false
127
+ // noMixedOperatorsBinarySymbol returns the ESLint operator name for a binary
128
+ // expression node, reporting false when the node is not a binary expression
129
+ // carrying a recognized operator token.
130
+ func noMixedOperatorsBinarySymbol(node *shimast.Node) (string, bool) {
131
+ if node == nil || node.Kind != shimast.KindBinaryExpression {
132
+ return "", false
133
+ }
134
+ expr := node.AsBinaryExpression()
135
+ if expr == nil || expr.OperatorToken == nil {
136
+ return "", false
50
137
  }
51
- inner := child.AsBinaryExpression()
52
- if inner == nil || inner.OperatorToken == nil || inner.OperatorToken.Kind == parentOp {
53
- return false
138
+ symbol := noMixedOperatorsOperatorSymbol(expr.OperatorToken.Kind)
139
+ return symbol, symbol != ""
140
+ }
141
+
142
+ // noMixedOperatorsParentSymbol returns the operator name of a candidate parent.
143
+ // A binary parent contributes its operator; a conditional parent contributes
144
+ // "?:". Any other parent — a ParenthesizedExpression wrapping the child, a
145
+ // statement, a call argument — means the child is not mixed with an operator,
146
+ // so it reports false and the mix is skipped.
147
+ func noMixedOperatorsParentSymbol(parent *shimast.Node) (string, bool) {
148
+ switch parent.Kind {
149
+ case shimast.KindBinaryExpression:
150
+ return noMixedOperatorsBinarySymbol(parent)
151
+ case shimast.KindConditionalExpression:
152
+ return noMixedOperatorsTernarySymbol, true
54
153
  }
55
- g := noMixedOperatorsGroup(inner.OperatorToken.Kind)
56
- if g == 0 {
57
- return false
154
+ return "", false
155
+ }
156
+
157
+ // noMixedOperatorsIncludesBothInAGroup mirrors ESLint's includesBothInAGroup:
158
+ // true when some group contains both operator names.
159
+ func noMixedOperatorsIncludesBothInAGroup(groups [][]string, left, right string) bool {
160
+ for _, group := range groups {
161
+ if noMixedOperatorsGroupContains(group, left) && noMixedOperatorsGroupContains(group, right) {
162
+ return true
163
+ }
58
164
  }
59
- if parent == mixedGroupLogical {
60
- return g == mixedGroupLogical || g == mixedGroupBitwise
165
+ return false
166
+ }
167
+
168
+ func noMixedOperatorsGroupContains(group []string, symbol string) bool {
169
+ for _, member := range group {
170
+ if member == symbol {
171
+ return true
172
+ }
61
173
  }
62
- return parent == mixedGroupBitwise && (g == mixedGroupLogical || g == mixedGroupComparison)
174
+ return false
63
175
  }
64
176
 
65
- func noMixedOperatorsGroup(op shimast.Kind) int {
66
- switch op {
67
- case shimast.KindAmpersandAmpersandToken, shimast.KindBarBarToken, shimast.KindQuestionQuestionToken:
68
- return mixedGroupLogical
69
- case shimast.KindAmpersandToken, shimast.KindBarToken, shimast.KindCaretToken:
70
- return mixedGroupBitwise
71
- case shimast.KindEqualsEqualsToken, shimast.KindEqualsEqualsEqualsToken,
72
- shimast.KindExclamationEqualsToken, shimast.KindExclamationEqualsEqualsToken,
73
- shimast.KindLessThanToken, shimast.KindLessThanEqualsToken,
74
- shimast.KindGreaterThanToken, shimast.KindGreaterThanEqualsToken:
75
- return mixedGroupComparison
177
+ // noMixedOperatorsOperatorSymbol maps a binary operator token kind to the
178
+ // operator name ESLint uses in its group arrays. Unrecognized kinds
179
+ // (assignments, comma, unmapped keywords) return "" and so belong to no group.
180
+ func noMixedOperatorsOperatorSymbol(kind shimast.Kind) string {
181
+ switch kind {
182
+ case shimast.KindPlusToken:
183
+ return "+"
184
+ case shimast.KindMinusToken:
185
+ return "-"
186
+ case shimast.KindAsteriskToken:
187
+ return "*"
188
+ case shimast.KindSlashToken:
189
+ return "/"
190
+ case shimast.KindPercentToken:
191
+ return "%"
192
+ case shimast.KindAsteriskAsteriskToken:
193
+ return "**"
194
+ case shimast.KindAmpersandToken:
195
+ return "&"
196
+ case shimast.KindBarToken:
197
+ return "|"
198
+ case shimast.KindCaretToken:
199
+ return "^"
200
+ case shimast.KindLessThanLessThanToken:
201
+ return "<<"
202
+ case shimast.KindGreaterThanGreaterThanToken:
203
+ return ">>"
204
+ case shimast.KindGreaterThanGreaterThanGreaterThanToken:
205
+ return ">>>"
206
+ case shimast.KindEqualsEqualsToken:
207
+ return "=="
208
+ case shimast.KindExclamationEqualsToken:
209
+ return "!="
210
+ case shimast.KindEqualsEqualsEqualsToken:
211
+ return "==="
212
+ case shimast.KindExclamationEqualsEqualsToken:
213
+ return "!=="
214
+ case shimast.KindGreaterThanToken:
215
+ return ">"
216
+ case shimast.KindGreaterThanEqualsToken:
217
+ return ">="
218
+ case shimast.KindLessThanToken:
219
+ return "<"
220
+ case shimast.KindLessThanEqualsToken:
221
+ return "<="
222
+ case shimast.KindAmpersandAmpersandToken:
223
+ return "&&"
224
+ case shimast.KindBarBarToken:
225
+ return "||"
226
+ case shimast.KindInKeyword:
227
+ return "in"
228
+ case shimast.KindInstanceOfKeyword:
229
+ return "instanceof"
230
+ case shimast.KindQuestionQuestionToken:
231
+ return "??"
76
232
  }
77
- return 0
233
+ return ""
78
234
  }
79
235
 
80
236
  func init() { Register(noMixedOperators{}) }