@ttsc/lint 0.18.3 → 0.19.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 (188) hide show
  1. package/README.md +95 -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 +129 -25
  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 +160 -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 +151 -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 +145 -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,4 +1,5 @@
1
- import type { TtscLintRuleSetting } from "../TtscLintRuleSetting";
1
+ import type { TtscLintRuleOptionsSetting, TtscLintRuleSetting } from "../TtscLintRuleSetting";
2
+ import type { ITtscLintCoreDefaultCaseRuleOptions, ITtscLintCoreNoDuplicateImportsRuleOptions, ITtscLintCoreNoElseReturnRuleOptions, ITtscLintCoreNoEmptyFunctionRuleOptions, ITtscLintCoreNoEmptyRuleOptions, ITtscLintCoreNoExtendNativeRuleOptions, ITtscLintCoreNoMixedOperatorsRuleOptions, ITtscLintCoreNoParamReassignRuleOptions, ITtscLintCoreNoPromiseExecutorReturnRuleOptions, ITtscLintCoreNoUnusedExpressionsRuleOptions, ITtscLintCorePreferConstRuleOptions, ITtscLintNoFallthroughRuleOptions, TtscLintCoreGroupedAccessorPairsRuleSetting, TtscLintCoreNoInnerDeclarationsRuleSetting, TtscLintCoreNoRestrictedImportsRuleSetting, TtscLintCoreNoRestrictedSyntaxRuleSetting, TtscLintCoreNoReturnAssignRuleSetting } from "./ITtscLintCoreRuleOptions";
2
3
  /**
3
4
  * Generic ESLint-compatible rules that apply to both JavaScript and TypeScript
4
5
  * source.
@@ -35,7 +36,7 @@ export interface ITtscLintCoreRules {
35
36
  *
36
37
  * @reference https://eslint.org/docs/latest/rules/default-case
37
38
  */
38
- "default-case"?: TtscLintRuleSetting;
39
+ "default-case"?: TtscLintRuleOptionsSetting<ITtscLintCoreDefaultCaseRuleOptions>;
39
40
  /**
40
41
  * Require the `default` clause of a `switch` statement to appear after every
41
42
  * explicit `case` label.
@@ -123,7 +124,7 @@ export interface ITtscLintCoreRules {
123
124
  *
124
125
  * @reference https://eslint.org/docs/latest/rules/grouped-accessor-pairs
125
126
  */
126
- "grouped-accessor-pairs"?: TtscLintRuleSetting;
127
+ "grouped-accessor-pairs"?: TtscLintCoreGroupedAccessorPairsRuleSetting;
127
128
  /**
128
129
  * Require the body of every `for (key in obj)` loop to begin with a guard
129
130
  * against inherited keys: `Object.hasOwn(obj, key)` or the older
@@ -271,10 +272,13 @@ export interface ITtscLintCoreRules {
271
272
  */
272
273
  "no-case-declarations"?: TtscLintRuleSetting;
273
274
  /**
274
- * Reject reassigning a class binding (`class C {}; C = ...`).
275
+ * Reject every write to a binding introduced by a class declaration or named
276
+ * class expression.
275
277
  *
276
- * The declaration name is effectively final; overwriting it silently leaves
277
- * other call sites pointing at the original class.
278
+ * Binding identity is resolved lexically, so same-spelled parameter, catch,
279
+ * block, and sibling bindings remain independent. Direct and compound
280
+ * assignments, updates, destructuring targets, and `for-in`/`for-of` targets
281
+ * are all covered.
278
282
  *
279
283
  * @reference https://eslint.org/docs/latest/rules/no-class-assign
280
284
  */
