@ttsc/lint 0.14.0-dev.20260529.1 → 0.14.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/README.md +85 -87
- package/lib/defaultFormat.d.ts +10 -6
- package/lib/defaultFormat.js +10 -6
- package/lib/defaultFormat.js.map +1 -1
- package/lib/structures/ITtscLintConfig.d.ts +5 -5
- package/lib/structures/TtscLintRuleSetting.d.ts +19 -19
- package/lib/structures/{ITtscLintFormat.d.ts → format/ITtscLintFormat.d.ts} +45 -70
- package/lib/structures/format/ITtscLintFormat.js.map +1 -0
- package/lib/structures/format/ITtscLintFormatJsDoc.d.ts +15 -0
- package/lib/structures/format/ITtscLintFormatJsDoc.js +3 -0
- package/lib/structures/format/ITtscLintFormatJsDoc.js.map +1 -0
- package/lib/structures/format/ITtscLintFormatSortImports.d.ts +54 -0
- package/lib/structures/format/ITtscLintFormatSortImports.js +3 -0
- package/lib/structures/format/ITtscLintFormatSortImports.js.map +1 -0
- package/lib/structures/format/index.d.ts +3 -0
- package/lib/structures/format/index.js +20 -0
- package/lib/structures/format/index.js.map +1 -0
- package/lib/structures/index.d.ts +1 -1
- package/lib/structures/index.js +1 -1
- package/lib/structures/index.js.map +1 -1
- package/lib/structures/rules/ITtscLintBoundariesRuleOptions.d.ts +18 -27
- package/lib/structures/rules/ITtscLintBoundariesRuleOptions.js +4 -5
- package/lib/structures/rules/ITtscLintBoundariesRuleOptions.js.map +1 -1
- package/lib/structures/rules/ITtscLintBoundariesRules.d.ts +29 -33
- package/lib/structures/rules/ITtscLintContributorRules.d.ts +6 -7
- package/lib/structures/rules/ITtscLintCoreRules.d.ts +380 -408
- package/lib/structures/rules/ITtscLintCypressRuleOptions.d.ts +5 -5
- package/lib/structures/rules/ITtscLintCypressRuleOptions.js +2 -2
- package/lib/structures/rules/ITtscLintCypressRules.d.ts +34 -38
- package/lib/structures/rules/ITtscLintFunctionalRuleOptions.d.ts +21 -24
- package/lib/structures/rules/ITtscLintFunctionalRuleOptions.js +2 -2
- package/lib/structures/rules/ITtscLintFunctionalRules.d.ts +51 -56
- package/lib/structures/rules/ITtscLintJestRules.d.ts +63 -74
- package/lib/structures/rules/ITtscLintJsdocRules.d.ts +47 -54
- package/lib/structures/rules/ITtscLintJsxA11yRules.d.ts +94 -102
- package/lib/structures/rules/ITtscLintNextjsRules.d.ts +50 -55
- package/lib/structures/rules/ITtscLintPlaywrightRules.d.ts +104 -122
- package/lib/structures/rules/ITtscLintPromiseRules.d.ts +62 -71
- package/lib/structures/rules/ITtscLintReactPerfRuleOptions.d.ts +4 -4
- package/lib/structures/rules/ITtscLintReactPerfRules.d.ts +17 -19
- package/lib/structures/rules/ITtscLintReactRuleOptions.d.ts +8 -10
- package/lib/structures/rules/ITtscLintReactRuleOptions.js +1 -2
- package/lib/structures/rules/ITtscLintReactRuleOptions.js.map +1 -1
- package/lib/structures/rules/ITtscLintReactRules.d.ts +91 -104
- package/lib/structures/rules/ITtscLintRegexpRules.d.ts +46 -54
- package/lib/structures/rules/ITtscLintRuleOptionsMap.d.ts +7 -8
- package/lib/structures/rules/ITtscLintSecurityRules.d.ts +45 -52
- package/lib/structures/rules/ITtscLintSolidRules.d.ts +53 -56
- package/lib/structures/rules/ITtscLintStorybookRuleOptions.d.ts +3 -4
- package/lib/structures/rules/ITtscLintStorybookRules.d.ts +60 -69
- package/lib/structures/rules/ITtscLintTanstackQueryRules.d.ts +31 -37
- package/lib/structures/rules/ITtscLintTestingLibraryRuleOptions.d.ts +2 -3
- package/lib/structures/rules/ITtscLintTestingLibraryRules.d.ts +102 -119
- package/lib/structures/rules/ITtscLintTypeScriptRules.d.ts +460 -518
- package/lib/structures/rules/ITtscLintVitestRules.d.ts +43 -51
- package/linthost/config.go +89 -72
- package/linthost/config_format.go +265 -99
- package/linthost/directives.go +5 -1
- package/linthost/display_width.go +72 -0
- package/linthost/fix.go +26 -1
- package/linthost/format.go +222 -25
- package/linthost/format_editor_settings.go +262 -0
- package/linthost/lsp.go +8 -4
- package/linthost/print_dispatch.go +3 -0
- package/linthost/print_doc.go +13 -0
- package/linthost/print_engine.go +68 -11
- package/linthost/print_nodes_array.go +108 -5
- package/linthost/print_nodes_call.go +515 -74
- package/linthost/print_nodes_function.go +25 -0
- package/linthost/print_nodes_imports.go +47 -14
- package/linthost/print_nodes_list.go +191 -8
- package/linthost/print_nodes_object.go +12 -6
- package/linthost/print_nodes_ternary.go +106 -0
- package/linthost/rules_boundaries.go +400 -400
- package/linthost/rules_camelcase.go +81 -81
- package/linthost/rules_complexity.go +52 -51
- package/linthost/rules_consistent_return.go +81 -81
- package/linthost/rules_core_extra.go +472 -472
- package/linthost/rules_curly.go +43 -43
- package/linthost/rules_default_case.go +15 -15
- package/linthost/rules_default_case_last.go +22 -22
- package/linthost/rules_format_arrow_parens.go +167 -0
- package/linthost/rules_format_bracket_spacing.go +117 -0
- package/linthost/rules_format_clause_join.go +172 -0
- package/linthost/rules_format_declaration_header.go +664 -0
- package/linthost/rules_format_indent.go +616 -0
- package/linthost/rules_format_jsdoc.go +4 -4
- package/linthost/rules_format_orphan_semi.go +106 -0
- package/linthost/rules_format_parameter_properties.go +175 -0
- package/linthost/rules_format_print_width.go +185 -69
- package/linthost/rules_format_quote_props.go +169 -0
- package/linthost/rules_format_quotes.go +75 -29
- package/linthost/rules_format_semi.go +185 -10
- package/linthost/rules_format_sort_imports.go +456 -121
- package/linthost/rules_format_statement_split.go +368 -0
- package/linthost/rules_format_ternary_nullish_parens.go +77 -0
- package/linthost/rules_format_trailing_comma.go +21 -2
- package/linthost/rules_format_whitespace.go +336 -0
- package/linthost/rules_functional.go +688 -688
- package/linthost/rules_gap.go +146 -11
- package/linthost/rules_grouped_accessor_pairs.go +60 -60
- package/linthost/rules_guard_for_in.go +122 -122
- package/linthost/rules_id_length.go +44 -44
- package/linthost/rules_imports.go +11 -3
- package/linthost/rules_init_declarations.go +25 -25
- package/linthost/rules_jsx_a11y.go +844 -844
- package/linthost/rules_max_classes_per_file.go +24 -24
- package/linthost/rules_max_depth.go +43 -43
- package/linthost/rules_max_lines.go +53 -53
- package/linthost/rules_max_lines_per_function.go +28 -28
- package/linthost/rules_max_nested_callbacks.go +26 -26
- package/linthost/rules_max_params.go +20 -20
- package/linthost/rules_max_statements.go +29 -29
- package/linthost/rules_nextjs.go +5 -5
- package/linthost/rules_no_else_return.go +38 -38
- package/linthost/rules_no_empty_named_blocks.go +45 -45
- package/linthost/rules_no_import_assign.go +96 -96
- package/linthost/rules_no_invalid_this.go +19 -19
- package/linthost/rules_no_loop_func.go +43 -43
- package/linthost/rules_no_magic_numbers.go +60 -60
- package/linthost/rules_no_mixed_operators.go +44 -44
- package/linthost/rules_no_param_reassign.go +64 -64
- package/linthost/rules_no_restricted_imports.go +45 -45
- package/linthost/rules_no_restricted_syntax.go +17 -17
- package/linthost/rules_no_shadow.go +112 -112
- package/linthost/rules_no_unreachable.go +36 -36
- package/linthost/rules_no_useless_assignment.go +79 -79
- package/linthost/rules_no_useless_constructor.go +167 -167
- package/linthost/rules_no_useless_return.go +28 -28
- package/linthost/rules_prefer_arrow_callback.go +74 -74
- package/linthost/rules_prefer_destructuring.go +61 -61
- package/linthost/rules_prefer_named_capture_group.go +87 -87
- package/linthost/rules_prefer_rest_params.go +61 -61
- package/linthost/rules_promise.go +800 -800
- package/linthost/rules_react.go +600 -600
- package/linthost/rules_react_extras.go +162 -162
- package/linthost/rules_react_hooks.go +2 -2
- package/linthost/rules_react_perf.go +231 -231
- package/linthost/rules_regexp.go +293 -293
- package/linthost/rules_security.go +613 -613
- package/linthost/rules_sort_imports.go +37 -37
- package/linthost/rules_sort_keys.go +88 -88
- package/linthost/rules_suggestions.go +13 -0
- package/linthost/rules_ts.go +2 -2
- package/linthost/rules_ts_async.go +247 -247
- package/linthost/rules_ts_class_literal_property_style.go +64 -64
- package/linthost/rules_ts_consistent_type_exports.go +209 -209
- package/linthost/rules_ts_explicit_function_return_type.go +35 -35
- package/linthost/rules_ts_extra.go +6 -2
- package/linthost/rules_ts_no_base_to_string.go +140 -140
- package/linthost/rules_ts_no_confusing_void.go +28 -28
- package/linthost/rules_ts_no_deprecated.go +110 -110
- package/linthost/rules_ts_no_for_in_array.go +45 -45
- package/linthost/rules_ts_no_magic_numbers.go +67 -67
- package/linthost/rules_ts_no_meaningless_void_operator.go +44 -44
- package/linthost/rules_ts_no_misused_spread.go +64 -64
- package/linthost/rules_ts_no_redundant_type_constituents.go +72 -72
- package/linthost/rules_ts_no_restricted_types.go +28 -28
- package/linthost/rules_ts_no_unnecessary_boolean_literal_compare.go +87 -87
- package/linthost/rules_ts_no_unnecessary_condition.go +184 -184
- package/linthost/rules_ts_no_unnecessary_qualifier.go +72 -72
- package/linthost/rules_ts_no_unnecessary_template_expression.go +120 -120
- package/linthost/rules_ts_no_unnecessary_type_arguments.go +171 -171
- package/linthost/rules_ts_no_unnecessary_type_assertion.go +90 -90
- package/linthost/rules_ts_no_unsafe_argument.go +50 -50
- package/linthost/rules_ts_no_unsafe_assignment.go +60 -60
- package/linthost/rules_ts_no_unsafe_call.go +40 -40
- package/linthost/rules_ts_no_unsafe_enum_comparison.go +147 -147
- package/linthost/rules_ts_no_unsafe_member_access.go +29 -29
- package/linthost/rules_ts_no_unsafe_return.go +64 -64
- package/linthost/rules_ts_no_unsafe_unary_minus.go +42 -42
- package/linthost/rules_ts_no_useless_constructor.go +20 -20
- package/linthost/rules_ts_non_nullable_type_assertion_style.go +60 -60
- package/linthost/rules_ts_parameter_properties.go +10 -10
- package/linthost/rules_ts_prefer_find.go +116 -116
- package/linthost/rules_ts_prefer_includes.go +173 -173
- package/linthost/rules_ts_prefer_nullish_coalescing.go +54 -54
- package/linthost/rules_ts_prefer_optional_chain.go +156 -156
- package/linthost/rules_ts_prefer_promise_reject_errors.go +104 -104
- package/linthost/rules_ts_prefer_readonly.go +31 -31
- package/linthost/rules_ts_prefer_reduce_type_parameter.go +74 -74
- package/linthost/rules_ts_prefer_regexp_exec.go +69 -69
- package/linthost/rules_ts_prefer_return_this_type.go +79 -79
- package/linthost/rules_ts_prefer_string_starts_ends_with.go +237 -237
- package/linthost/rules_ts_promise_function_async.go +41 -41
- package/linthost/rules_ts_related_getter_setter_pairs.go +61 -61
- package/linthost/rules_ts_require_array_sort_compare.go +58 -58
- package/linthost/rules_ts_restrict_plus_operands.go +82 -82
- package/linthost/rules_ts_restrict_template_expressions.go +50 -50
- package/linthost/rules_ts_simple.go +249 -249
- package/linthost/rules_ts_sort_type_constituents.go +88 -88
- package/linthost/rules_ts_strict_boolean_expressions.go +103 -103
- package/linthost/rules_ts_switch_exhaustiveness_check.go +90 -90
- package/linthost/rules_ts_unbound_method.go +65 -65
- package/linthost/rules_tsdoc.go +88 -88
- package/linthost/rules_unicorn_better_regex.go +1 -1
- package/linthost/rules_unicorn_catch_error_name.go +19 -19
- package/linthost/rules_unicorn_consistent_assert.go +20 -20
- package/linthost/rules_unicorn_consistent_date_clone.go +27 -27
- package/linthost/rules_unicorn_consistent_destructuring.go +3 -3
- package/linthost/rules_unicorn_consistent_empty_array_spread.go +34 -34
- package/linthost/rules_unicorn_consistent_existence_index_check.go +42 -42
- package/linthost/rules_unicorn_consistent_function_scoping.go +3 -3
- package/linthost/rules_unicorn_consistent_template_literal_escape.go +3 -3
- package/linthost/rules_unicorn_custom_error_definition.go +92 -92
- package/linthost/rules_unicorn_empty_brace_spaces.go +47 -47
- package/linthost/rules_unicorn_error_message.go +34 -34
- package/linthost/rules_unicorn_escape_case.go +14 -14
- package/linthost/rules_unicorn_expiring_todo_comments.go +36 -36
- package/linthost/rules_unicorn_explicit_length_check.go +51 -51
- package/linthost/rules_unicorn_filename_case.go +1 -1
- package/linthost/rules_unicorn_import_style.go +1 -1
- package/linthost/rules_unicorn_isolated_functions.go +2 -2
- package/linthost/rules_unicorn_new_for_builtins.go +49 -49
- package/linthost/rules_unicorn_no_abusive_eslint_disable.go +31 -31
- package/linthost/rules_unicorn_no_accessor_recursion.go +69 -69
- package/linthost/rules_unicorn_no_anonymous_default_export.go +40 -40
- package/linthost/rules_unicorn_no_array_callback_reference.go +33 -33
- package/linthost/rules_unicorn_no_array_for_each.go +14 -14
- package/linthost/rules_unicorn_no_array_method_this_argument.go +29 -29
- package/linthost/rules_unicorn_no_array_reduce.go +15 -15
- package/linthost/rules_unicorn_no_array_reverse.go +17 -17
- package/linthost/rules_unicorn_no_array_sort.go +17 -17
- package/linthost/rules_unicorn_no_await_expression_member.go +12 -12
- package/linthost/rules_unicorn_no_await_in_promise_methods.go +38 -38
- package/linthost/rules_unicorn_no_console_spaces.go +30 -30
- package/linthost/rules_unicorn_no_document_cookie.go +13 -13
- package/linthost/rules_unicorn_no_empty_file.go +16 -16
- package/linthost/rules_unicorn_no_for_loop.go +58 -58
- package/linthost/rules_unicorn_no_hex_escape.go +11 -11
- package/linthost/rules_unicorn_no_immediate_mutation.go +55 -55
- package/linthost/rules_unicorn_no_instanceof_builtins.go +34 -34
- package/linthost/rules_unicorn_no_invalid_fetch_options.go +52 -52
- package/linthost/rules_unicorn_no_invalid_remove_event_listener.go +25 -25
- package/linthost/rules_unicorn_no_keyword_prefix.go +56 -56
- package/linthost/rules_unicorn_no_lonely_if.go +21 -21
- package/linthost/rules_unicorn_no_magic_array_flat_depth.go +22 -22
- package/linthost/rules_unicorn_no_named_default.go +25 -25
- package/linthost/rules_unicorn_no_negated_condition.go +54 -54
- package/linthost/rules_unicorn_no_negation_in_equality_check.go +23 -23
- package/linthost/rules_unicorn_no_nested_ternary.go +15 -15
- package/linthost/rules_unicorn_no_new_array.go +5 -5
- package/linthost/rules_unicorn_no_new_buffer.go +5 -5
- package/linthost/rules_unicorn_no_null.go +2 -2
- package/linthost/rules_unicorn_no_object_as_default_parameter.go +19 -19
- package/linthost/rules_unicorn_no_process_exit.go +17 -17
- package/linthost/rules_unicorn_no_single_promise_in_promise_methods.go +29 -29
- package/linthost/rules_unicorn_no_static_only_class.go +27 -27
- package/linthost/rules_unicorn_no_thenable.go +47 -47
- package/linthost/rules_unicorn_no_this_assignment.go +10 -10
- package/linthost/rules_unicorn_no_typeof_undefined.go +31 -31
- package/linthost/rules_unicorn_no_unnecessary_array_flat_depth.go +23 -23
- package/linthost/rules_unicorn_no_unnecessary_array_splice_count.go +37 -37
- package/linthost/rules_unicorn_no_unnecessary_await.go +24 -24
- package/linthost/rules_unicorn_no_unnecessary_slice_end.go +22 -22
- package/linthost/rules_unicorn_no_unreadable_array_destructuring.go +67 -67
- package/linthost/rules_unicorn_no_unreadable_iife.go +22 -22
- package/linthost/rules_unicorn_no_useless_collection_argument.go +34 -34
- package/linthost/rules_unicorn_no_useless_error_capture_stack_trace.go +18 -18
- package/linthost/rules_unicorn_no_useless_fallback_in_spread.go +49 -49
- package/linthost/rules_unicorn_no_useless_iterator_to_array.go +41 -41
- package/linthost/rules_unicorn_no_useless_length_check.go +82 -82
- package/linthost/rules_unicorn_no_useless_promise_resolve_reject.go +42 -42
- package/linthost/rules_unicorn_no_useless_spread.go +38 -38
- package/linthost/rules_unicorn_no_useless_switch_case.go +29 -29
- package/linthost/rules_unicorn_no_useless_undefined.go +25 -25
- package/linthost/rules_unicorn_no_zero_fractions.go +17 -17
- package/linthost/rules_unicorn_number_literal_case.go +33 -33
- package/linthost/rules_unicorn_numeric_separators_style.go +36 -36
- package/linthost/rules_unicorn_prefer_add_event_listener.go +30 -30
- package/linthost/rules_unicorn_prefer_array_find.go +27 -27
- package/linthost/rules_unicorn_prefer_array_flat.go +25 -25
- package/linthost/rules_unicorn_prefer_array_flat_map.go +37 -37
- package/linthost/rules_unicorn_prefer_array_index_of.go +108 -108
- package/linthost/rules_unicorn_prefer_array_some.go +43 -43
- package/linthost/rules_unicorn_prefer_at.go +42 -42
- package/linthost/rules_unicorn_prefer_bigint_literals.go +42 -42
- package/linthost/rules_unicorn_prefer_blob_reading_methods.go +15 -15
- package/linthost/rules_unicorn_prefer_class_fields.go +57 -57
- package/linthost/rules_unicorn_prefer_classlist_toggle.go +76 -76
- package/linthost/rules_unicorn_prefer_code_point.go +21 -21
- package/linthost/rules_unicorn_prefer_date_now.go +47 -47
- package/linthost/rules_unicorn_prefer_default_parameters.go +96 -96
- package/linthost/rules_unicorn_prefer_dom_node_append.go +14 -14
- package/linthost/rules_unicorn_prefer_dom_node_dataset.go +27 -27
- package/linthost/rules_unicorn_prefer_dom_node_remove.go +17 -17
- package/linthost/rules_unicorn_prefer_dom_node_text_content.go +11 -11
- package/linthost/rules_unicorn_prefer_event_target.go +10 -10
- package/linthost/rules_unicorn_prefer_export_from.go +99 -99
- package/linthost/rules_unicorn_prefer_global_this.go +91 -91
- package/linthost/rules_unicorn_prefer_import_meta_properties.go +38 -38
- package/linthost/rules_unicorn_prefer_includes.go +108 -108
- package/linthost/rules_unicorn_prefer_json_parse_buffer.go +37 -37
- package/linthost/rules_unicorn_prefer_keyboard_event_key.go +10 -10
- package/linthost/rules_unicorn_prefer_logical_operator_over_ternary.go +20 -20
- package/linthost/rules_unicorn_prefer_math_min_max.go +33 -33
- package/linthost/rules_unicorn_prefer_math_trunc.go +32 -32
- package/linthost/rules_unicorn_prefer_modern_dom_apis.go +18 -18
- package/linthost/rules_unicorn_prefer_modern_math_apis.go +38 -38
- package/linthost/rules_unicorn_prefer_module.go +22 -22
- package/linthost/rules_unicorn_prefer_native_coercion_functions.go +73 -73
- package/linthost/rules_unicorn_prefer_negative_index.go +46 -46
- package/linthost/rules_unicorn_prefer_node_protocol.go +90 -90
- package/linthost/rules_unicorn_prefer_number_properties.go +57 -57
- package/linthost/rules_unicorn_prefer_object_from_entries.go +26 -26
- package/linthost/rules_unicorn_prefer_optional_catch_binding.go +24 -24
- package/linthost/rules_unicorn_prefer_prototype_methods.go +25 -25
- package/linthost/rules_unicorn_prefer_query_selector.go +25 -25
- package/linthost/rules_unicorn_prefer_reflect_apply.go +10 -10
- package/linthost/rules_unicorn_prefer_regexp_test_rule.go +47 -47
- package/linthost/rules_unicorn_prefer_response_static_json.go +26 -26
- package/linthost/rules_unicorn_prefer_set_has.go +16 -16
- package/linthost/rules_unicorn_prefer_set_size.go +22 -22
- package/linthost/rules_unicorn_prefer_simple_condition_first.go +3 -3
- package/linthost/rules_unicorn_prefer_single_call.go +59 -59
- package/linthost/rules_unicorn_prefer_spread.go +24 -24
- package/linthost/rules_unicorn_prefer_string_raw.go +12 -12
- package/linthost/rules_unicorn_prefer_string_replace_all.go +46 -46
- package/linthost/rules_unicorn_prefer_string_slice.go +17 -17
- package/linthost/rules_unicorn_prefer_string_starts_ends_with.go +104 -104
- package/linthost/rules_unicorn_prefer_string_trim_start_end.go +21 -21
- package/linthost/rules_unicorn_prefer_structured_clone.go +36 -36
- package/linthost/rules_unicorn_prefer_switch.go +65 -65
- package/linthost/rules_unicorn_prefer_ternary.go +35 -35
- package/linthost/rules_unicorn_prefer_top_level_await.go +34 -34
- package/linthost/rules_unicorn_prefer_type_error.go +84 -84
- package/linthost/rules_unicorn_prevent_abbreviations.go +68 -68
- package/linthost/rules_unicorn_relative_url_style.go +19 -19
- package/linthost/rules_unicorn_require_array_join_separator.go +18 -18
- package/linthost/rules_unicorn_require_module_attributes.go +25 -25
- package/linthost/rules_unicorn_require_module_specifiers.go +28 -28
- package/linthost/rules_unicorn_require_number_to_fixed_digits_argument.go +18 -18
- package/linthost/rules_unicorn_require_post_message_target_origin.go +18 -18
- package/linthost/rules_unicorn_string_content.go +1 -1
- package/linthost/rules_unicorn_switch_case_braces.go +16 -16
- package/linthost/rules_unicorn_switch_case_break_position.go +3 -3
- package/linthost/rules_unicorn_template_indent.go +1 -1
- package/linthost/rules_unicorn_text_encoding_identifier_case.go +36 -36
- package/linthost/rules_unicorn_throw_new_error.go +30 -30
- package/linthost/rules_var.go +273 -3
- package/package.json +3 -3
- package/src/defaultFormat.ts +11 -7
- package/src/structures/ITtscLintConfig.ts +5 -5
- package/src/structures/TtscLintRuleSetting.ts +19 -19
- package/src/structures/{ITtscLintFormat.ts → format/ITtscLintFormat.ts} +48 -75
- package/src/structures/format/ITtscLintFormatJsDoc.ts +16 -0
- package/src/structures/format/ITtscLintFormatSortImports.ts +62 -0
- package/src/structures/format/index.ts +3 -0
- package/src/structures/index.ts +1 -1
- package/src/structures/rules/ITtscLintBoundariesRuleOptions.ts +20 -31
- package/src/structures/rules/ITtscLintBoundariesRules.ts +32 -36
- package/src/structures/rules/ITtscLintContributorRules.ts +6 -7
- package/src/structures/rules/ITtscLintCoreRules.ts +380 -408
- package/src/structures/rules/ITtscLintCypressRuleOptions.ts +5 -5
- package/src/structures/rules/ITtscLintCypressRules.ts +34 -38
- package/src/structures/rules/ITtscLintFunctionalRuleOptions.ts +28 -41
- package/src/structures/rules/ITtscLintFunctionalRules.ts +51 -56
- package/src/structures/rules/ITtscLintJestRules.ts +63 -74
- package/src/structures/rules/ITtscLintJsdocRules.ts +47 -54
- package/src/structures/rules/ITtscLintJsxA11yRules.ts +94 -102
- package/src/structures/rules/ITtscLintNextjsRules.ts +50 -55
- package/src/structures/rules/ITtscLintPlaywrightRules.ts +104 -122
- package/src/structures/rules/ITtscLintPromiseRules.ts +62 -71
- package/src/structures/rules/ITtscLintReactPerfRuleOptions.ts +4 -4
- package/src/structures/rules/ITtscLintReactPerfRules.ts +17 -19
- package/src/structures/rules/ITtscLintReactRuleOptions.ts +8 -10
- package/src/structures/rules/ITtscLintReactRules.ts +91 -104
- package/src/structures/rules/ITtscLintRegexpRules.ts +46 -54
- package/src/structures/rules/ITtscLintRuleOptionsMap.ts +7 -8
- package/src/structures/rules/ITtscLintSecurityRules.ts +45 -52
- package/src/structures/rules/ITtscLintSolidRules.ts +53 -56
- package/src/structures/rules/ITtscLintStorybookRuleOptions.ts +3 -4
- package/src/structures/rules/ITtscLintStorybookRules.ts +60 -69
- package/src/structures/rules/ITtscLintTanstackQueryRules.ts +31 -37
- package/src/structures/rules/ITtscLintTestingLibraryRuleOptions.ts +2 -3
- package/src/structures/rules/ITtscLintTestingLibraryRules.ts +102 -119
- package/src/structures/rules/ITtscLintTypeScriptRules.ts +460 -518
- package/src/structures/rules/ITtscLintVitestRules.ts +43 -51
- package/lib/structures/ITtscLintFormat.js.map +0 -1
- /package/lib/structures/{ITtscLintFormat.js → format/ITtscLintFormat.js} +0 -0
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import type { TtscLintRuleSetting } from "../TtscLintRuleSetting";
|
|
2
2
|
/**
|
|
3
|
-
* TypeScript-only rules and `@typescript-eslint` plugin equivalents,
|
|
4
|
-
*
|
|
3
|
+
* TypeScript-only rules and `@typescript-eslint` plugin equivalents, exposed
|
|
4
|
+
* under the `typescript/*` namespace.
|
|
5
5
|
*
|
|
6
|
-
* Every rule listed here either requires TypeScript syntax (interface,
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* Every rule listed here either requires TypeScript syntax (interface, `enum`,
|
|
7
|
+
* `namespace`, `as`, `!`, `import type`, type parameters, declaration merging,
|
|
8
|
+
* parameter properties, triple-slash references) or originates from
|
|
9
|
+
* `@typescript-eslint` as a TS-aware extension that has no counterpart in plain
|
|
10
|
+
* ESLint.
|
|
11
11
|
*
|
|
12
12
|
* Generic JS/TS rules (such as `eqeqeq`, `no-console`) stay unnamespaced in
|
|
13
13
|
* {@link ITtscLintCoreRules}.
|
|
14
14
|
*
|
|
15
|
-
* This family deliberately mirrors `typescript-eslint`'s rule ids but
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* This family deliberately mirrors `typescript-eslint`'s rule ids but **only**
|
|
16
|
+
* under the `typescript/*` prefix — `@ttsc/lint` does not accept legacy bare
|
|
17
|
+
* names or `@typescript-eslint/*` aliases for these rules.
|
|
18
18
|
*
|
|
19
19
|
* @reference https://typescript-eslint.io/rules/
|
|
20
20
|
*/
|
|
21
21
|
export interface ITtscLintTypeScriptRules {
|
|
22
22
|
/**
|
|
23
|
-
* Require overload declarations for the same member to be written
|
|
24
|
-
* adjacently.
|
|
23
|
+
* Require overload declarations for the same member to be written adjacently.
|
|
25
24
|
*
|
|
26
|
-
* Splitting overloads with other members hides the full signature
|
|
27
|
-
*
|
|
25
|
+
* Splitting overloads with other members hides the full signature set from
|
|
26
|
+
* readers and tools.
|
|
28
27
|
*
|
|
29
28
|
* @reference https://typescript-eslint.io/rules/adjacent-overload-signatures
|
|
30
29
|
*/
|
|
@@ -32,9 +31,8 @@ export interface ITtscLintTypeScriptRules {
|
|
|
32
31
|
/**
|
|
33
32
|
* Enforce one consistent spelling of array types.
|
|
34
33
|
*
|
|
35
|
-
* By default the rule prefers `T[]` / `readonly T[]` over `Array<T>`
|
|
36
|
-
*
|
|
37
|
-
* default.
|
|
34
|
+
* By default the rule prefers `T[]` / `readonly T[]` over `Array<T>` /
|
|
35
|
+
* `ReadonlyArray<T>`, matching `@typescript-eslint`'s `array-type` default.
|
|
38
36
|
*
|
|
39
37
|
* @reference https://typescript-eslint.io/rules/array-type
|
|
40
38
|
*/
|
|
@@ -42,60 +40,59 @@ export interface ITtscLintTypeScriptRules {
|
|
|
42
40
|
/**
|
|
43
41
|
* Reject `await` on operands that are not thenable.
|
|
44
42
|
*
|
|
45
|
-
* Type-aware — the Checker decides whether the awaited expression has
|
|
46
|
-
*
|
|
43
|
+
* Type-aware — the Checker decides whether the awaited expression has a
|
|
44
|
+
* `then` method. Autofixable: drops the `await`.
|
|
47
45
|
*
|
|
48
46
|
* @reference https://typescript-eslint.io/rules/await-thenable
|
|
49
47
|
*/
|
|
50
48
|
"typescript/await-thenable"?: TtscLintRuleSetting;
|
|
51
49
|
/**
|
|
52
|
-
* Reject `@ts-ignore
|
|
53
|
-
* `@ts-check` comments.
|
|
50
|
+
* Reject `@ts-ignore` and `@ts-expect-error` comments.
|
|
54
51
|
*
|
|
55
|
-
* The
|
|
56
|
-
*
|
|
52
|
+
* The rule flags both directives unconditionally. There is no
|
|
53
|
+
* description-based allowance, and the `@typescript-eslint` options are not
|
|
54
|
+
* implemented.
|
|
57
55
|
*
|
|
58
56
|
* @reference https://typescript-eslint.io/rules/ban-ts-comment
|
|
59
57
|
*/
|
|
60
58
|
"typescript/ban-ts-comment"?: TtscLintRuleSetting;
|
|
61
59
|
/**
|
|
62
|
-
* Reject `// tslint:disable` and related TSLint directive comments
|
|
63
|
-
*
|
|
60
|
+
* Reject `// tslint:disable` and related TSLint directive comments left
|
|
61
|
+
* behind from the legacy TSLint era.
|
|
64
62
|
*
|
|
65
63
|
* @reference https://typescript-eslint.io/rules/ban-tslint-comment
|
|
66
64
|
*/
|
|
67
65
|
"typescript/ban-tslint-comment"?: TtscLintRuleSetting;
|
|
68
66
|
/**
|
|
69
|
-
* Prefer a `static readonly` field over a `get` accessor whose body
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* side effects cannot be reproduced by a field.
|
|
67
|
+
* Prefer a `static readonly` field over a `get` accessor whose body is a
|
|
68
|
+
* single `return <literal>;`. The getter form re-runs the body on every read
|
|
69
|
+
* and obscures that the value is fixed; a readonly field is shorter, narrows
|
|
70
|
+
* to the literal type, and signals "this is a constant" at the call site.
|
|
71
|
+
* Skipped when the class also declares a `set` accessor for the same member
|
|
72
|
+
* name — the setter's side effects cannot be reproduced by a field.
|
|
76
73
|
*
|
|
77
74
|
* @reference https://typescript-eslint.io/rules/class-literal-property-style
|
|
78
75
|
*/
|
|
79
76
|
"typescript/class-literal-property-style"?: TtscLintRuleSetting;
|
|
80
77
|
/**
|
|
81
|
-
* Prefer `Record<K, V>` over `{ [key: K]: V }` when an object type
|
|
82
|
-
*
|
|
78
|
+
* Prefer `Record<K, V>` over `{ [key: K]: V }` when an object type has a
|
|
79
|
+
* single index signature and no other members.
|
|
83
80
|
*
|
|
84
81
|
* @reference https://typescript-eslint.io/rules/consistent-indexed-object-style
|
|
85
82
|
*/
|
|
86
83
|
"typescript/consistent-indexed-object-style"?: TtscLintRuleSetting;
|
|
87
84
|
/**
|
|
88
|
-
* Prefer the `as` form of type assertions over the angle-bracket
|
|
89
|
-
*
|
|
85
|
+
* Prefer the `as` form of type assertions over the angle-bracket form
|
|
86
|
+
* `<T>expr`, which is ambiguous inside JSX.
|
|
90
87
|
*
|
|
91
88
|
* @reference https://typescript-eslint.io/rules/consistent-type-assertions
|
|
92
89
|
*/
|
|
93
90
|
"typescript/consistent-type-assertions"?: TtscLintRuleSetting;
|
|
94
91
|
/**
|
|
95
|
-
* Reject the redundant pattern where a variable is annotated with a
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
92
|
+
* Reject the redundant pattern where a variable is annotated with a generic
|
|
93
|
+
* type AND the same generic arguments are repeated on the constructor: `const
|
|
94
|
+
* m: Map<K, V> = new Map<K, V>()`. One of the two type-argument lists carries
|
|
95
|
+
* the binding; stating both is noise.
|
|
99
96
|
*
|
|
100
97
|
* @reference https://typescript-eslint.io/rules/consistent-generic-constructors
|
|
101
98
|
*/
|
|
@@ -103,53 +100,51 @@ export interface ITtscLintTypeScriptRules {
|
|
|
103
100
|
/**
|
|
104
101
|
* Enforce one consistent shape for object types.
|
|
105
102
|
*
|
|
106
|
-
* By default the rule prefers `interface` over `type` aliases for
|
|
107
|
-
*
|
|
103
|
+
* By default the rule prefers `interface` over `type` aliases for plain
|
|
104
|
+
* object shapes.
|
|
108
105
|
*
|
|
109
106
|
* @reference https://typescript-eslint.io/rules/consistent-type-definitions
|
|
110
107
|
*/
|
|
111
108
|
"typescript/consistent-type-definitions"?: TtscLintRuleSetting;
|
|
112
109
|
/**
|
|
113
|
-
* Require type-only re-exports to use `export type { ... }` instead
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* import.
|
|
110
|
+
* Require type-only re-exports to use `export type { ... }` instead of the
|
|
111
|
+
* value form `export { ... }` when the exported binding only refers to a type
|
|
112
|
+
* alias or interface in the same file. The type form has no runtime cost and
|
|
113
|
+
* signals intent to the downstream import.
|
|
118
114
|
*
|
|
119
115
|
* @reference https://typescript-eslint.io/rules/consistent-type-exports
|
|
120
116
|
*/
|
|
121
117
|
"typescript/consistent-type-exports"?: TtscLintRuleSetting;
|
|
122
118
|
/**
|
|
123
|
-
* Require imports that only reference types to use `import type {}`
|
|
124
|
-
*
|
|
119
|
+
* Require imports that only reference types to use `import type {}` so the
|
|
120
|
+
* import has no runtime cost.
|
|
125
121
|
*
|
|
126
122
|
* @reference https://typescript-eslint.io/rules/consistent-type-imports
|
|
127
123
|
*/
|
|
128
124
|
"typescript/consistent-type-imports"?: TtscLintRuleSetting;
|
|
129
125
|
/**
|
|
130
|
-
* Require every exported function and method declaration to carry an
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
126
|
+
* Require every exported function and method declaration to carry an explicit
|
|
127
|
+
* return-type annotation. Implicit return types let downstream consumers
|
|
128
|
+
* depend on inference details that can shift with future edits; the explicit
|
|
129
|
+
* annotation pins the contract.
|
|
134
130
|
*
|
|
135
131
|
* @reference https://typescript-eslint.io/rules/explicit-function-return-type
|
|
136
132
|
*/
|
|
137
133
|
"typescript/explicit-function-return-type"?: TtscLintRuleSetting;
|
|
138
134
|
/**
|
|
139
|
-
* Require an explicit accessibility modifier (`public`, `private`,
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
135
|
+
* Require an explicit accessibility modifier (`public`, `private`, or
|
|
136
|
+
* `protected`) on every class member declaration. Implicit public is
|
|
137
|
+
* permitted by TypeScript but obscures intent — the modifier makes the
|
|
138
|
+
* encapsulation contract self-documenting. Members declared with the `#name`
|
|
139
|
+
* private-hash form are exempt.
|
|
144
140
|
*
|
|
145
141
|
* @reference https://typescript-eslint.io/rules/explicit-member-accessibility
|
|
146
142
|
*/
|
|
147
143
|
"typescript/explicit-member-accessibility"?: TtscLintRuleSetting;
|
|
148
144
|
/**
|
|
149
|
-
* Prefer a function-property signature (`f: () => void`) over a
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* applies.
|
|
145
|
+
* Prefer a function-property signature (`f: () => void`) over a shorthand
|
|
146
|
+
* method signature (`f(): void`) in interfaces and type literals so the
|
|
147
|
+
* strict-function-types contravariance check applies.
|
|
153
148
|
*
|
|
154
149
|
* @reference https://typescript-eslint.io/rules/method-signature-style
|
|
155
150
|
*/
|
|
@@ -163,86 +158,82 @@ export interface ITtscLintTypeScriptRules {
|
|
|
163
158
|
*/
|
|
164
159
|
"typescript/no-array-delete"?: TtscLintRuleSetting;
|
|
165
160
|
/**
|
|
166
|
-
* Prefer `for ... of` over `Array.prototype.forEach()`. The for-of
|
|
167
|
-
*
|
|
168
|
-
*
|
|
161
|
+
* Prefer `for ... of` over `Array.prototype.forEach()`. The for-of form
|
|
162
|
+
* supports early termination (`break`/`return`) and `await`, while `forEach`
|
|
163
|
+
* swallows both.
|
|
169
164
|
*
|
|
170
165
|
* @reference https://typescript-eslint.io/rules/no-array-for-each
|
|
171
166
|
*/
|
|
172
167
|
"typescript/no-array-for-each"?: TtscLintRuleSetting;
|
|
173
168
|
/**
|
|
174
|
-
* Reject string-coercion contexts (
|
|
175
|
-
*
|
|
169
|
+
* Reject string-coercion contexts (`${x}`, `x + ""`, `String(x)`) where `x`
|
|
170
|
+
* has a type whose `toString` resolves to the default
|
|
176
171
|
* `Object.prototype.toString` and would print `"[object Object]"`.
|
|
177
172
|
*
|
|
178
|
-
* Type-aware via the Checker. Stringish primitives, `Date`, `Error`,
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* default string.
|
|
173
|
+
* Type-aware via the Checker. Stringish primitives, `Date`, `Error`, arrays,
|
|
174
|
+
* regexes, and any object that overrides `toString` are safe; plain `{}`
|
|
175
|
+
* literals, `Record<...>` shapes, and structural interfaces with no
|
|
176
|
+
* `toString` member are the ones that produce the useless default string.
|
|
183
177
|
*
|
|
184
178
|
* @reference https://typescript-eslint.io/rules/no-base-to-string
|
|
185
179
|
*/
|
|
186
180
|
"typescript/no-base-to-string"?: TtscLintRuleSetting;
|
|
187
181
|
/**
|
|
188
|
-
* Reject classes that exist purely as a namespace for static members
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
182
|
+
* Reject classes that exist purely as a namespace for static members or that
|
|
183
|
+
* are entirely empty. A namespace import or plain functions are clearer than
|
|
184
|
+
* `class Util { static foo() {} }` — the class adds indirection without
|
|
185
|
+
* providing instance behavior.
|
|
192
186
|
*
|
|
193
187
|
* @reference https://typescript-eslint.io/rules/no-extraneous-class
|
|
194
188
|
*/
|
|
195
189
|
"typescript/no-extraneous-class"?: TtscLintRuleSetting;
|
|
196
190
|
/**
|
|
197
|
-
* Reject non-null assertions placed where they visually merge with
|
|
198
|
-
*
|
|
199
|
-
*
|
|
191
|
+
* Reject non-null assertions placed where they visually merge with a
|
|
192
|
+
* following operator — `a! == b` (reads as `!=`), `a! in b`, or `a!
|
|
193
|
+
* instanceof B`.
|
|
200
194
|
*
|
|
201
|
-
* Wrap the assertion in parentheses (`(a!) == b`) or drop it
|
|
202
|
-
* entirely.
|
|
195
|
+
* Wrap the assertion in parentheses (`(a!) == b`) or drop it entirely.
|
|
203
196
|
*
|
|
204
197
|
* @reference https://typescript-eslint.io/rules/no-confusing-non-null-assertion
|
|
205
198
|
*/
|
|
206
199
|
"typescript/no-confusing-non-null-assertion"?: TtscLintRuleSetting;
|
|
207
200
|
/**
|
|
208
|
-
* Reject `void X` expressions used in any position where the
|
|
209
|
-
*
|
|
210
|
-
*
|
|
201
|
+
* Reject `void X` expressions used in any position where the surrounding
|
|
202
|
+
* context expects a value — initializer, call argument, `return` operand,
|
|
203
|
+
* conditional, binary, or ternary subexpression.
|
|
211
204
|
*
|
|
212
|
-
* The only acceptable positions are an expression statement
|
|
213
|
-
*
|
|
214
|
-
*
|
|
205
|
+
* The only acceptable positions are an expression statement (`void x;`), an
|
|
206
|
+
* arrow function's concise body (`() => void x`), and the operand of an
|
|
207
|
+
* enclosing `void` operator (`void void x`).
|
|
215
208
|
*
|
|
216
209
|
* @reference https://typescript-eslint.io/rules/no-confusing-void-expression
|
|
217
210
|
*/
|
|
218
211
|
"typescript/no-confusing-void-expression"?: TtscLintRuleSetting;
|
|
219
212
|
/**
|
|
220
|
-
* Reject references to declarations marked `@deprecated` in their
|
|
221
|
-
* JSDoc.
|
|
213
|
+
* Reject references to declarations marked `@deprecated` in their JSDoc.
|
|
222
214
|
*
|
|
223
215
|
* Type-aware via the Checker. The rule resolves the symbol at each
|
|
224
|
-
* identifier, property access, call, `new`, or JSX tag-name location,
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
216
|
+
* identifier, property access, call, `new`, or JSX tag-name location, walks
|
|
217
|
+
* the symbol's declarations for an attached `@deprecated` JSDoc tag, and
|
|
218
|
+
* reports at the reference. References inside the same declaration block as
|
|
219
|
+
* the deprecation marker are skipped so the deprecation site itself doesn't
|
|
220
|
+
* fire.
|
|
229
221
|
*
|
|
230
222
|
* @reference https://typescript-eslint.io/rules/no-deprecated
|
|
231
223
|
*/
|
|
232
224
|
"typescript/no-deprecated"?: TtscLintRuleSetting;
|
|
233
225
|
/**
|
|
234
|
-
* Reject `enum` declarations whose members share the same literal
|
|
235
|
-
* value.
|
|
226
|
+
* Reject `enum` declarations whose members share the same literal value.
|
|
236
227
|
*
|
|
237
|
-
* Reverse lookup (`E[E.X]`) returns whichever member is listed last,
|
|
238
|
-
*
|
|
228
|
+
* Reverse lookup (`E[E.X]`) returns whichever member is listed last, so
|
|
229
|
+
* duplicates almost always reflect a copy-paste mistake.
|
|
239
230
|
*
|
|
240
231
|
* @reference https://typescript-eslint.io/rules/no-duplicate-enum-values
|
|
241
232
|
*/
|
|
242
233
|
"typescript/no-duplicate-enum-values"?: TtscLintRuleSetting;
|
|
243
234
|
/**
|
|
244
|
-
* Reject computed bracket-key `delete` expressions (`delete obj[x]`)
|
|
245
|
-
*
|
|
235
|
+
* Reject computed bracket-key `delete` expressions (`delete obj[x]`) where
|
|
236
|
+
* `x` is not a string literal, since these escape type tracking.
|
|
246
237
|
*
|
|
247
238
|
* @reference https://typescript-eslint.io/rules/no-dynamic-delete
|
|
248
239
|
*/
|
|
@@ -250,8 +241,8 @@ export interface ITtscLintTypeScriptRules {
|
|
|
250
241
|
/**
|
|
251
242
|
* Reject empty `interface` declarations.
|
|
252
243
|
*
|
|
253
|
-
* An empty interface that does not `extends` anything is equivalent
|
|
254
|
-
*
|
|
244
|
+
* An empty interface that does not `extends` anything is equivalent to
|
|
245
|
+
* `unknown` and almost always represents incomplete typing work.
|
|
255
246
|
*
|
|
256
247
|
* @reference https://typescript-eslint.io/rules/no-empty-interface
|
|
257
248
|
*/
|
|
@@ -259,9 +250,9 @@ export interface ITtscLintTypeScriptRules {
|
|
|
259
250
|
/**
|
|
260
251
|
* Reject `{}` as a type annotation.
|
|
261
252
|
*
|
|
262
|
-
* `{}` matches every non-nullish value and is almost never intended;
|
|
263
|
-
*
|
|
264
|
-
*
|
|
253
|
+
* `{}` matches every non-nullish value and is almost never intended; use
|
|
254
|
+
* `Record<string, unknown>` for a generic object, or `object` for any
|
|
255
|
+
* non-primitive.
|
|
265
256
|
*
|
|
266
257
|
* @reference https://typescript-eslint.io/rules/no-empty-object-type
|
|
267
258
|
*/
|
|
@@ -275,90 +266,88 @@ export interface ITtscLintTypeScriptRules {
|
|
|
275
266
|
*/
|
|
276
267
|
"typescript/no-explicit-any"?: TtscLintRuleSetting;
|
|
277
268
|
/**
|
|
278
|
-
* Reject `x!!` — chained non-null assertions where the inner one
|
|
279
|
-
*
|
|
269
|
+
* Reject `x!!` — chained non-null assertions where the inner one already
|
|
270
|
+
* removes nullability. Autofixable: drops the extra `!`.
|
|
280
271
|
*
|
|
281
272
|
* @reference https://typescript-eslint.io/rules/no-extra-non-null-assertion
|
|
282
273
|
*/
|
|
283
274
|
"typescript/no-extra-non-null-assertion"?: TtscLintRuleSetting;
|
|
284
275
|
/**
|
|
285
|
-
* Reject Promise-typed expressions whose result is discarded — most
|
|
286
|
-
*
|
|
276
|
+
* Reject Promise-typed expressions whose result is discarded — most often a
|
|
277
|
+
* bare `getPromise();` expression statement.
|
|
287
278
|
*
|
|
288
|
-
* Type-aware via the Checker. A floating promise loses its rejection
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
279
|
+
* Type-aware via the Checker. A floating promise loses its rejection channel
|
|
280
|
+
* and runs out of order with surrounding code. Acceptable sinks are `await`,
|
|
281
|
+
* `.catch(...)`, `.then(_, onRejected)`, `.finally(...)`, assignment, the
|
|
282
|
+
* `void` operator, and `return`.
|
|
292
283
|
*
|
|
293
284
|
* @reference https://typescript-eslint.io/rules/no-floating-promises
|
|
294
285
|
*/
|
|
295
286
|
"typescript/no-floating-promises"?: TtscLintRuleSetting;
|
|
296
287
|
/**
|
|
297
|
-
* Reject `for (const k in arr)` where `arr` is statically typed as an
|
|
298
|
-
*
|
|
288
|
+
* Reject `for (const k in arr)` where `arr` is statically typed as an array
|
|
289
|
+
* or tuple.
|
|
299
290
|
*
|
|
300
|
-
* Type-aware via the Checker. `for...in` iterates enumerable property
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
291
|
+
* Type-aware via the Checker. `for...in` iterates enumerable property names
|
|
292
|
+
* (yielded as strings, including any inherited or custom-added members), not
|
|
293
|
+
* array values or numeric indices — almost always a mistake for `for...of`,
|
|
294
|
+
* `Array#forEach`, or an indexed `for` loop.
|
|
304
295
|
*
|
|
305
296
|
* @reference https://typescript-eslint.io/rules/no-for-in-array
|
|
306
297
|
*/
|
|
307
298
|
"typescript/no-for-in-array"?: TtscLintRuleSetting;
|
|
308
299
|
/**
|
|
309
|
-
* Hoist inline `type` modifiers on individual imports into a single
|
|
310
|
-
*
|
|
300
|
+
* Hoist inline `type` modifiers on individual imports into a single top-level
|
|
301
|
+
* `import type {}`. Autofixable.
|
|
311
302
|
*
|
|
312
303
|
* @reference https://typescript-eslint.io/rules/no-import-type-side-effects
|
|
313
304
|
*/
|
|
314
305
|
"typescript/no-import-type-side-effects"?: TtscLintRuleSetting;
|
|
315
306
|
/**
|
|
316
|
-
* Reject explicit type annotations that TypeScript can already
|
|
317
|
-
*
|
|
307
|
+
* Reject explicit type annotations that TypeScript can already infer from the
|
|
308
|
+
* initializer (`const x: number = 1`).
|
|
318
309
|
*
|
|
319
310
|
* @reference https://typescript-eslint.io/rules/no-inferrable-types
|
|
320
311
|
*/
|
|
321
312
|
"typescript/no-inferrable-types"?: TtscLintRuleSetting;
|
|
322
313
|
/**
|
|
323
|
-
* Reject `void` used as anything other than a function return type.
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* `AsyncGenerator` / `Iterator` / `AsyncIterator` /
|
|
314
|
+
* Reject `void` used as anything other than a function return type. `void` in
|
|
315
|
+
* a union (`string | void`) or as a non-allow-listed generic argument is
|
|
316
|
+
* almost always a confusion with `undefined`. Allowed positions:
|
|
317
|
+
* function/method/arrow return-type annotations and generic arguments to
|
|
318
|
+
* `Promise` / `Generator` / `AsyncGenerator` / `Iterator` / `AsyncIterator` /
|
|
329
319
|
* `IterableIterator` / `AsyncIterableIterator`.
|
|
330
320
|
*
|
|
331
321
|
* @reference https://typescript-eslint.io/rules/no-invalid-void-type
|
|
332
322
|
*/
|
|
333
323
|
"typescript/no-invalid-void-type"?: TtscLintRuleSetting;
|
|
334
324
|
/**
|
|
335
|
-
* TypeScript-aware extension of `no-magic-numbers` that additionally ignores
|
|
325
|
+
* TypeScript-aware extension of `no-magic-numbers` that additionally ignores
|
|
326
|
+
* enum member values.
|
|
336
327
|
*
|
|
337
328
|
* @reference https://typescript-eslint.io/rules/no-magic-numbers
|
|
338
329
|
*/
|
|
339
330
|
"typescript/no-magic-numbers"?: TtscLintRuleSetting;
|
|
340
331
|
/**
|
|
341
|
-
* Reject `void X` where `X` is already statically typed `void` — the
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
332
|
+
* Reject `void X` where `X` is already statically typed `void` — the `void`
|
|
333
|
+
* operator adds nothing because the operand already evaluates to `undefined`.
|
|
334
|
+
* The operator is meaningful only on a value- returning expression that the
|
|
335
|
+
* caller wants to discard.
|
|
345
336
|
*
|
|
346
|
-
* Type-aware — the Checker decides whether the operand carries the
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
* does not.
|
|
337
|
+
* Type-aware — the Checker decides whether the operand carries the `void`
|
|
338
|
+
* type. The upstream `checkNever` option is left at its default of `false`:
|
|
339
|
+
* only `void`-typed operands trigger, `never` does not.
|
|
350
340
|
*
|
|
351
341
|
* @reference https://typescript-eslint.io/rules/no-meaningless-void-operator
|
|
352
342
|
*/
|
|
353
343
|
"typescript/no-meaningless-void-operator"?: TtscLintRuleSetting;
|
|
354
344
|
/**
|
|
355
|
-
* Reject signatures that fake a constructor or an instance `new`
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
* C }`.
|
|
345
|
+
* Reject signatures that fake a constructor or an instance `new` method —
|
|
346
|
+
* `interface I { new (): I }` (TypeScript treats this as the type of `new
|
|
347
|
+
* I()` regardless of intent) and `class C { new(): C }`.
|
|
359
348
|
*
|
|
360
|
-
* Use a separate construct signature on a factory type when the
|
|
361
|
-
*
|
|
349
|
+
* Use a separate construct signature on a factory type when the intent is
|
|
350
|
+
* "anything callable with `new`".
|
|
362
351
|
*
|
|
363
352
|
* @reference https://typescript-eslint.io/rules/no-misused-new
|
|
364
353
|
*/
|
|
@@ -366,58 +355,56 @@ export interface ITtscLintTypeScriptRules {
|
|
|
366
355
|
/**
|
|
367
356
|
* Reject Promise values supplied where a non-Promise was expected.
|
|
368
357
|
*
|
|
369
|
-
* Covers conditional positions (`if (promise)`, `while`, `for`,
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
358
|
+
* Covers conditional positions (`if (promise)`, `while`, `for`, ternary,
|
|
359
|
+
* `&&`, `||`, `??`) where the Promise is truthy by reference, and `async`
|
|
360
|
+
* callbacks passed to APIs that expect a void-returning function (e.g.
|
|
361
|
+
* `Array#forEach`, JSX event handlers), where the returned Promise is
|
|
362
|
+
* silently dropped.
|
|
374
363
|
*
|
|
375
364
|
* @reference https://typescript-eslint.io/rules/no-misused-promises
|
|
376
365
|
*/
|
|
377
366
|
"typescript/no-misused-promises"?: TtscLintRuleSetting;
|
|
378
367
|
/**
|
|
379
|
-
* Reject spread expressions whose operand is syntactically wrong
|
|
380
|
-
*
|
|
368
|
+
* Reject spread expressions whose operand is syntactically wrong for the
|
|
369
|
+
* surrounding context.
|
|
381
370
|
*
|
|
382
|
-
* AST-only subset of the upstream rule — no Checker required.
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* (`{ ...[1, 2] }`). General iterability detection still needs the
|
|
371
|
+
* AST-only subset of the upstream rule — no Checker required. Fires on object
|
|
372
|
+
* literal spread inside an array literal or a call/construct argument (`[...{
|
|
373
|
+
* a: 1 }]`, `f(...{ a: 1 })`) and on array literal spread inside an object
|
|
374
|
+
* literal (`{ ...[1, 2] }`). General iterability detection still needs the
|
|
387
375
|
* full type-aware rule.
|
|
388
376
|
*
|
|
389
377
|
* @reference https://typescript-eslint.io/rules/no-misused-spread
|
|
390
378
|
*/
|
|
391
379
|
"typescript/no-misused-spread"?: TtscLintRuleSetting;
|
|
392
380
|
/**
|
|
393
|
-
* Reject `enum`s that mix numeric and string members, which makes
|
|
394
|
-
*
|
|
381
|
+
* Reject `enum`s that mix numeric and string members, which makes the
|
|
382
|
+
* resulting type unsafe for reverse lookups.
|
|
395
383
|
*
|
|
396
384
|
* @reference https://typescript-eslint.io/rules/no-mixed-enums
|
|
397
385
|
*/
|
|
398
386
|
"typescript/no-mixed-enums"?: TtscLintRuleSetting;
|
|
399
387
|
/**
|
|
400
|
-
* Reject non-ambient `namespace` and `module Foo {}` declarations
|
|
401
|
-
*
|
|
388
|
+
* Reject non-ambient `namespace` and `module Foo {}` declarations in regular
|
|
389
|
+
* `.ts` files.
|
|
402
390
|
*
|
|
403
391
|
* ES modules replace the legacy namespace concept; ambient `declare
|
|
404
|
-
* namespace` in `.d.ts` files stays allowed by default for global
|
|
405
|
-
*
|
|
392
|
+
* namespace` in `.d.ts` files stays allowed by default for global typings
|
|
393
|
+
* compatibility.
|
|
406
394
|
*
|
|
407
395
|
* @reference https://typescript-eslint.io/rules/no-namespace
|
|
408
396
|
*/
|
|
409
397
|
"typescript/no-namespace"?: TtscLintRuleSetting;
|
|
410
398
|
/**
|
|
411
|
-
* Reject `x! ?? y` — the `!` collapses `null | undefined` to a
|
|
412
|
-
*
|
|
399
|
+
* Reject `x! ?? y` — the `!` collapses `null | undefined` to a non-nullish
|
|
400
|
+
* value, so the `??` branch is unreachable.
|
|
413
401
|
*
|
|
414
402
|
* @reference https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing
|
|
415
403
|
*/
|
|
416
404
|
"typescript/no-non-null-asserted-nullish-coalescing"?: TtscLintRuleSetting;
|
|
417
405
|
/**
|
|
418
406
|
* Reject `x!?.y` — the non-null assertion makes the optional chain
|
|
419
|
-
* meaningless because the inner expression is already known to be
|
|
420
|
-
* defined.
|
|
407
|
+
* meaningless because the inner expression is already known to be defined.
|
|
421
408
|
*
|
|
422
409
|
* @reference https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain
|
|
423
410
|
*/
|
|
@@ -425,151 +412,145 @@ export interface ITtscLintTypeScriptRules {
|
|
|
425
412
|
/**
|
|
426
413
|
* Reject postfix `!` non-null assertions altogether.
|
|
427
414
|
*
|
|
428
|
-
* The operator suppresses a real `null` / `undefined` possibility
|
|
429
|
-
*
|
|
430
|
-
*
|
|
415
|
+
* The operator suppresses a real `null` / `undefined` possibility without
|
|
416
|
+
* inserting a check; prefer a narrowing branch, optional chaining, or
|
|
417
|
+
* refining the type at its source.
|
|
431
418
|
*
|
|
432
419
|
* @reference https://typescript-eslint.io/rules/no-non-null-assertion
|
|
433
420
|
*/
|
|
434
421
|
"typescript/no-non-null-assertion"?: TtscLintRuleSetting;
|
|
435
422
|
/**
|
|
436
|
-
* Reject union and intersection type constituents that the type
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
423
|
+
* Reject union and intersection type constituents that the type system
|
|
424
|
+
* absorbs anyway — `string | any` collapses to `any`, `T & never` collapses
|
|
425
|
+
* to `never`, `T & unknown` collapses to `T`, and repeated constituents add
|
|
426
|
+
* nothing.
|
|
440
427
|
*
|
|
441
|
-
* AST-only baseline: only the literal `any` / `unknown` / `never`
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
428
|
+
* AST-only baseline: only the literal `any` / `unknown` / `never` keyword
|
|
429
|
+
* constituents and duplicates matched by textual identity are reported.
|
|
430
|
+
* Subset relations such as `string | "foo"` and generic alias resolution
|
|
431
|
+
* still require the type-aware path.
|
|
445
432
|
*
|
|
446
433
|
* @reference https://typescript-eslint.io/rules/no-redundant-type-constituents
|
|
447
434
|
*/
|
|
448
435
|
"typescript/no-redundant-type-constituents"?: TtscLintRuleSetting;
|
|
449
436
|
/**
|
|
450
|
-
* Reject specific type-reference names that are almost always a
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
* the wrapper names imply.
|
|
437
|
+
* Reject specific type-reference names that are almost always a mistake — by
|
|
438
|
+
* default the global wrapper types `Object`, `Function`, `Number`, `String`,
|
|
439
|
+
* and `Boolean`. The lowercase primitives (`number`, `string`, `boolean`) and
|
|
440
|
+
* explicit call signatures convey the intended type without the
|
|
441
|
+
* runtime-boxing semantics that the wrapper names imply.
|
|
456
442
|
*
|
|
457
|
-
* AST-only baseline: shadow guard reuses the same file-scope check
|
|
458
|
-
*
|
|
459
|
-
*
|
|
443
|
+
* AST-only baseline: shadow guard reuses the same file-scope check as
|
|
444
|
+
* `no-wrapper-object-types` so a user-declared `interface String {}` is not
|
|
445
|
+
* flagged as the global wrapper.
|
|
460
446
|
*
|
|
461
447
|
* @reference https://typescript-eslint.io/rules/no-restricted-types
|
|
462
448
|
*/
|
|
463
449
|
"typescript/no-restricted-types"?: TtscLintRuleSetting;
|
|
464
450
|
/**
|
|
465
|
-
* Reject `require(...)` calls and `import x = require(...)`
|
|
466
|
-
* declarations.
|
|
451
|
+
* Reject `require(...)` calls and `import x = require(...)` declarations.
|
|
467
452
|
*
|
|
468
|
-
* Use ES module `import` syntax so the type-only / runtime-import
|
|
469
|
-
*
|
|
453
|
+
* Use ES module `import` syntax so the type-only / runtime-import distinction
|
|
454
|
+
* is preserved and declaration shape stays consistent.
|
|
470
455
|
*
|
|
471
456
|
* @reference https://typescript-eslint.io/rules/no-require-imports
|
|
472
457
|
*/
|
|
473
458
|
"typescript/no-require-imports"?: TtscLintRuleSetting;
|
|
474
459
|
/**
|
|
475
|
-
* Reject aliasing `this` to a local (`const self = this`, `const
|
|
476
|
-
*
|
|
460
|
+
* Reject aliasing `this` to a local (`const self = this`, `const that =
|
|
461
|
+
* this`, destructuring `const { x } = this`).
|
|
477
462
|
*
|
|
478
|
-
* Arrow functions and `.bind(this)` make the workaround unnecessary;
|
|
479
|
-
*
|
|
463
|
+
* Arrow functions and `.bind(this)` make the workaround unnecessary; the
|
|
464
|
+
* alias also breaks type narrowing on `this`.
|
|
480
465
|
*
|
|
481
466
|
* @reference https://typescript-eslint.io/rules/no-this-alias
|
|
482
467
|
*/
|
|
483
468
|
"typescript/no-this-alias"?: TtscLintRuleSetting;
|
|
484
469
|
/**
|
|
485
|
-
* Reject direct comparison of a boolean-typed value with `true` /
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
470
|
+
* Reject direct comparison of a boolean-typed value with `true` / `false`
|
|
471
|
+
* literals — `x === true` is just `x`, `x !== false` is just `x`. The literal
|
|
472
|
+
* compare adds noise without changing the result whenever the non-literal
|
|
473
|
+
* side is provably pure boolean.
|
|
489
474
|
*
|
|
490
|
-
* Type-aware via the Checker. Skipped when the value side carries
|
|
491
|
-
* `
|
|
492
|
-
*
|
|
475
|
+
* Type-aware via the Checker. Skipped when the value side carries `null` /
|
|
476
|
+
* `undefined` — the literal compare is also stripping nullability there, and
|
|
477
|
+
* the rewrite would lose information.
|
|
493
478
|
*
|
|
494
479
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
495
480
|
*/
|
|
496
481
|
"typescript/no-unnecessary-boolean-literal-compare"?: TtscLintRuleSetting;
|
|
497
482
|
/**
|
|
498
|
-
* Reject conditions whose static type proves the runtime truthiness
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
* names the intent.
|
|
483
|
+
* Reject conditions whose static type proves the runtime truthiness is fixed
|
|
484
|
+
* — `if ({})`, `if (null)`, `while ("")`, `0 && f()`. The conditional becomes
|
|
485
|
+
* either dead code (the always-false arm) or unconditional execution (the
|
|
486
|
+
* always-true arm); the explicit shape (`if (true)`, deleting the dead
|
|
487
|
+
* branch, or widening the type) names the intent.
|
|
504
488
|
*
|
|
505
|
-
* Type-aware via the Checker. The rule stays silent on `any`,
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
489
|
+
* Type-aware via the Checker. The rule stays silent on `any`, `unknown`,
|
|
490
|
+
* plain `boolean`, plain `string`, plain `number`, unions that mix truthy and
|
|
491
|
+
* falsy outcomes, and any other shape whose runtime truthiness is not
|
|
492
|
+
* statically decidable — only the provably always-truthy / always-falsy
|
|
493
|
+
* positions are flagged.
|
|
510
494
|
*
|
|
511
495
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-condition
|
|
512
496
|
*/
|
|
513
497
|
"typescript/no-unnecessary-condition"?: TtscLintRuleSetting;
|
|
514
498
|
/**
|
|
515
|
-
* Reject `this.x = x` in a constructor body when `x` is already
|
|
516
|
-
*
|
|
517
|
-
* assignment automatically.
|
|
499
|
+
* Reject `this.x = x` in a constructor body when `x` is already declared as a
|
|
500
|
+
* parameter property — TypeScript performs the assignment automatically.
|
|
518
501
|
*
|
|
519
502
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-parameter-property-assignment
|
|
520
503
|
*/
|
|
521
504
|
"typescript/no-unnecessary-parameter-property-assignment"?: TtscLintRuleSetting;
|
|
522
505
|
/**
|
|
523
|
-
* Reject `Foo.Bar` references written inside `namespace Foo { ... }`
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
506
|
+
* Reject `Foo.Bar` references written inside `namespace Foo { ... }` or `enum
|
|
507
|
+
* Foo { ..., X = Foo.Y, ... }` where the `Foo.` qualifier names the same
|
|
508
|
+
* lexical scope the access lives in. Dropping the qualifier leaves the
|
|
509
|
+
* identical binding lookup.
|
|
527
510
|
*
|
|
528
511
|
* AST-only: walks `Parent` links for an enclosing namespace or enum
|
|
529
|
-
* declaration whose identifier matches the qualifier's head. The
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
* declaration ancestry.
|
|
512
|
+
* declaration whose identifier matches the qualifier's head. The Checker is
|
|
513
|
+
* not required because the upstream rule operates on lexical scope identity,
|
|
514
|
+
* which the AST already encodes via declaration ancestry.
|
|
533
515
|
*
|
|
534
516
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-qualifier
|
|
535
517
|
*/
|
|
536
518
|
"typescript/no-unnecessary-qualifier"?: TtscLintRuleSetting;
|
|
537
519
|
/**
|
|
538
520
|
* Reject template literals that carry no template-only behavior — a
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
521
|
+
* `${"abc"}` interpolation, a lone `${name}` span around a string-typed
|
|
522
|
+
* value, or a `abc` no-substitution literal with no escaped backticks. Each
|
|
523
|
+
* of these collapses to a regular string literal without changing meaning, so
|
|
524
|
+
* the backtick form is just noise.
|
|
543
525
|
*
|
|
544
|
-
* Type-aware via the Checker. The interpolation forms are flagged only
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
526
|
+
* Type-aware via the Checker. The interpolation forms are flagged only when
|
|
527
|
+
* the span's expression statically resolves to a string-like type and the
|
|
528
|
+
* surrounding head / tail text is empty — the runtime coercion is then a
|
|
529
|
+
* no-op, mirroring the upstream rule.
|
|
548
530
|
*
|
|
549
531
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-template-expression
|
|
550
532
|
*/
|
|
551
533
|
"typescript/no-unnecessary-template-expression"?: TtscLintRuleSetting;
|
|
552
534
|
/**
|
|
553
|
-
* Reject `Foo<DefaultT>` calls where the supplied generic argument is
|
|
554
|
-
*
|
|
535
|
+
* Reject `Foo<DefaultT>` calls where the supplied generic argument is the
|
|
536
|
+
* same as the parameter's default — the argument adds nothing.
|
|
555
537
|
*
|
|
556
|
-
* Type-aware via the Checker. Walks the resolved type parameters of
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
538
|
+
* Type-aware via the Checker. Walks the resolved type parameters of the
|
|
539
|
+
* call's signature and compares each explicit argument against the
|
|
540
|
+
* parameter's declared default. Only the contiguous trailing run of
|
|
541
|
+
* default-equal arguments is reported — TypeScript can only omit a suffix of
|
|
542
|
+
* the type-argument list.
|
|
561
543
|
*
|
|
562
544
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-type-arguments
|
|
563
545
|
*/
|
|
564
546
|
"typescript/no-unnecessary-type-arguments"?: TtscLintRuleSetting;
|
|
565
547
|
/**
|
|
566
|
-
* Reject `x as T` and `<T>x` assertions whose target type is the same
|
|
567
|
-
*
|
|
548
|
+
* Reject `x as T` and `<T>x` assertions whose target type is the same as
|
|
549
|
+
* `x`'s already-known static type — the assertion adds nothing.
|
|
568
550
|
*
|
|
569
|
-
* Also rejects `x!` non-null assertions when `x` is already
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* `prefer-as-const` rule.
|
|
551
|
+
* Also rejects `x!` non-null assertions when `x` is already statically
|
|
552
|
+
* non-nullable. The `as const` syntax is excluded because it produces a
|
|
553
|
+
* strictly different type and is handled by the `prefer-as-const` rule.
|
|
573
554
|
*
|
|
574
555
|
* Type-aware via the Checker.
|
|
575
556
|
*
|
|
@@ -577,16 +558,16 @@ export interface ITtscLintTypeScriptRules {
|
|
|
577
558
|
*/
|
|
578
559
|
"typescript/no-unnecessary-type-assertion"?: TtscLintRuleSetting;
|
|
579
560
|
/**
|
|
580
|
-
* Reject `<T extends unknown>` and similar constraints that match
|
|
581
|
-
*
|
|
561
|
+
* Reject `<T extends unknown>` and similar constraints that match everything.
|
|
562
|
+
* Autofixable: drops the constraint.
|
|
582
563
|
*
|
|
583
564
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-type-constraint
|
|
584
565
|
*/
|
|
585
566
|
"typescript/no-unnecessary-type-constraint"?: TtscLintRuleSetting;
|
|
586
567
|
/**
|
|
587
568
|
* Reject passing an `any`-typed value into a parameter whose type is
|
|
588
|
-
* concrete. The call still runs, but every static guarantee the
|
|
589
|
-
*
|
|
569
|
+
* concrete. The call still runs, but every static guarantee the function's
|
|
570
|
+
* signature would otherwise enforce is silently dropped.
|
|
590
571
|
*
|
|
591
572
|
* Type-aware via the Checker. `unknown` is not flagged.
|
|
592
573
|
*
|
|
@@ -594,9 +575,9 @@ export interface ITtscLintTypeScriptRules {
|
|
|
594
575
|
*/
|
|
595
576
|
"typescript/no-unsafe-argument"?: TtscLintRuleSetting;
|
|
596
577
|
/**
|
|
597
|
-
* Reject assigning an `any`-typed value into a concretely typed
|
|
598
|
-
*
|
|
599
|
-
*
|
|
578
|
+
* Reject assigning an `any`-typed value into a concretely typed location —
|
|
579
|
+
* variable initializer with an explicit annotation, or a reassignment whose
|
|
580
|
+
* left-hand side has a static type.
|
|
600
581
|
*
|
|
601
582
|
* Type-aware via the Checker. `unknown` is not flagged.
|
|
602
583
|
*
|
|
@@ -604,9 +585,9 @@ export interface ITtscLintTypeScriptRules {
|
|
|
604
585
|
*/
|
|
605
586
|
"typescript/no-unsafe-assignment"?: TtscLintRuleSetting;
|
|
606
587
|
/**
|
|
607
|
-
* Reject calling a value whose static type is `any`. The runtime
|
|
608
|
-
*
|
|
609
|
-
*
|
|
588
|
+
* Reject calling a value whose static type is `any`. The runtime call still
|
|
589
|
+
* happens, but the signature is unchecked and the return type spreads `any`
|
|
590
|
+
* to every downstream use.
|
|
610
591
|
*
|
|
611
592
|
* Type-aware via the Checker. Visits plain calls, `new`, and tagged
|
|
612
593
|
* templates. `unknown` is not flagged.
|
|
@@ -615,35 +596,32 @@ export interface ITtscLintTypeScriptRules {
|
|
|
615
596
|
*/
|
|
616
597
|
"typescript/no-unsafe-call"?: TtscLintRuleSetting;
|
|
617
598
|
/**
|
|
618
|
-
* Reject declaration merging between an `interface` and a `class`
|
|
619
|
-
*
|
|
599
|
+
* Reject declaration merging between an `interface` and a `class` with the
|
|
600
|
+
* same name.
|
|
620
601
|
*
|
|
621
|
-
* The interface grafts members onto the class type without forcing a
|
|
622
|
-
*
|
|
623
|
-
* exposes.
|
|
602
|
+
* The interface grafts members onto the class type without forcing a runtime
|
|
603
|
+
* implementation, so the class object lies about what it exposes.
|
|
624
604
|
*
|
|
625
605
|
* @reference https://typescript-eslint.io/rules/no-unsafe-declaration-merging
|
|
626
606
|
*/
|
|
627
607
|
"typescript/no-unsafe-declaration-merging"?: TtscLintRuleSetting;
|
|
628
608
|
/**
|
|
629
|
-
* Reject `==` / `===` / `!=` / `!==` comparisons between an
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
* primitive.
|
|
609
|
+
* Reject `==` / `===` / `!=` / `!==` comparisons between an enum-typed value
|
|
610
|
+
* and a plain `number` or `string` of the same widened primitive — the
|
|
611
|
+
* comparison silently accepts unrelated enums and raw literals that happen to
|
|
612
|
+
* share the underlying primitive.
|
|
634
613
|
*
|
|
635
|
-
* Type-aware via the Checker. The rule fires when one side carries
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
* helpers quiet), pass through.
|
|
614
|
+
* Type-aware via the Checker. The rule fires when one side carries an enum
|
|
615
|
+
* type and the other is the widened primitive without naming the same enum;
|
|
616
|
+
* comparisons against members of the same enum, and against `any` / `unknown`
|
|
617
|
+
* / `never` (to keep generic helpers quiet), pass through.
|
|
640
618
|
*
|
|
641
619
|
* @reference https://typescript-eslint.io/rules/no-unsafe-enum-comparison
|
|
642
620
|
*/
|
|
643
621
|
"typescript/no-unsafe-enum-comparison"?: TtscLintRuleSetting;
|
|
644
622
|
/**
|
|
645
|
-
* Reject the unsafe `Function` type, which matches every callable
|
|
646
|
-
*
|
|
623
|
+
* Reject the unsafe `Function` type, which matches every callable regardless
|
|
624
|
+
* of signature.
|
|
647
625
|
*
|
|
648
626
|
* Declare the specific call signature instead.
|
|
649
627
|
*
|
|
@@ -651,47 +629,46 @@ export interface ITtscLintTypeScriptRules {
|
|
|
651
629
|
*/
|
|
652
630
|
"typescript/no-unsafe-function-type"?: TtscLintRuleSetting;
|
|
653
631
|
/**
|
|
654
|
-
* Reject property access on a receiver whose static type is `any`.
|
|
655
|
-
*
|
|
656
|
-
*
|
|
632
|
+
* Reject property access on a receiver whose static type is `any`. The lookup
|
|
633
|
+
* still resolves at runtime, but the property type is `any` and spreads
|
|
634
|
+
* through the rest of the program.
|
|
657
635
|
*
|
|
658
|
-
* Type-aware via the Checker. Visits dot access and computed
|
|
659
|
-
*
|
|
636
|
+
* Type-aware via the Checker. Visits dot access and computed element access.
|
|
637
|
+
* `unknown` is not flagged.
|
|
660
638
|
*
|
|
661
639
|
* @reference https://typescript-eslint.io/rules/no-unsafe-member-access
|
|
662
640
|
*/
|
|
663
641
|
"typescript/no-unsafe-member-access"?: TtscLintRuleSetting;
|
|
664
642
|
/**
|
|
665
|
-
* Reject a `return` expression whose static type is `any` from a
|
|
666
|
-
*
|
|
667
|
-
* non-`
|
|
668
|
-
*
|
|
669
|
-
* value.
|
|
643
|
+
* Reject a `return` expression whose static type is `any` from a function
|
|
644
|
+
* whose declared return type is a concrete (non-`any` / non-`unknown` /
|
|
645
|
+
* non-`void`) shape — the `any` leaks past the type boundary and disables
|
|
646
|
+
* every downstream check on the returned value.
|
|
670
647
|
*
|
|
671
|
-
* Type-aware via the Checker. The rule walks each `return` to its
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
648
|
+
* Type-aware via the Checker. The rule walks each `return` to its enclosing
|
|
649
|
+
* function-like declaration, asks the Checker for that function's signature,
|
|
650
|
+
* and compares the declared return type against the expression type.
|
|
651
|
+
* `unknown`-typed expressions pass through because they cannot be used
|
|
652
|
+
* without further narrowing.
|
|
676
653
|
*
|
|
677
654
|
* @reference https://typescript-eslint.io/rules/no-unsafe-return
|
|
678
655
|
*/
|
|
679
656
|
"typescript/no-unsafe-return"?: TtscLintRuleSetting;
|
|
680
657
|
/**
|
|
681
|
-
* Reject the unary `-` operator applied to an operand whose static
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
* always indicates a bug.
|
|
658
|
+
* Reject the unary `-` operator applied to an operand whose static type is
|
|
659
|
+
* not number-like or bigint-like — `-x` silently coerces strings, objects,
|
|
660
|
+
* and other shapes via `Number(x)` and almost always indicates a bug.
|
|
685
661
|
*
|
|
686
|
-
* Type-aware via the Checker. `any` / `unknown` / `never` operands
|
|
687
|
-
*
|
|
688
|
-
*
|
|
662
|
+
* Type-aware via the Checker. `any` / `unknown` / `never` operands pass
|
|
663
|
+
* through to match the upstream `allowAny`-style defaults that keep generic
|
|
664
|
+
* helpers quiet.
|
|
689
665
|
*
|
|
690
666
|
* @reference https://typescript-eslint.io/rules/no-unsafe-unary-minus
|
|
691
667
|
*/
|
|
692
668
|
"typescript/no-unsafe-unary-minus"?: TtscLintRuleSetting;
|
|
693
669
|
/**
|
|
694
|
-
* TypeScript-aware extension of `no-useless-constructor` that tolerates a
|
|
670
|
+
* TypeScript-aware extension of `no-useless-constructor` that tolerates a
|
|
671
|
+
* constructor existing solely to expose parameter properties.
|
|
695
672
|
*
|
|
696
673
|
* @reference https://typescript-eslint.io/rules/no-useless-constructor
|
|
697
674
|
*/
|
|
@@ -699,55 +676,49 @@ export interface ITtscLintTypeScriptRules {
|
|
|
699
676
|
/**
|
|
700
677
|
* Reject redundant `export {}` declarations in module files.
|
|
701
678
|
*
|
|
702
|
-
* The file is already a module via its other top-level `import` /
|
|
703
|
-
* `export`.
|
|
679
|
+
* The file is already a module via its other top-level `import` / `export`.
|
|
704
680
|
*
|
|
705
681
|
* @reference https://typescript-eslint.io/rules/no-useless-empty-export
|
|
706
682
|
*/
|
|
707
683
|
"typescript/no-useless-empty-export"?: TtscLintRuleSetting;
|
|
708
684
|
/**
|
|
709
|
-
* Reject the wrapper object types `String`, `Number`, `Boolean`,
|
|
710
|
-
*
|
|
685
|
+
* Reject the wrapper object types `String`, `Number`, `Boolean`, `Symbol`,
|
|
686
|
+
* and `BigInt`.
|
|
711
687
|
*
|
|
712
|
-
* Autofixable to the corresponding primitive. `Object` stays
|
|
713
|
-
*
|
|
688
|
+
* Autofixable to the corresponding primitive. `Object` stays detection-only
|
|
689
|
+
* because it has slightly different semantics.
|
|
714
690
|
*
|
|
715
691
|
* @reference https://typescript-eslint.io/rules/no-wrapper-object-types
|
|
716
692
|
*/
|
|
717
693
|
"typescript/no-wrapper-object-types"?: TtscLintRuleSetting;
|
|
718
694
|
/**
|
|
719
|
-
* Reject `x as Foo` assertions whose target type is the non-nullable
|
|
720
|
-
*
|
|
721
|
-
* non-null assertion.
|
|
695
|
+
* Reject `x as Foo` assertions whose target type is the non-nullable version
|
|
696
|
+
* of `x`'s static type — replace with the shorter `x!` non-null assertion.
|
|
722
697
|
*
|
|
723
|
-
* Type-aware via the Checker. Fires when the source expression's
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
* non-nullable subset.
|
|
698
|
+
* Type-aware via the Checker. Fires when the source expression's static type
|
|
699
|
+
* is `Foo | null`, `Foo | undefined`, or `Foo | null | undefined`, and the
|
|
700
|
+
* asserted type equals the non-nullable subset.
|
|
727
701
|
*
|
|
728
702
|
* @reference https://typescript-eslint.io/rules/non-nullable-type-assertion-style
|
|
729
703
|
*/
|
|
730
704
|
"typescript/non-nullable-type-assertion-style"?: TtscLintRuleSetting;
|
|
731
705
|
/**
|
|
732
|
-
* Reject `throw X` where `X` is statically known not to derive from
|
|
733
|
-
*
|
|
734
|
-
* like.
|
|
706
|
+
* Reject `throw X` where `X` is statically known not to derive from `Error` —
|
|
707
|
+
* string literals, numbers, plain object literals, and the like.
|
|
735
708
|
*
|
|
736
|
-
* Type-aware via the Checker. Non-Error throws lose the stack trace
|
|
737
|
-
*
|
|
709
|
+
* Type-aware via the Checker. Non-Error throws lose the stack trace and
|
|
710
|
+
* confuse `instanceof` checks in the surrounding `catch`.
|
|
738
711
|
*
|
|
739
712
|
* @reference https://typescript-eslint.io/rules/only-throw-error
|
|
740
713
|
*/
|
|
741
714
|
"typescript/only-throw-error"?: TtscLintRuleSetting;
|
|
742
715
|
/**
|
|
743
|
-
* Reject TypeScript parameter-property constructors
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
* buried inside the constructor parameter list.
|
|
716
|
+
* Reject TypeScript parameter-property constructors (`constructor(public foo:
|
|
717
|
+
* T)`) — prefer plain field declarations so the class shape is visible from
|
|
718
|
+
* the member list instead of buried inside the constructor parameter list.
|
|
747
719
|
*
|
|
748
|
-
* AST-only — the trigger is a syntactic modifier (`public` /
|
|
749
|
-
* `
|
|
750
|
-
* constructor parameter.
|
|
720
|
+
* AST-only — the trigger is a syntactic modifier (`public` / `private` /
|
|
721
|
+
* `protected` / `readonly` / `override`) on a constructor parameter.
|
|
751
722
|
*
|
|
752
723
|
* @reference https://typescript-eslint.io/rules/parameter-properties
|
|
753
724
|
*/
|
|
@@ -761,8 +732,8 @@ export interface ITtscLintTypeScriptRules {
|
|
|
761
732
|
/**
|
|
762
733
|
* Require every `enum` member to have an explicit initializer.
|
|
763
734
|
*
|
|
764
|
-
* Implicit auto-increment is fine for novelty enums but dangerous
|
|
765
|
-
*
|
|
735
|
+
* Implicit auto-increment is fine for novelty enums but dangerous once a
|
|
736
|
+
* value gets persisted.
|
|
766
737
|
*
|
|
767
738
|
* @reference https://typescript-eslint.io/rules/prefer-enum-initializers
|
|
768
739
|
*/
|
|
@@ -771,95 +742,88 @@ export interface ITtscLintTypeScriptRules {
|
|
|
771
742
|
* Prefer `arr.find(predicate)` over `arr.filter(predicate)[0]` and
|
|
772
743
|
* `arr.filter(predicate).at(0)`.
|
|
773
744
|
*
|
|
774
|
-
* Type-aware via the Checker. Fires only when the receiver of
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
* `find` cannot express them.
|
|
745
|
+
* Type-aware via the Checker. Fires only when the receiver of `filter` is
|
|
746
|
+
* provably an array or tuple. `find` short-circuits on the first match
|
|
747
|
+
* instead of materializing the whole filtered array, so it expresses the "get
|
|
748
|
+
* me the first match" intent more directly and is strictly faster on large
|
|
749
|
+
* inputs. Non-zero index accesses (`[1]`, `.at(1)`, ...) are intentionally
|
|
750
|
+
* skipped because `find` cannot express them.
|
|
781
751
|
*
|
|
782
752
|
* @reference https://typescript-eslint.io/rules/prefer-find
|
|
783
753
|
*/
|
|
784
754
|
"typescript/prefer-find"?: TtscLintRuleSetting;
|
|
785
755
|
/**
|
|
786
|
-
* Prefer a type alias over an interface that declares only a
|
|
787
|
-
*
|
|
788
|
-
* structural typing.
|
|
756
|
+
* Prefer a type alias over an interface that declares only a single call
|
|
757
|
+
* signature — the type form composes better with structural typing.
|
|
789
758
|
*
|
|
790
759
|
* @reference https://typescript-eslint.io/rules/prefer-function-type
|
|
791
760
|
*/
|
|
792
761
|
"typescript/prefer-function-type"?: TtscLintRuleSetting;
|
|
793
762
|
/**
|
|
794
|
-
* Prefer `array.includes(x)` over `array.indexOf(x) !== -1` (and the
|
|
795
|
-
*
|
|
763
|
+
* Prefer `array.includes(x)` over `array.indexOf(x) !== -1` (and the matching
|
|
764
|
+
* `=== -1`, `>= 0`, `< 0`, `> -1` shapes).
|
|
796
765
|
*
|
|
797
|
-
* Type-aware via the Checker. Fires only when the receiver of
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
* `indexOf` return value against `-1`.
|
|
766
|
+
* Type-aware via the Checker. Fires only when the receiver of `indexOf` is
|
|
767
|
+
* provably an array, tuple, or string. The `includes`-style call states the
|
|
768
|
+
* intent directly and avoids the sentinel-vs-position confusion that comes
|
|
769
|
+
* with comparing an `indexOf` return value against `-1`.
|
|
802
770
|
*
|
|
803
771
|
* @reference https://typescript-eslint.io/rules/prefer-includes
|
|
804
772
|
*/
|
|
805
773
|
"typescript/prefer-includes"?: TtscLintRuleSetting;
|
|
806
774
|
/**
|
|
807
|
-
* Prefer literal initializers (`= 0`, `= "FOO"`) for enum members
|
|
808
|
-
*
|
|
809
|
-
* time.
|
|
775
|
+
* Prefer literal initializers (`= 0`, `= "FOO"`) for enum members over
|
|
776
|
+
* computed expressions, so the value is decidable at compile time.
|
|
810
777
|
*
|
|
811
778
|
* @reference https://typescript-eslint.io/rules/prefer-literal-enum-member
|
|
812
779
|
*/
|
|
813
780
|
"typescript/prefer-literal-enum-member"?: TtscLintRuleSetting;
|
|
814
781
|
/**
|
|
815
|
-
* Prefer the `namespace` keyword over the legacy `module Foo {}`
|
|
816
|
-
*
|
|
782
|
+
* Prefer the `namespace` keyword over the legacy `module Foo {}` form.
|
|
783
|
+
* Autofixable.
|
|
817
784
|
*
|
|
818
785
|
* @reference https://typescript-eslint.io/rules/prefer-namespace-keyword
|
|
819
786
|
*/
|
|
820
787
|
"typescript/prefer-namespace-keyword"?: TtscLintRuleSetting;
|
|
821
788
|
/**
|
|
822
|
-
* Prefer `??` over `||` (and `??=` over `||=`, and `??` over the
|
|
823
|
-
*
|
|
824
|
-
* `undefined`.
|
|
789
|
+
* Prefer `??` over `||` (and `??=` over `||=`, and `??` over the ternary `x ?
|
|
790
|
+
* x : y`) when the intent is to default `null` / `undefined`.
|
|
825
791
|
*
|
|
826
|
-
* `||` short-circuits on every falsy value (0, "", false, NaN), so
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
* ternary condition, etc.).
|
|
792
|
+
* `||` short-circuits on every falsy value (0, "", false, NaN), so "default
|
|
793
|
+
* this if missing" silently coerces legitimate zeros and empty strings. The
|
|
794
|
+
* AST-only baseline skips operands the surrounding context already coerces to
|
|
795
|
+
* boolean (`if (a || b)`, `!(a || b)`, ternary condition, etc.).
|
|
831
796
|
*
|
|
832
797
|
* @reference https://typescript-eslint.io/rules/prefer-nullish-coalescing
|
|
833
798
|
*/
|
|
834
799
|
"typescript/prefer-nullish-coalescing"?: TtscLintRuleSetting;
|
|
835
800
|
/**
|
|
836
|
-
* Prefer an optional chain (`a?.b?.c`) over chained boolean guards
|
|
837
|
-
*
|
|
801
|
+
* Prefer an optional chain (`a?.b?.c`) over chained boolean guards such as `a
|
|
802
|
+
* && a.b && a.b.c` or `a != null && a.b`.
|
|
838
803
|
*
|
|
839
|
-
* The optional-chain form is shorter and short-circuits to
|
|
840
|
-
*
|
|
841
|
-
*
|
|
842
|
-
*
|
|
843
|
-
*
|
|
844
|
-
*
|
|
804
|
+
* The optional-chain form is shorter and short-circuits to `undefined`
|
|
805
|
+
* instead of the leftmost falsy value, which is almost always the intent when
|
|
806
|
+
* guarding a property access against a nullish base. AST-only: the rule
|
|
807
|
+
* matches by the textual identity of the guard against the receiver of the
|
|
808
|
+
* right-hand access, and skips chains that cross a call expression with
|
|
809
|
+
* arguments.
|
|
845
810
|
*
|
|
846
811
|
* @reference https://typescript-eslint.io/rules/prefer-optional-chain
|
|
847
812
|
*/
|
|
848
813
|
"typescript/prefer-optional-chain"?: TtscLintRuleSetting;
|
|
849
814
|
/**
|
|
850
|
-
* Reject `Promise.reject(value)` where `value` is statically known
|
|
851
|
-
*
|
|
852
|
-
*
|
|
815
|
+
* Reject `Promise.reject(value)` where `value` is statically known not to
|
|
816
|
+
* derive from `Error` — string literals, numbers, plain primitives, and the
|
|
817
|
+
* like.
|
|
853
818
|
*
|
|
854
|
-
* Type-aware via the Checker. Mirrors `typescript/only-throw-error`
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
*
|
|
860
|
-
*
|
|
861
|
-
* `
|
|
862
|
-
* `allowThrowingAny` / `allowThrowingUnknown` defaults.
|
|
819
|
+
* Type-aware via the Checker. Mirrors `typescript/only-throw-error` for the
|
|
820
|
+
* rejection side of the promise contract: a non-Error rejection loses the
|
|
821
|
+
* structured stack trace and breaks downstream `instanceof Error` checks in
|
|
822
|
+
* `.catch(...)` / `try { await … } catch (err)` handlers. Covers
|
|
823
|
+
* `Promise.reject(arg)`, `<promise>.reject(arg)` on a Promise-typed receiver,
|
|
824
|
+
* and `reject(arg)` calls bound to the second parameter of a `new Promise((_,
|
|
825
|
+
* reject) => …)` executor. `any` and `unknown` pass through, matching
|
|
826
|
+
* upstream's `allowThrowingAny` / `allowThrowingUnknown` defaults.
|
|
863
827
|
*
|
|
864
828
|
* @reference https://typescript-eslint.io/rules/prefer-promise-reject-errors
|
|
865
829
|
*/
|
|
@@ -867,15 +831,14 @@ export interface ITtscLintTypeScriptRules {
|
|
|
867
831
|
/**
|
|
868
832
|
* Reject private class fields that could carry `readonly`.
|
|
869
833
|
*
|
|
870
|
-
* AST-only baseline: fires on a `PropertyDeclaration` inside a class
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
*
|
|
877
|
-
*
|
|
878
|
-
* narrow but safe shape.
|
|
834
|
+
* AST-only baseline: fires on a `PropertyDeclaration` inside a class body
|
|
835
|
+
* that is `private` (or uses the `#name` private-hash form), does not already
|
|
836
|
+
* carry `readonly`, and is initialized at the declaration site. A field
|
|
837
|
+
* initialized at declaration time is set before the constructor runs, so
|
|
838
|
+
* locking it as `readonly` rules out accidental reassignments without
|
|
839
|
+
* changing runtime behavior. The fully type-aware upstream rule also walks
|
|
840
|
+
* assignments inside the constructor and other methods; the AST baseline
|
|
841
|
+
* targets the narrow but safe shape.
|
|
879
842
|
*
|
|
880
843
|
* @reference https://typescript-eslint.io/rules/prefer-readonly
|
|
881
844
|
*/
|
|
@@ -884,178 +847,162 @@ export interface ITtscLintTypeScriptRules {
|
|
|
884
847
|
* Prefer `arr.reduce<T>(callback, initial)` over the assertion-on-
|
|
885
848
|
* initial-value pattern `arr.reduce(callback, initial as T)`.
|
|
886
849
|
*
|
|
887
|
-
* Type-aware via the Checker. The accumulator type bound through a
|
|
888
|
-
*
|
|
889
|
-
*
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
* or angle-bracket type assertion.
|
|
850
|
+
* Type-aware via the Checker. The accumulator type bound through a call-site
|
|
851
|
+
* type parameter constrains the callback's accumulator parameter directly; an
|
|
852
|
+
* `as` on the seed only widens the runtime value and lets the callback infer
|
|
853
|
+
* the accumulator's parameter type from the seed's widened literal shape
|
|
854
|
+
* instead. The rule fires only when the `.reduce` receiver is provably an
|
|
855
|
+
* array or tuple, the call has no existing type arguments, and the second
|
|
856
|
+
* argument is an `as` or angle-bracket type assertion.
|
|
895
857
|
*
|
|
896
858
|
* @reference https://typescript-eslint.io/rules/prefer-reduce-type-parameter
|
|
897
859
|
*/
|
|
898
860
|
"typescript/prefer-reduce-type-parameter"?: TtscLintRuleSetting;
|
|
899
861
|
/**
|
|
900
|
-
* Prefer `re.exec(str)` over `str.match(re)` when the regex has no
|
|
901
|
-
* `g` flag.
|
|
862
|
+
* Prefer `re.exec(str)` over `str.match(re)` when the regex has no `g` flag.
|
|
902
863
|
*
|
|
903
|
-
* Type-aware via the Checker. Both shapes return the same
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
* conservatively skipped because static flag tracking would explode
|
|
912
|
-
* in scope.
|
|
864
|
+
* Type-aware via the Checker. Both shapes return the same `RegExpExecArray |
|
|
865
|
+
* null` for first-match queries, but `String#match` silently switches to
|
|
866
|
+
* "every match" the moment the regex gains the `g` flag — a typo at the regex
|
|
867
|
+
* literal changes the call's return shape from `[fullMatch, ...captures]` to
|
|
868
|
+
* a flat `string[]` of matches. The AST-only baseline reads the flag suffix
|
|
869
|
+
* off the regex literal directly; non-literal regex arguments (a `new
|
|
870
|
+
* RegExp(...)`, a variable holding `/.../`) are conservatively skipped
|
|
871
|
+
* because static flag tracking would explode in scope.
|
|
913
872
|
*
|
|
914
873
|
* @reference https://typescript-eslint.io/rules/prefer-regexp-exec
|
|
915
874
|
*/
|
|
916
875
|
"typescript/prefer-regexp-exec"?: TtscLintRuleSetting;
|
|
917
876
|
/**
|
|
918
|
-
* When an instance method always `return this`, declare its return
|
|
919
|
-
*
|
|
920
|
-
*
|
|
921
|
-
* stays polymorphic.
|
|
877
|
+
* When an instance method always `return this`, declare its return type as
|
|
878
|
+
* `this` instead of the enclosing class name so subclass call sites keep the
|
|
879
|
+
* narrower receiver type and method-chaining stays polymorphic.
|
|
922
880
|
*
|
|
923
|
-
* Type-aware via the Checker. Fires only when the method declares
|
|
924
|
-
*
|
|
925
|
-
*
|
|
926
|
-
*
|
|
927
|
-
*
|
|
928
|
-
*
|
|
929
|
-
* semantics the `this` rewrite does not preserve.
|
|
881
|
+
* Type-aware via the Checker. Fires only when the method declares an explicit
|
|
882
|
+
* non-`this` return-type annotation AND every value-returning `return`
|
|
883
|
+
* statement in the body returns exactly `this`. Methods with no annotation,
|
|
884
|
+
* methods with at least one non-`this` return, `async` methods, generators,
|
|
885
|
+
* constructors, accessors, and static methods are skipped — each has
|
|
886
|
+
* return-shape semantics the `this` rewrite does not preserve.
|
|
930
887
|
*
|
|
931
888
|
* @reference https://typescript-eslint.io/rules/prefer-return-this-type
|
|
932
889
|
*/
|
|
933
890
|
"typescript/prefer-return-this-type"?: TtscLintRuleSetting;
|
|
934
891
|
/**
|
|
935
|
-
* Prefer `str.startsWith(prefix)` / `str.endsWith(suffix)` over the
|
|
936
|
-
*
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
* and `/suffix$/.test(str)`.
|
|
892
|
+
* Prefer `str.startsWith(prefix)` / `str.endsWith(suffix)` over the `indexOf`
|
|
893
|
+
* / `lastIndexOf` and anchored-regex idioms — `str.indexOf(p) === 0`,
|
|
894
|
+
* `str.indexOf(p, str.length - p.length) !== -1`, `str.lastIndexOf(p) ===
|
|
895
|
+
* str.length - p.length`, `/^prefix/.test(str)`, and `/suffix$/.test(str)`.
|
|
940
896
|
*
|
|
941
|
-
* Type-aware via the Checker. Fires only when the string-position
|
|
942
|
-
*
|
|
943
|
-
*
|
|
944
|
-
*
|
|
897
|
+
* Type-aware via the Checker. Fires only when the string-position subject is
|
|
898
|
+
* provably a `string`-like type. The dedicated methods state the intent
|
|
899
|
+
* directly and avoid the off-by-one arithmetic and regex-anchor pitfalls of
|
|
900
|
+
* the older shapes.
|
|
945
901
|
*
|
|
946
902
|
* @reference https://typescript-eslint.io/rules/prefer-string-starts-ends-with
|
|
947
903
|
*/
|
|
948
904
|
"typescript/prefer-string-starts-ends-with"?: TtscLintRuleSetting;
|
|
949
905
|
/**
|
|
950
|
-
* Require functions whose return type is `Promise<T>` (or a
|
|
951
|
-
*
|
|
906
|
+
* Require functions whose return type is `Promise<T>` (or a Promise-like
|
|
907
|
+
* thenable) to be declared with the `async` keyword.
|
|
952
908
|
*
|
|
953
|
-
* Type-aware via the Checker. An `async` function wraps a synchronous
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
* abstract methods, and declaration-merging hosts (functions with
|
|
909
|
+
* Type-aware via the Checker. An `async` function wraps a synchronous `throw`
|
|
910
|
+
* into a rejected Promise so the caller's `await` / `.catch(...)` observes
|
|
911
|
+
* it; the non-async equivalent throws synchronously and bypasses every
|
|
912
|
+
* Promise-aware handler downstream. Marking the function `async` keeps the
|
|
913
|
+
* rejection channel consistent with the declared return type. Overload
|
|
914
|
+
* signatures, abstract methods, and declaration-merging hosts (functions with
|
|
960
915
|
* no body) are skipped — there is no body to wrap.
|
|
961
916
|
*
|
|
962
917
|
* @reference https://typescript-eslint.io/rules/promise-function-async
|
|
963
918
|
*/
|
|
964
919
|
"typescript/promise-function-async"?: TtscLintRuleSetting;
|
|
965
920
|
/**
|
|
966
|
-
* Reject a `get` accessor whose declared return type does not match
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
* accessors carry independent annotations.
|
|
921
|
+
* Reject a `get` accessor whose declared return type does not match the
|
|
922
|
+
* parameter type of its companion `set` accessor on the same class. The
|
|
923
|
+
* accessor pair presents a single conceptual field to callers — `obj.x = v`
|
|
924
|
+
* followed by `w = obj.x` should round-trip with compatible types — but
|
|
925
|
+
* TypeScript otherwise lets the two accessors carry independent annotations.
|
|
972
926
|
*
|
|
973
|
-
* Type-aware. The comparison resolves both sides through the
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
* is decided.
|
|
927
|
+
* Type-aware. The comparison resolves both sides through the Checker so type
|
|
928
|
+
* aliases, generic parameters, and union constituents collapse to the same
|
|
929
|
+
* set of values before equality is decided.
|
|
977
930
|
*
|
|
978
931
|
* @reference https://typescript-eslint.io/rules/related-getter-setter-pairs
|
|
979
932
|
*/
|
|
980
933
|
"typescript/related-getter-setter-pairs"?: TtscLintRuleSetting;
|
|
981
934
|
/**
|
|
982
|
-
* Require `arr.sort()` and `arr.toSorted()` calls to pass an
|
|
983
|
-
*
|
|
935
|
+
* Require `arr.sort()` and `arr.toSorted()` calls to pass an explicit
|
|
936
|
+
* `compareFunction`.
|
|
984
937
|
*
|
|
985
|
-
* Without a comparator both methods coerce elements to strings and
|
|
986
|
-
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
* trigger the rule.
|
|
938
|
+
* Without a comparator both methods coerce elements to strings and sort
|
|
939
|
+
* lexically, so `[10, 2, 1].sort()` returns `[1, 10, 2]` — almost never the
|
|
940
|
+
* intent. Type-aware via the Checker: only fires when the receiver is
|
|
941
|
+
* provably an array or tuple, so user-defined methods named `sort` /
|
|
942
|
+
* `toSorted` on non-array types do not trigger the rule.
|
|
991
943
|
*
|
|
992
944
|
* @reference https://typescript-eslint.io/rules/require-array-sort-compare
|
|
993
945
|
*/
|
|
994
946
|
"typescript/require-array-sort-compare"?: TtscLintRuleSetting;
|
|
995
947
|
/**
|
|
996
|
-
* Reject `async` functions whose body contains no `await`
|
|
997
|
-
* expression.
|
|
948
|
+
* Reject `async` functions whose body contains no `await` expression.
|
|
998
949
|
*
|
|
999
|
-
* An async function with no `await` only inflates the return type
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
950
|
+
* An async function with no `await` only inflates the return type to
|
|
951
|
+
* `Promise<T>` without doing any asynchronous work; collapse it to a sync
|
|
952
|
+
* function. Async generators are accepted as long as they have at least one
|
|
953
|
+
* `yield`.
|
|
1003
954
|
*
|
|
1004
955
|
* @reference https://typescript-eslint.io/rules/require-await
|
|
1005
956
|
*/
|
|
1006
957
|
"typescript/require-await"?: TtscLintRuleSetting;
|
|
1007
958
|
/**
|
|
1008
|
-
* Reject `+` expressions whose operands are not both `number`,
|
|
1009
|
-
*
|
|
959
|
+
* Reject `+` expressions whose operands are not both `number`, both `string`,
|
|
960
|
+
* or both `bigint`.
|
|
1010
961
|
*
|
|
1011
|
-
* Type-aware via the Checker. `1 + "a"`, `null + 5`, and
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1015
|
-
* or use a template literal.
|
|
962
|
+
* Type-aware via the Checker. `1 + "a"`, `null + 5`, and `obj + 1` are
|
|
963
|
+
* silently coerced by the runtime — almost always a bug. Mixed
|
|
964
|
+
* `number`/`string` concatenations are likewise rejected: the author should
|
|
965
|
+
* convert explicitly with `String(x)` or use a template literal.
|
|
1016
966
|
*
|
|
1017
967
|
* @reference https://typescript-eslint.io/rules/restrict-plus-operands
|
|
1018
968
|
*/
|
|
1019
969
|
"typescript/restrict-plus-operands"?: TtscLintRuleSetting;
|
|
1020
970
|
/**
|
|
1021
|
-
* Reject template-literal interpolations whose expression carries a
|
|
1022
|
-
*
|
|
1023
|
-
*
|
|
971
|
+
* Reject template-literal interpolations whose expression carries a type that
|
|
972
|
+
* does not stringify cleanly — `${obj}` prints `"[object Object]"`, `${null}`
|
|
973
|
+
* prints `"null"`, and so on.
|
|
1024
974
|
*
|
|
1025
|
-
* Type-aware via the Checker. Each `${...}` span's type must be
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
* constituent stringify cleanly.
|
|
975
|
+
* Type-aware via the Checker. Each `${...}` span's type must be string-like,
|
|
976
|
+
* number-like, bigint-like, or boolean-like; `any`, `unknown`, and `never`
|
|
977
|
+
* pass through to avoid false positives on generic helpers, matching upstream
|
|
978
|
+
* `allowAny` / `allowNever` defaults. Union and intersection types must have
|
|
979
|
+
* every constituent stringify cleanly.
|
|
1031
980
|
*
|
|
1032
981
|
* @reference https://typescript-eslint.io/rules/restrict-template-expressions
|
|
1033
982
|
*/
|
|
1034
983
|
"typescript/restrict-template-expressions"?: TtscLintRuleSetting;
|
|
1035
984
|
/**
|
|
1036
|
-
* Reject `return promise` inside `try`, `catch`, or `finally`;
|
|
1037
|
-
*
|
|
985
|
+
* Reject `return promise` inside `try`, `catch`, or `finally`; require
|
|
986
|
+
* `return await promise`.
|
|
1038
987
|
*
|
|
1039
|
-
* Without the `await`, the surrounding handler unbinds before the
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
988
|
+
* Without the `await`, the surrounding handler unbinds before the promise
|
|
989
|
+
* settles, so a rejection skips the `catch` block entirely and the `finally`
|
|
990
|
+
* cleanup races the result.
|
|
1042
991
|
*
|
|
1043
992
|
* @reference https://typescript-eslint.io/rules/return-await
|
|
1044
993
|
*/
|
|
1045
994
|
"typescript/return-await"?: TtscLintRuleSetting;
|
|
1046
995
|
/**
|
|
1047
996
|
* Require union and intersection type constituents to be listed in a
|
|
1048
|
-
* canonical group order — keyword primitives alphabetized first,
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1052
|
-
* discussion from review.
|
|
997
|
+
* canonical group order — keyword primitives alphabetized first, named /
|
|
998
|
+
* object references alphabetized next, `null` / `undefined` last. Two authors
|
|
999
|
+
* writing the same set of values can otherwise disagree on the spelling, and
|
|
1000
|
+
* the canonical order eliminates that discussion from review.
|
|
1053
1001
|
*
|
|
1054
1002
|
* AST-only baseline: ordering is decided by syntactic group (keyword
|
|
1055
|
-
* primitive vs. named reference vs. nullish) and a within-group
|
|
1056
|
-
*
|
|
1057
|
-
* the
|
|
1058
|
-
* diagnostic.
|
|
1003
|
+
* primitive vs. named reference vs. nullish) and a within-group source-text
|
|
1004
|
+
* sort. Nested unions / intersections are skipped — only the outermost shape,
|
|
1005
|
+
* the one the author wrote, fires the diagnostic.
|
|
1059
1006
|
*
|
|
1060
1007
|
* @reference https://typescript-eslint.io/rules/sort-type-constituents
|
|
1061
1008
|
*/
|
|
@@ -1063,36 +1010,33 @@ export interface ITtscLintTypeScriptRules {
|
|
|
1063
1010
|
/**
|
|
1064
1011
|
* Reject non-boolean values used in a boolean context.
|
|
1065
1012
|
*
|
|
1066
|
-
* Type-aware via the Checker. Fires when the test of an `if`,
|
|
1067
|
-
* `
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
* coerce in boolean position; an explicit comparison (`count !== 0`,
|
|
1013
|
+
* Type-aware via the Checker. Fires when the test of an `if`, `while`, `do`,
|
|
1014
|
+
* `for`, or ternary, the operand of `!`, or either side of `&&` / `||`
|
|
1015
|
+
* carries a type whose flags are not pure boolean. Numbers (`if (count)` is
|
|
1016
|
+
* truthy for any non-zero), strings (`""` is falsy), and nullable objects
|
|
1017
|
+
* (`if (obj)` conflates `null` / `undefined` with a present object) all
|
|
1018
|
+
* silently coerce in boolean position; an explicit comparison (`count !== 0`,
|
|
1073
1019
|
* `str.length > 0`, `obj != null`) names the intent.
|
|
1074
1020
|
*
|
|
1075
1021
|
* @reference https://typescript-eslint.io/rules/strict-boolean-expressions
|
|
1076
1022
|
*/
|
|
1077
1023
|
"typescript/strict-boolean-expressions"?: TtscLintRuleSetting;
|
|
1078
1024
|
/**
|
|
1079
|
-
* Require every member of a union or `enum` discriminant to be
|
|
1080
|
-
*
|
|
1081
|
-
* present.
|
|
1025
|
+
* Require every member of a union or `enum` discriminant to be covered by an
|
|
1026
|
+
* explicit `case`, unless a `default` clause is present.
|
|
1082
1027
|
*
|
|
1083
|
-
* Type-aware via the Checker. The rule resolves the discriminant
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
* `default` clause
|
|
1088
|
-
* remaining shape and silences the rule.
|
|
1028
|
+
* Type-aware via the Checker. The rule resolves the discriminant type, walks
|
|
1029
|
+
* each constituent of the union (or each member of the enum), matches it
|
|
1030
|
+
* against the `case` expressions in the body, and flags the switch when at
|
|
1031
|
+
* least one constituent is uncovered and no `default` clause is present. A
|
|
1032
|
+
* `default` clause covers the remaining shape and silences the rule.
|
|
1089
1033
|
*
|
|
1090
1034
|
* @reference https://typescript-eslint.io/rules/switch-exhaustiveness-check
|
|
1091
1035
|
*/
|
|
1092
1036
|
"typescript/switch-exhaustiveness-check"?: TtscLintRuleSetting;
|
|
1093
1037
|
/**
|
|
1094
|
-
* Reject `/// <reference path="..." />`, `/// <reference types=""
|
|
1095
|
-
*
|
|
1038
|
+
* Reject `/// <reference path="..." />`, `/// <reference types="" />`, and
|
|
1039
|
+
* `/// <reference lib="" />` directives.
|
|
1096
1040
|
*
|
|
1097
1041
|
* Replace with `import` (or `import type`) declarations and
|
|
1098
1042
|
* `compilerOptions.types` in `tsconfig.json`.
|
|
@@ -1101,30 +1045,28 @@ export interface ITtscLintTypeScriptRules {
|
|
|
1101
1045
|
*/
|
|
1102
1046
|
"typescript/triple-slash-reference"?: TtscLintRuleSetting;
|
|
1103
1047
|
/**
|
|
1104
|
-
* Reject referencing a class instance method as a value instead of
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1048
|
+
* Reject referencing a class instance method as a value instead of calling it
|
|
1049
|
+
* (`obj.method` passed as a callback, aliased to a variable, or stored on
|
|
1050
|
+
* another object).
|
|
1107
1051
|
*
|
|
1108
|
-
* Type-aware via the Checker. JavaScript methods are not bound to
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
* stably bound.
|
|
1052
|
+
* Type-aware via the Checker. JavaScript methods are not bound to their
|
|
1053
|
+
* receiver — once extracted, `this` resolves to whatever the caller supplies
|
|
1054
|
+
* (usually `undefined` in strict mode or the host object the value lands on).
|
|
1055
|
+
* Safe positions — immediate call (`obj.method()`), assignment target,
|
|
1056
|
+
* `typeof` / `delete` operand, `instanceof` / `in` operand, and
|
|
1057
|
+
* tagged-template tag — pass through; static methods are exempt because the
|
|
1058
|
+
* constructor is stably bound.
|
|
1116
1059
|
*
|
|
1117
1060
|
* @reference https://typescript-eslint.io/rules/unbound-method
|
|
1118
1061
|
*/
|
|
1119
1062
|
"typescript/unbound-method"?: TtscLintRuleSetting;
|
|
1120
1063
|
/**
|
|
1121
|
-
* Require the callback parameter of `.catch(...)` and the second
|
|
1122
|
-
*
|
|
1064
|
+
* Require the callback parameter of `.catch(...)` and the second argument of
|
|
1065
|
+
* `.then(...)` to be typed `unknown`.
|
|
1123
1066
|
*
|
|
1124
|
-
* Mirrors TypeScript 4.4+ `useUnknownInCatchVariables`, which made
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
* implicit `any`.
|
|
1067
|
+
* Mirrors TypeScript 4.4+ `useUnknownInCatchVariables`, which made `catch
|
|
1068
|
+
* (e)` default to `unknown` — the same discipline applied to promise
|
|
1069
|
+
* rejection handlers so a rejection cannot smuggle in an implicit `any`.
|
|
1128
1070
|
*
|
|
1129
1071
|
* @reference https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
|
|
1130
1072
|
*/
|