@@ -380,8 +384,8 @@ export interface ITtscLintCoreRules {
380
384
  */
381
385
  "no-dupe-class-members"?: TtscLintRuleSetting;
382
386
  /**
383
- * Reject `if (a) {} else if (a) {}` the second branch is unreachable
384
- * because the first condition already handled it.
387
+ * Reject an `else if` branch when duplicate or structurally covered
388
+ * conditions earlier in the same chain make it unreachable.
385
389
  *
386
390
  * @reference https://eslint.org/docs/latest/rules/no-dupe-else-if
387
391
  */
@@ -401,28 +405,31 @@ export interface ITtscLintCoreRules {
401
405
  */
402
406
  "no-duplicate-case"?: TtscLintRuleSetting;
403
407
  /**
404
- * Reject two import declarations that resolve to the same module specifier.
405
- * The runtime sees one module load either way; the duplicated declaration is
406
- * purely noise at the head of the file and obscures the dependency graph.
408
+ * Reject an import declaration whose module specifier already appeared above
409
+ * when the two declarations could be merged into one legal declaration.
410
+ * Same-module pairs TypeScript cannot consolidate named next to namespace
411
+ * bindings, or a type-only default next to type-only named bindings — are not
412
+ * duplicates. `allowSeparateTypeImports` additionally keeps clause-level
413
+ * `import type` declarations apart from value imports, and `includeExports`
414
+ * folds `export … from` declarations into the same analysis.
407
415
  *
408
416
  * @reference https://eslint.org/docs/latest/rules/no-duplicate-imports
409
417
  */
410
- "no-duplicate-imports"?: TtscLintRuleSetting;
418
+ "no-duplicate-imports"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoDuplicateImportsRuleOptions>;
411
419
  /**
412
- * Reject an `else` block whose preceding `if` branch already terminates
413
- * control flow with `return`, `throw`, `break`, or `continue` — flatten the
414
- * body into the surrounding scope.
420
+ * Reject an `else` block whose preceding `if` branch returns on every path;
421
+ * flatten the body into the surrounding scope.
415
422
  *
416
423
  * @reference https://eslint.org/docs/latest/rules/no-else-return
417
424
  */
418
- "no-else-return"?: TtscLintRuleSetting;
425
+ "no-else-return"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoElseReturnRuleOptions>;
419
426
  /**
420
- * Reject empty blocks (`if (x) {}`, `while (x) {}`, `try {} catch (e) {}`
421
- * etc.) that almost always indicate forgotten code.
427
+ * Reject empty, uncommented blocks and switches. Set `allowEmptyCatch` to
428
+ * accept an uncommented empty catch clause; its default is `false`.
422
429
  *
423
430
  * @reference https://eslint.org/docs/latest/rules/no-empty
424
431
  */
425
- "no-empty"?: TtscLintRuleSetting;
432
+ "no-empty"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoEmptyRuleOptions>;
426
433
  /**
427
434
  * Reject empty regex character classes (`[]`).
428
435
  *
@@ -433,14 +440,13 @@ export interface ITtscLintCoreRules {
433
440
  */
434
441
  "no-empty-character-class"?: TtscLintRuleSetting;
435
442
  /**
436
- * Reject empty function and method bodies (`function f() {}`, `() => {}`).
437
- *
438
- * Use `() => undefined` or a leading TODO comment when the empty body is
439
- * intentional.
443
+ * Reject empty, uncommented function bodies. The `allow` option accepts
444
+ * canonical function, method, accessor, constructor, async, generator,
445
+ * decorator, and override categories.
440
446
  *
441
447
  * @reference https://eslint.org/docs/latest/rules/no-empty-function
442
448
  */
443
- "no-empty-function"?: TtscLintRuleSetting;
449
+ "no-empty-function"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoEmptyFunctionRuleOptions>;
444
450
  /**
445
451
  * Reject empty named import or export clauses — `import {} from "x"`, `import
446
452
  * name, {} from "x"`, and `export {}` — which bind nothing.
@@ -494,16 +500,17 @@ export interface ITtscLintCoreRules {
494
500
  */
495
501
  "no-ex-assign"?: TtscLintRuleSetting;
496
502
  /**
497
- * Reject assignments to a built-in prototype such as `Array.prototype.foo =
498
- * bar`. Only `<Builtin>.prototype.<key> = …` is flagged; assigning to
499
- * `Object.foo = …` (a static property) is left alone.
503
+ * Reject extending a built-in prototype through direct assignment or
504
+ * `Object.defineProperty` / `Object.defineProperties`. Assigning to a static
505
+ * property such as `Object.foo` is left alone.
500
506
  *
501
507
  * @reference https://eslint.org/docs/latest/rules/no-extend-native
502
508
  */
503
- "no-extend-native"?: TtscLintRuleSetting;
509
+ "no-extend-native"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoExtendNativeRuleOptions>;
504
510
  /**
505
- * Reject unnecessary `Function.prototype.bind()` calls for example, binding
506
- * without arguments or binding an arrow function (which ignores `this`).
511
+ * Reject `.bind(thisArg)` on an arrow function or on a regular function whose
512
+ * own scope never reads `this`. Calls that bind later arguments are preserved
513
+ * as partial applications.
507
514
  *
508
515
  * @reference https://eslint.org/docs/latest/rules/no-extra-bind
509
516
  */
@@ -516,17 +523,26 @@ export interface ITtscLintCoreRules {
516
523
  */
517
524
  "no-extra-boolean-cast"?: TtscLintRuleSetting;
518
525
  /**
519
- * Reject `switch` case fall-through unless preceded by an explicit `// falls
520
- * through` comment.
526
+ * Reject `switch` cases that can reach the next `case` / `default` label
527
+ * without an intentional-fallthrough comment (`// falls through` by
528
+ * default).
529
+ *
530
+ * Reachability follows statement completion: a case whose every path ends in
531
+ * `break`, `continue`, `return`, or `throw` (composed through blocks,
532
+ * `if/else`, loops, labeled statements, and `try/catch/finally`) does not
533
+ * fall through, while a `return` inside a nested function never terminates
534
+ * the case. Options: {@link ITtscLintNoFallthroughRuleOptions}.
521
535
  *
522
536
  * @reference https://eslint.org/docs/latest/rules/no-fallthrough
523
537
  */
524
- "no-fallthrough"?: TtscLintRuleSetting;
538
+ "no-fallthrough"?: TtscLintRuleOptionsSetting<ITtscLintNoFallthroughRuleOptions>;
525
539
  /**
526
- * Reject reassignment of function declarations (`function f() {}; f = 0;`).
540
+ * Reject writes to bindings introduced by function declarations and named
541
+ * function expressions. Lexical binding identity keeps same-spelled shadows
542
+ * independent across parameters, blocks, catches, and sibling scopes.
527
543
  *
528
- * The hoisted binding looks final to most readers; overwriting it makes the
529
- * original implementation unreachable from other references.
544
+ * Direct and compound assignment, updates, destructuring, and for-in/of
545
+ * targets are all modifying references to the function binding.
530
546
  *
531
547
  * @reference https://eslint.org/docs/latest/rules/no-func-assign
532
548
  */
@@ -552,12 +568,13 @@ export interface ITtscLintCoreRules {
552
568
  */
553
569
  "no-import-assign"?: TtscLintRuleSetting;
554
570
  /**
555
- * Reject `function` and `var` declarations nested in non-function blocks
556
- * (loops, `if`, etc.) they hoist in surprising ways.
571
+ * Reject function declarations nested in sloppy blocks. The `"both"` mode
572
+ * also checks `var`; strict ES2015 block-scoped functions are allowed by
573
+ * default and can be disabled through `blockScopedFunctions`.
557
574
  *
558
575
  * @reference https://eslint.org/docs/latest/rules/no-inner-declarations
559
576
  */
560
- "no-inner-declarations"?: TtscLintRuleSetting;
577
+ "no-inner-declarations"?: TtscLintCoreNoInnerDeclarationsRuleSetting;
561
578
  /**
562
579
  * Reject `this` references outside any function-like, class method, or
563
580
  * class-static-block context.
@@ -609,10 +626,9 @@ export interface ITtscLintCoreRules {
609
626
  */
610
627
  "no-lonely-if"?: TtscLintRuleSetting;
611
628
  /**
612
- * Reject function declarations defined inside the body of a loop. Each
613
- * iteration of the loop allocates a fresh function whose closure captures the
614
- * surrounding `let`/`var` binding — a class of bugs where every captured
615
- * function reads the iteration's final value instead of its own.
629
+ * Reject loop-created closures that capture bindings which can change between
630
+ * iterations. Constants, per-iteration `let` bindings, and unreferenced
631
+ * synchronous IIFEs are safe.
616
632
  *
617
633
  * @reference https://eslint.org/docs/latest/rules/no-loop-func
618
634
  */
@@ -645,14 +661,14 @@ export interface ITtscLintCoreRules {
645
661
  * The famous case is `a && b || c`: readers expect left-to-right grouping but
646
662
  * the parser sees `(a && b) || c` because `&&` binds tighter than `||`.
647
663
  *
648
- * The conservative baseline only flags the highest-confusion mixes — logical
649
- * mixed with a different logical (`&&` next to `||` / `??`), and bitwise
650
- * (`&`, `|`, `^`) next to a comparison or logical. Wrapping the inner
651
- * sub-expression in parens suppresses the report.
664
+ * The default groups cover arithmetic, bitwise, comparison, logical, and
665
+ * relational operators, matching ESLint. A custom `groups` option replaces
666
+ * that grouping, while `allowSamePrecedence` controls equal-precedence mixes.
667
+ * Wrapping the inner sub-expression in parens suppresses the report.
652
668
  *
653
669
  * @reference https://eslint.org/docs/latest/rules/no-mixed-operators
654
670
  */
655
- "no-mixed-operators"?: TtscLintRuleSetting;
671
+ "no-mixed-operators"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoMixedOperatorsRuleOptions>;
656
672
  /**
657
673
  * Reject chained assignment such as `a = b = 0`, which obscures intent and
658
674
  * surprises readers who expect comparison.
@@ -745,13 +761,14 @@ export interface ITtscLintCoreRules {
745
761
  */
746
762
  "no-octal-escape"?: TtscLintRuleSetting;
747
763
  /**
748
- * Reject reassigning a function parameter inside the body of the function it
749
- * belongs to. The parameter name stops pointing at the caller's argument
750
- * after the write. Property mutations (`param.foo = …`) are not flagged.
764
+ * Reject writes to a function parameter's binding, including through nested
765
+ * closures and destructuring assignment targets. `props: true` also reports
766
+ * property writes, with the official exact-name and regular-expression ignore
767
+ * lists.
751
768
  *
752
769
  * @reference https://eslint.org/docs/latest/rules/no-param-reassign
753
770
  */
754
- "no-param-reassign"?: TtscLintRuleSetting;
771
+ "no-param-reassign"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoParamReassignRuleOptions>;
755
772
  /**
756
773
  * Reject `++` and `--` operators.
757
774
  *
@@ -762,12 +779,13 @@ export interface ITtscLintCoreRules {
762
779
  */
763
780
  "no-plusplus"?: TtscLintRuleSetting;
764
781
  /**
765
- * Reject `return` inside the Promise executor function — the value is
766
- * ignored.
782
+ * Reject values returned by the global Promise constructor's executor. This
783
+ * covers concise arrows and explicit returns without crossing nested function
784
+ * boundaries. Set `allowVoid` to accept an explicit unary `void` return.
767
785
  *
768
786
  * @reference https://eslint.org/docs/latest/rules/no-promise-executor-return
769
787
  */
770
- "no-promise-executor-return"?: TtscLintRuleSetting;
788
+ "no-promise-executor-return"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoPromiseExecutorReturnRuleOptions>;
771
789
  /**
772
790
  * Reject access to `obj.__proto__`; use `Object.getPrototypeOf` /
773
791
  * `Object.setPrototypeOf`.
@@ -802,25 +820,29 @@ export interface ITtscLintCoreRules {
802
820
  */
803
821
  "no-regex-spaces"?: TtscLintRuleSetting;
804
822
  /**
805
- * Reject `import` declarations targeting any module specifier in the project
806
- * denylist.
823
+ * Reject static imports and re-exports selected by exact paths or patterns.
824
+ * Missing or empty restrictions are a no-op.
807
825
  *
808
826
  * @reference https://eslint.org/docs/latest/rules/no-restricted-imports
809
827
  */
810
- "no-restricted-imports"?: TtscLintRuleSetting;
828
+ "no-restricted-imports"?: TtscLintCoreNoRestrictedImportsRuleSetting;
811
829
  /**
812
- * Reject AST node kinds listed in the project denylist.
830
+ * Reject syntax matching the configured AST selectors. With no selector
831
+ * options the rule is silent; it does not impose a built-in denylist.
832
+ *
833
+ * Native TypeScript-Go kind names and the documented esquery-compatible
834
+ * selector forms are supported, including TypeScript-only syntax.
813
835
  *
814
836
  * @reference https://eslint.org/docs/latest/rules/no-restricted-syntax
815
837
  */
816
- "no-restricted-syntax"?: TtscLintRuleSetting;
838
+ "no-restricted-syntax"?: TtscLintCoreNoRestrictedSyntaxRuleSetting;
817
839
  /**
818
840
  * Reject assignment expressions used as the operand of `return` (`return x =
819
841
  * 1`) — almost always a typo for `===`.
820
842
  *
821
843
  * @reference https://eslint.org/docs/latest/rules/no-return-assign
822
844
  */
823
- "no-return-assign"?: TtscLintRuleSetting;
845
+ "no-return-assign"?: TtscLintCoreNoReturnAssignRuleSetting;
824
846
  /**
825
847
  * Reject `javascript:` URLs in string literals — they execute their body as
826
848
  * code on browser navigation, and security scanners treat them as an `eval`
@@ -959,12 +981,21 @@ export interface ITtscLintCoreRules {
959
981
  */
960
982
  "no-unsafe-optional-chaining"?: TtscLintRuleSetting;
961
983
  /**
962
- * Reject expression statements with no observable effect, like a bare `x;` or
963
- * `'use strict' && f();`.
984
+ * Reject expression statements with no observable effect, like a bare `x;`,
985
+ * `a === b;`, or a tagged template literal statement.
986
+ *
987
+ * Directive prologues — the leading run of string-literal statements at the
988
+ * top of a script, module, namespace body, or function body — are accepted
989
+ * whatever their text (`"use strict"`, `"use client"`, …); the same strings
990
+ * elsewhere are rejected. Productive expressions (calls, `new`, assignments,
991
+ * updates, `delete`, `void`, `await`, `yield`) are accepted, and JSX is
992
+ * accepted unless
993
+ * {@link ITtscLintCoreNoUnusedExpressionsRuleOptions.enforceForJSX} is
994
+ * enabled.
964
995
  *
965
996
  * @reference https://eslint.org/docs/latest/rules/no-unused-expressions
966
997
  */
967
- "no-unused-expressions"?: TtscLintRuleSetting;
998
+ "no-unused-expressions"?: TtscLintRuleOptionsSetting<ITtscLintCoreNoUnusedExpressionsRuleOptions>;
968
999
  /**
969
1000
  * Reject labels that no `break` or `continue` statement references.
970
1001
  *
@@ -1083,12 +1114,15 @@ export interface ITtscLintCoreRules {
1083
1114
  */
1084
1115
  "prefer-arrow-callback"?: TtscLintRuleSetting;
1085
1116
  /**
1086
- * Require `const` for variables that are never reassigned after declaration.
1087
- * Autofixable for single-declaration `let`s.
1117
+ * Require `const` for lexical bindings that are never reassigned after their
1118
+ * initial value is established. Declaration-only and destructured bindings
1119
+ * follow ESLint's `ignoreReadBeforeAssign` and `destructuring` options.
1120
+ * Autofixable when one initialized declaration can safely change its shared
1121
+ * `let` keyword.
1088
1122
  *
1089
1123
  * @reference https://eslint.org/docs/latest/rules/prefer-const
1090
1124
  */
1091
- "prefer-const"?: TtscLintRuleSetting;
1125
+ "prefer-const"?: TtscLintRuleOptionsSetting<ITtscLintCorePreferConstRuleOptions>;
1092
1126
  /**
1093
1127
  * Reject single-property and single-index variable declarations (`const a =
1094
1128
  * obj.a`, `const x = arr[0]`) that destructuring would replace verbatim.
@@ -91,10 +91,15 @@ export interface ITtscLintRegexpRules {
91
91
  "regexp/no-useless-escape"?: TtscLintRuleSetting;
92
92
  /**
93
93
  * Reject regex flags that the literal does not exercise — `i` on a pattern
94
- * without case-variable characters, `m` without `^`/`$`, `s` without `.`, and
95
- * similar dead flags on `g`/`y`.
94
+ * with no case-variable character, `m` on a pattern with no `^`/`$`
95
+ * assertion.
96
96
  *
97
97
  * Cleans up flag combos that suggest behavior the pattern can never trigger.
98
+ * A character is case-variable wherever it sits, so `/[a-z]/i` keeps its flag
99
+ * (the flag is what extends the class to `A-Z`), and a `^` or `$` inside a
100
+ * character class is a plain character that does not save `m`. Patterns the
101
+ * rule cannot settle from the source — a Unicode property escape, a
102
+ * backreference, a `v`-mode set-notation class — count as using the flag.
98
103
  *
99
104
  * @reference https://ota-meshi.github.io/eslint-plugin-regexp/rules/no-useless-flag.html
100
105
  */
@@ -1,33 +1,54 @@
1
+ import type { TtscLintRuleOptionsSetting } from "../TtscLintRuleSetting";
1
2
  import type { ITtscLintBoundariesDependenciesRuleOptions, ITtscLintBoundariesElementTypesRuleOptions, ITtscLintBoundariesEntryPointRuleOptions, ITtscLintBoundariesExternalRuleOptions, ITtscLintBoundariesNoPrivateRuleOptions, ITtscLintBoundariesNoUnknownRuleOptions } from "./ITtscLintBoundariesRuleOptions";
3
+ import type { ITtscLintCoreDefaultCaseRuleOptions, ITtscLintCoreNoDuplicateImportsRuleOptions, ITtscLintCoreNoElseReturnRuleOptions, ITtscLintCoreNoEmptyFunctionRuleOptions, ITtscLintCoreNoEmptyRuleOptions, ITtscLintCoreNoExtendNativeRuleOptions, ITtscLintCoreNoMixedOperatorsRuleOptions, ITtscLintCoreNoParamReassignRuleOptions, ITtscLintCoreNoPromiseExecutorReturnRuleOptions, ITtscLintCoreNoUnusedExpressionsRuleOptions, ITtscLintCorePreferConstRuleOptions, ITtscLintNoFallthroughRuleOptions } from "./ITtscLintCoreRuleOptions";
2
4
  import type { ITtscLintCypressUnsafeToChainCommandRuleOptions } from "./ITtscLintCypressRuleOptions";
3
5
  import type { ITtscLintFunctionalEmptyRuleOptions, ITtscLintFunctionalImmutableDataRuleOptions, ITtscLintFunctionalNoConditionalStatementsRuleOptions, ITtscLintFunctionalNoLetRuleOptions, ITtscLintFunctionalNoMixedTypesRuleOptions, ITtscLintFunctionalNoReturnVoidRuleOptions, ITtscLintFunctionalNoThrowStatementsRuleOptions, ITtscLintFunctionalNoTryStatementsRuleOptions, ITtscLintFunctionalParametersRuleOptions, ITtscLintFunctionalPreferImmutableTypesRuleOptions, ITtscLintFunctionalPreferReadonlyTypeRuleOptions, ITtscLintFunctionalPreferTacitRuleOptions, ITtscLintFunctionalReadonlyTypeRuleOptions, ITtscLintFunctionalTypeDeclarationImmutabilityRuleOptions } from "./ITtscLintFunctionalRuleOptions";
4
6
  import type { ITtscLintReactPerfRuleOptions } from "./ITtscLintReactPerfRuleOptions";
5
7
  import type { ITtscLintReactOnlyExportComponentsRuleOptions } from "./ITtscLintReactRuleOptions";
6
8
  import type { ITtscLintStorybookNoUninstalledAddonsRuleOptions } from "./ITtscLintStorybookRuleOptions";
7
9
  import type { ITtscLintTestingLibraryConsistentDataTestIdRuleOptions } from "./ITtscLintTestingLibraryRuleOptions";
10
+ import type { ITtscLintTypeScriptBanTsCommentRuleOptions, ITtscLintTypeScriptNoFloatingPromisesRuleOptions, ITtscLintTypeScriptNoMisusedPromisesRuleOptions, ITtscLintTypeScriptNoRestrictedTypesRuleOptions, ITtscLintTypeScriptSwitchExhaustivenessCheckRuleOptions } from "./ITtscLintTypeScriptRuleOptions";
11
+ import type { ITtscLintUnicornBetterRegexRuleOptions, ITtscLintUnicornConsistentFunctionScopingRuleOptions, ITtscLintUnicornFilenameCaseRuleOptions, ITtscLintUnicornImportStyleRuleOptions, ITtscLintUnicornIsolatedFunctionsRuleOptions, ITtscLintUnicornNoTypeofUndefinedRuleOptions, ITtscLintUnicornNoUnnecessaryPolyfillsRuleOptions, ITtscLintUnicornPreferNumberPropertiesRuleOptions, ITtscLintUnicornPreventAbbreviationsRuleOptions, ITtscLintUnicornStringContentRuleOptions, ITtscLintUnicornTemplateIndentRuleOptions, ITtscLintUnicornTextEncodingIdentifierCaseRuleOptions } from "./ITtscLintUnicornRuleOptions";
8
12
  /**
9
- * Index from typed rule name to its options object.
13
+ * Index from typed rule name to its single options-object slot.
10
14
  *
11
- * Built-in rule families with configurable options are listed here. Contributor
12
- * plugins extend the map by augmenting it from their own package:
15
+ * Built-in rule families with one object option are listed here. Rules with
16
+ * canonical positional lists expose dedicated setting types instead.
17
+ * Contributor plugins extend the map by augmenting it from their own package:
13
18
  *
14
19
  * ```ts
15
20
  * declare module "@ttsc/lint" {
16
21
  * interface ITtscLintRuleOptionsMap {
17
- * "demo/no-marker-comment": { marker: string };
22
+ * "demo/no-marker-comment": { markers?: readonly string[] };
18
23
  * }
19
24
  * }
20
25
  * ```
21
26
  *
22
- * After augmentation, `{@link TtscLintRuleOptionsSetting}` tuples and the
23
- * `defineConfig`-style helpers in plugin packages can type-check the options
24
- * object against the contributor's declared shape.
27
+ * {@link TtscLintRuleOptionsOverlay} maps every entry to its strongly typed
28
+ * severity tuple. {@link ITtscLintRules} intersects that overlay with the
29
+ * built-in families and the open contributor fallback, so importing a plugin's
30
+ * augmentation tightens its registered rule while unknown contributor names
31
+ * retain the backward-compatible `unknown` options slot.
25
32
  *
26
33
  * `format/*` is **not** listed: formatter behavior is configured through the
27
34
  * top-level `format` block ({@link ITtscLintFormat}), not through the `rules`
28
35
  * surface.
29
36
  */
30
37
  export interface ITtscLintRuleOptionsMap {
38
+ "default-case": ITtscLintCoreDefaultCaseRuleOptions;
39
+ "unicorn/template-indent": ITtscLintUnicornTemplateIndentRuleOptions;
40
+ "typescript/no-floating-promises": ITtscLintTypeScriptNoFloatingPromisesRuleOptions;
41
+ "no-duplicate-imports": ITtscLintCoreNoDuplicateImportsRuleOptions;
42
+ "no-else-return": ITtscLintCoreNoElseReturnRuleOptions;
43
+ "no-empty": ITtscLintCoreNoEmptyRuleOptions;
44
+ "no-empty-function": ITtscLintCoreNoEmptyFunctionRuleOptions;
45
+ "no-extend-native": ITtscLintCoreNoExtendNativeRuleOptions;
46
+ "no-mixed-operators": ITtscLintCoreNoMixedOperatorsRuleOptions;
47
+ "no-param-reassign": ITtscLintCoreNoParamReassignRuleOptions;
48
+ "no-promise-executor-return": ITtscLintCoreNoPromiseExecutorReturnRuleOptions;
49
+ "no-unused-expressions": ITtscLintCoreNoUnusedExpressionsRuleOptions;
50
+ "no-fallthrough": ITtscLintNoFallthroughRuleOptions;
51
+ "prefer-const": ITtscLintCorePreferConstRuleOptions;
31
52
  "testing-library/consistent-data-testid": ITtscLintTestingLibraryConsistentDataTestIdRuleOptions;
32
53
  "functional/functional-parameters": ITtscLintFunctionalParametersRuleOptions;
33
54
  "functional/immutable-data": ITtscLintFunctionalImmutableDataRuleOptions;
@@ -62,4 +83,29 @@ export interface ITtscLintRuleOptionsMap {
62
83
  "react-perf/jsx-no-jsx-as-prop": ITtscLintReactPerfRuleOptions;
63
84
  "storybook/no-uninstalled-addons": ITtscLintStorybookNoUninstalledAddonsRuleOptions;
64
85
  "react/only-export-components": ITtscLintReactOnlyExportComponentsRuleOptions;
86
+ "typescript/ban-ts-comment": ITtscLintTypeScriptBanTsCommentRuleOptions;
87
+ "typescript/no-misused-promises": ITtscLintTypeScriptNoMisusedPromisesRuleOptions;
88
+ "typescript/no-restricted-types": ITtscLintTypeScriptNoRestrictedTypesRuleOptions;
89
+ "typescript/switch-exhaustiveness-check": ITtscLintTypeScriptSwitchExhaustivenessCheckRuleOptions;
90
+ "unicorn/consistent-function-scoping": ITtscLintUnicornConsistentFunctionScopingRuleOptions;
91
+ "unicorn/better-regex": ITtscLintUnicornBetterRegexRuleOptions;
92
+ "unicorn/prevent-abbreviations": ITtscLintUnicornPreventAbbreviationsRuleOptions;
93
+ "unicorn/import-style": ITtscLintUnicornImportStyleRuleOptions;
94
+ "unicorn/filename-case": ITtscLintUnicornFilenameCaseRuleOptions;
95
+ "unicorn/string-content": ITtscLintUnicornStringContentRuleOptions;
96
+ "unicorn/isolated-functions": ITtscLintUnicornIsolatedFunctionsRuleOptions;
97
+ "unicorn/no-typeof-undefined": ITtscLintUnicornNoTypeofUndefinedRuleOptions;
98
+ "unicorn/no-unnecessary-polyfills": ITtscLintUnicornNoUnnecessaryPolyfillsRuleOptions;
99
+ "unicorn/prefer-number-properties": ITtscLintUnicornPreferNumberPropertiesRuleOptions;
100
+ "unicorn/text-encoding-identifier-case": ITtscLintUnicornTextEncodingIdentifierCaseRuleOptions;
65
101
  }
102
+ /**
103
+ * Strongly typed rule settings derived from the augmentable options map.
104
+ *
105
+ * This mapped overlay is consumed by {@link ITtscLintRules}; keeping the
106
+ * derivation here makes module augmentation immediately affect the public
107
+ * configuration type without a second per-plugin rule-name declaration.
108
+ */
109
+ export type TtscLintRuleOptionsOverlay = {
110
+ [TRuleName in keyof ITtscLintRuleOptionsMap]?: TtscLintRuleOptionsSetting<ITtscLintRuleOptionsMap[TRuleName]>;
111
+ };
@@ -12,6 +12,7 @@ import type { ITtscLintPromiseRules } from "./ITtscLintPromiseRules";
12
12
  import type { ITtscLintReactPerfRules } from "./ITtscLintReactPerfRules";
13
13
  import type { ITtscLintReactRules } from "./ITtscLintReactRules";
14
14
  import type { ITtscLintRegexpRules } from "./ITtscLintRegexpRules";
15
+ import type { TtscLintRuleOptionsOverlay } from "./ITtscLintRuleOptionsMap";
15
16
  import type { ITtscLintSecurityRules } from "./ITtscLintSecurityRules";
16
17
  import type { ITtscLintSolidRules } from "./ITtscLintSolidRules";
17
18
  import type { ITtscLintStorybookRules } from "./ITtscLintStorybookRules";
@@ -50,6 +51,9 @@ import type { ITtscLintVitestRules } from "./ITtscLintVitestRules";
50
51
  * public rules surface.
51
52
  * - Any other `"<namespace>/<rule>"` key is accepted via
52
53
  * {@link ITtscLintContributorRules} so plugin-shipped rules compose cleanly
53
- * without ambient module augmentation.
54
+ * without ambient module augmentation. A plugin can augment
55
+ * `ITtscLintRuleOptionsMap`; {@link TtscLintRuleOptionsOverlay} then tightens
56
+ * that rule's options while the open fallback remains for unregistered
57
+ * contributor names.
54
58
  */
55
- export type ITtscLintRules = ITtscLintCoreRules & ITtscLintTypeScriptRules & ITtscLintBoundariesRules & ITtscLintCypressRules & ITtscLintFunctionalRules & ITtscLintJestRules & ITtscLintJsdocRules & ITtscLintJsxA11yRules & ITtscLintNextjsRules & ITtscLintPlaywrightRules & ITtscLintPromiseRules & ITtscLintReactRules & ITtscLintReactPerfRules & ITtscLintRegexpRules & ITtscLintSecurityRules & ITtscLintSolidRules & ITtscLintStorybookRules & ITtscLintTanstackQueryRules & ITtscLintTestingLibraryRules & ITtscLintUnicornRules & ITtscLintVitestRules & ITtscLintContributorRules;
59
+ export type ITtscLintRules = ITtscLintCoreRules & ITtscLintTypeScriptRules & ITtscLintBoundariesRules & ITtscLintCypressRules & ITtscLintFunctionalRules & ITtscLintJestRules & ITtscLintJsdocRules & ITtscLintJsxA11yRules & ITtscLintNextjsRules & ITtscLintPlaywrightRules & ITtscLintPromiseRules & ITtscLintReactRules & ITtscLintReactPerfRules & ITtscLintRegexpRules & ITtscLintSecurityRules & ITtscLintSolidRules & ITtscLintStorybookRules & ITtscLintTanstackQueryRules & ITtscLintTestingLibraryRules & ITtscLintUnicornRules & ITtscLintVitestRules & ITtscLintContributorRules & TtscLintRuleOptionsOverlay;
@@ -57,14 +57,6 @@ export interface ITtscLintSolidRules {
57
57
  * @reference https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/jsx-no-undef.md
58
58
  */
59
59
  "solid/jsx-no-undef"?: TtscLintRuleSetting;
60
- /**
61
- * Scope-marker compatibility rule (mirrors ESLint's `react/jsx-uses-vars`).
62
- *
63
- * The native engine emits no diagnostics for this id.
64
- *
65
- * @reference https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/jsx-uses-vars.md
66
- */
67
- "solid/jsx-uses-vars"?: TtscLintRuleSetting;
68
60
  /**
69
61
  * Reject array values passed as Solid event handlers — Solid does not unwrap
70
62
  * the array form React supports.