@ttsc/lint 0.18.4 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -43
- package/go.mod +5 -4
- package/internal/rulecode/rulecode.go +88 -0
- package/lib/index.d.ts +10 -1
- package/lib/index.js +45 -17
- package/lib/index.js.map +1 -1
- package/lib/structures/ITtscLintConfig.d.ts +3 -0
- package/lib/structures/TtscLintRuleSetting.d.ts +3 -2
- package/lib/structures/format/ITtscLintFormat.d.ts +3 -2
- package/lib/structures/format/ITtscLintFormatSortImports.d.ts +20 -4
- package/lib/structures/rules/ITtscLintBoundariesRuleOptions.d.ts +80 -8
- package/lib/structures/rules/ITtscLintBoundariesRules.d.ts +6 -8
- package/lib/structures/rules/ITtscLintContributorRules.d.ts +18 -2
- package/lib/structures/rules/ITtscLintCoreRuleOptions.d.ts +347 -0
- package/lib/structures/rules/ITtscLintCoreRuleOptions.js +3 -0
- package/lib/structures/rules/ITtscLintCoreRuleOptions.js.map +1 -0
- package/lib/structures/rules/ITtscLintCoreRules.d.ts +101 -67
- package/lib/structures/rules/ITtscLintRegexpRules.d.ts +7 -2
- package/lib/structures/rules/ITtscLintRuleOptionsMap.d.ts +53 -7
- package/lib/structures/rules/ITtscLintRules.d.ts +6 -2
- package/lib/structures/rules/ITtscLintSolidRules.d.ts +0 -8
- package/lib/structures/rules/ITtscLintTypeScriptRuleOptions.d.ts +206 -0
- package/lib/structures/rules/ITtscLintTypeScriptRuleOptions.js +8 -0
- package/lib/structures/rules/ITtscLintTypeScriptRuleOptions.js.map +1 -0
- package/lib/structures/rules/ITtscLintTypeScriptRules.d.ts +55 -42
- package/lib/structures/rules/ITtscLintUnicornRuleOptions.d.ts +276 -0
- package/lib/structures/rules/ITtscLintUnicornRuleOptions.js +3 -0
- package/lib/structures/rules/ITtscLintUnicornRuleOptions.js.map +1 -0
- package/lib/structures/rules/ITtscLintUnicornRules.d.ts +44 -36
- package/lib/structures/rules/index.d.ts +3 -0
- package/lib/structures/rules/index.js +3 -0
- package/lib/structures/rules/index.js.map +1 -1
- package/linthost/ast_helpers.go +521 -23
- package/linthost/ast_selector_matcher.go +1628 -0
- package/linthost/ast_selector_parser.go +628 -0
- package/linthost/comment_scan.go +154 -0
- package/linthost/compile.go +129 -79
- package/linthost/config.go +352 -88
- package/linthost/config_format.go +15 -1
- package/linthost/contrib_adapter.go +47 -8
- package/linthost/declaration_rules.go +12 -11
- package/linthost/directives.go +9 -67
- package/linthost/dispatch.go +37 -3
- package/linthost/engine.go +368 -53
- package/linthost/escape_string.go +77 -0
- package/linthost/fix.go +133 -23
- package/linthost/flags_gen.go +18 -17
- package/linthost/format.go +73 -167
- package/linthost/format_editor_settings.go +134 -26
- package/linthost/grapheme_tables_gen.go +1920 -0
- package/linthost/host.go +160 -61
- package/linthost/literal_escape_scan.go +117 -0
- package/linthost/lsp.go +545 -98
- package/linthost/numeric_literal_precision.go +228 -0
- package/linthost/polyfill_browserslist.go +1439 -0
- package/linthost/polyfill_browserslist_config.go +603 -0
- package/linthost/polyfill_corejs.go +750 -0
- package/linthost/polyfill_data.go +113 -0
- package/linthost/polyfill_data_gen.json +39868 -0
- package/linthost/print_nodes_array.go +7 -1
- package/linthost/print_nodes_object.go +7 -1
- package/linthost/project_engine.go +151 -0
- package/linthost/project_rules.go +78 -0
- package/linthost/regex_clean.go +191 -0
- package/linthost/regex_tree.go +1544 -0
- package/linthost/regex_tree_optimizer.go +1685 -0
- package/linthost/regexp_cache.go +44 -0
- package/linthost/rule_codes.go +105 -0
- package/linthost/rule_codes.json +745 -0
- package/linthost/rules_ban_ts_comment.go +312 -0
- package/linthost/rules_boundaries.go +128 -43
- package/linthost/rules_boundaries_dependencies.go +1013 -0
- package/linthost/rules_core_extra.go +62 -92
- package/linthost/rules_cypress.go +1 -1
- package/linthost/rules_default_case.go +87 -11
- package/linthost/rules_dupes.go +38 -13
- package/linthost/rules_empty.go +188 -20
- package/linthost/rules_escape.go +62 -48
- package/linthost/rules_format_arrow_parens.go +19 -5
- package/linthost/rules_format_bracket_spacing.go +1 -1
- package/linthost/rules_format_clause_join.go +1 -1
- package/linthost/rules_format_declaration_header.go +31 -19
- package/linthost/rules_format_indent.go +1 -1
- package/linthost/rules_format_jsdoc.go +1 -1
- package/linthost/rules_format_orphan_semi.go +1 -1
- package/linthost/rules_format_parameter_properties.go +17 -7
- package/linthost/rules_format_print_width.go +1 -1
- package/linthost/rules_format_quote_props.go +1 -1
- package/linthost/rules_format_quotes.go +1 -1
- package/linthost/rules_format_semi.go +106 -79
- package/linthost/rules_format_sort_imports.go +79 -45
- package/linthost/rules_format_statement_split.go +1 -1
- package/linthost/rules_format_ternary_nullish_parens.go +1 -1
- package/linthost/rules_format_trailing_comma.go +64 -1
- package/linthost/rules_format_whitespace.go +1 -1
- package/linthost/rules_functional.go +21 -22
- package/linthost/rules_gap.go +80 -3
- package/linthost/rules_grouped_accessor_pairs.go +84 -25
- package/linthost/rules_guard_for_in.go +64 -147
- package/linthost/rules_jsx_a11y.go +232 -22
- package/linthost/rules_logic.go +84 -38
- package/linthost/rules_nextjs.go +105 -16
- package/linthost/rules_no_class_assign.go +70 -0
- package/linthost/rules_no_duplicate_imports.go +266 -0
- package/linthost/rules_no_else_return.go +156 -38
- package/linthost/rules_no_extend_native.go +113 -17
- package/linthost/rules_no_fallthrough.go +1013 -0
- package/linthost/rules_no_func_assign.go +70 -0
- package/linthost/rules_no_import_assign.go +278 -86
- package/linthost/rules_no_inner_declarations.go +186 -0
- package/linthost/rules_no_loop_func.go +438 -53
- package/linthost/rules_no_mixed_operators.go +208 -52
- package/linthost/rules_no_param_reassign.go +376 -61
- package/linthost/rules_no_promise_executor_return.go +156 -0
- package/linthost/rules_no_restricted_imports.go +1013 -57
- package/linthost/rules_no_restricted_syntax.go +190 -26
- package/linthost/rules_no_useless_constructor.go +6 -36
- package/linthost/rules_problems.go +154 -311
- package/linthost/rules_promise.go +2578 -109
- package/linthost/rules_react_extras.go +71 -45
- package/linthost/rules_react_hooks.go +18 -2
- package/linthost/rules_react_perf.go +1 -0
- package/linthost/rules_react_refresh.go +1 -1
- package/linthost/rules_regexp.go +230 -14
- package/linthost/rules_security.go +45 -19
- package/linthost/rules_self.go +21 -1
- package/linthost/rules_solid.go +13 -7
- package/linthost/rules_storybook.go +1 -1
- package/linthost/rules_suggestions.go +490 -84
- package/linthost/rules_testing_library.go +12 -1
- package/linthost/rules_ts.go +227 -54
- package/linthost/rules_ts_async.go +0 -131
- package/linthost/rules_ts_no_base_to_string.go +3 -4
- package/linthost/rules_ts_no_misused_promises.go +817 -0
- package/linthost/rules_ts_no_restricted_types.go +320 -34
- package/linthost/rules_ts_no_unnecessary_qualifier.go +132 -55
- package/linthost/rules_ts_no_unsafe_assignment.go +608 -60
- package/linthost/rules_ts_require_array_sort_compare.go +5 -5
- package/linthost/rules_ts_switch_exhaustiveness_check.go +556 -86
- package/linthost/rules_unicorn_better_regex.go +224 -16
- package/linthost/rules_unicorn_consistent_destructuring.go +1002 -7
- package/linthost/rules_unicorn_consistent_existence_index_check.go +208 -29
- package/linthost/rules_unicorn_consistent_function_scoping.go +1041 -8
- package/linthost/rules_unicorn_consistent_template_literal_escape.go +178 -7
- package/linthost/rules_unicorn_escape_case.go +30 -19
- package/linthost/rules_unicorn_filename_case.go +763 -16
- package/linthost/rules_unicorn_import_style.go +783 -17
- package/linthost/rules_unicorn_isolated_functions.go +934 -14
- package/linthost/rules_unicorn_no_hex_escape.go +26 -11
- package/linthost/rules_unicorn_no_typeof_undefined.go +234 -25
- package/linthost/rules_unicorn_no_unnecessary_polyfills.go +376 -21
- package/linthost/rules_unicorn_no_unused_properties.go +756 -19
- package/linthost/rules_unicorn_number_literal_case.go +58 -39
- package/linthost/rules_unicorn_prefer_at.go +7 -3
- package/linthost/rules_unicorn_prefer_number_properties.go +381 -48
- package/linthost/rules_unicorn_prefer_optional_catch_binding.go +24 -24
- package/linthost/rules_unicorn_prefer_simple_condition_first.go +597 -19
- package/linthost/rules_unicorn_prefer_string_raw.go +147 -16
- package/linthost/rules_unicorn_prevent_abbreviations.go +1963 -95
- package/linthost/rules_unicorn_string_content.go +611 -15
- package/linthost/rules_unicorn_switch_case_break_position.go +172 -15
- package/linthost/rules_unicorn_template_indent.go +923 -18
- package/linthost/rules_unicorn_text_encoding_identifier_case.go +202 -42
- package/linthost/rules_unicorn_throw_new_error.go +218 -26
- package/linthost/rules_var.go +829 -142
- package/linthost/string_length.go +222 -0
- package/package.json +4 -3
- package/rule/project.go +145 -0
- package/rule/rule.go +58 -1
- package/src/index.ts +58 -17
- package/src/structures/ITtscLintConfig.ts +3 -0
- package/src/structures/TtscLintRuleSetting.ts +3 -2
- package/src/structures/format/ITtscLintFormat.ts +3 -2
- package/src/structures/format/ITtscLintFormatSortImports.ts +21 -4
- package/src/structures/rules/ITtscLintBoundariesRuleOptions.ts +122 -8
- package/src/structures/rules/ITtscLintBoundariesRules.ts +6 -8
- package/src/structures/rules/ITtscLintContributorRules.ts +18 -2
- package/src/structures/rules/ITtscLintCoreRuleOptions.ts +465 -0
- package/src/structures/rules/ITtscLintCoreRules.ts +122 -67
- package/src/structures/rules/ITtscLintRegexpRules.ts +7 -2
- package/src/structures/rules/ITtscLintRuleOptionsMap.ts +88 -7
- package/src/structures/rules/ITtscLintRules.ts +7 -2
- package/src/structures/rules/ITtscLintSolidRules.ts +0 -9
- package/src/structures/rules/ITtscLintTypeScriptRuleOptions.ts +248 -0
- package/src/structures/rules/ITtscLintTypeScriptRules.ts +64 -42
- package/src/structures/rules/ITtscLintUnicornRuleOptions.ts +350 -0
- package/src/structures/rules/ITtscLintUnicornRules.ts +60 -36
- package/src/structures/rules/index.ts +3 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options shapes for the configurable rules in {@link ITtscLintTypeScriptRules}.
|
|
3
|
+
*
|
|
4
|
+
* @reference https://typescript-eslint.io/rules/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Identifies a type or value declared in a project file. */
|
|
8
|
+
export interface ITtscLintFileTypeOrValueSpecifier {
|
|
9
|
+
/** Select project-file declarations. */
|
|
10
|
+
from: "file";
|
|
11
|
+
/** Match one or more declared names. */
|
|
12
|
+
name: string | readonly string[];
|
|
13
|
+
/** Restrict the match to this project-relative declaration file. */
|
|
14
|
+
path?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Identifies a type or value declared by TypeScript's default libraries. */
|
|
18
|
+
export interface ITtscLintLibTypeOrValueSpecifier {
|
|
19
|
+
/** Select TypeScript default-library declarations. */
|
|
20
|
+
from: "lib";
|
|
21
|
+
/** Match one or more declared names. */
|
|
22
|
+
name: string | readonly string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Identifies a type or value declared by an installed package. */
|
|
26
|
+
export interface ITtscLintPackageTypeOrValueSpecifier {
|
|
27
|
+
/** Select package declarations. */
|
|
28
|
+
from: "package";
|
|
29
|
+
/** Match one or more declared names. */
|
|
30
|
+
name: string | readonly string[];
|
|
31
|
+
/** Require declarations from this package or ambient module. */
|
|
32
|
+
package: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Identifies a type or value by name and, preferably, declaration source. */
|
|
36
|
+
export type TtscLintTypeOrValueSpecifier =
|
|
37
|
+
| string
|
|
38
|
+
| ITtscLintFileTypeOrValueSpecifier
|
|
39
|
+
| ITtscLintLibTypeOrValueSpecifier
|
|
40
|
+
| ITtscLintPackageTypeOrValueSpecifier;
|
|
41
|
+
|
|
42
|
+
/** One structured replacement policy in `typescript/no-restricted-types`. */
|
|
43
|
+
export interface ITtscLintTypeScriptNoRestrictedTypesTypeConfig {
|
|
44
|
+
/** Custom text appended to the standard diagnostic. */
|
|
45
|
+
message: string;
|
|
46
|
+
/** Replacement applied automatically by `ttsc fix`. */
|
|
47
|
+
fixWith?: string;
|
|
48
|
+
/** Replacement choices exposed as opt-in editor suggestions. */
|
|
49
|
+
suggest?: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Policy value for one normalized type spelling. */
|
|
53
|
+
export type TtscLintTypeScriptNoRestrictedTypesTypeValue =
|
|
54
|
+
| boolean
|
|
55
|
+
| string
|
|
56
|
+
| ITtscLintTypeScriptNoRestrictedTypesTypeConfig
|
|
57
|
+
| null;
|
|
58
|
+
|
|
59
|
+
/** Options for `typescript/no-restricted-types`. */
|
|
60
|
+
export interface ITtscLintTypeScriptNoRestrictedTypesRuleOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Type spellings to reject. Whitespace is ignored in both keys and source
|
|
63
|
+
* spellings; `false` and `null` entries explicitly disable a key.
|
|
64
|
+
*/
|
|
65
|
+
types?: Readonly<
|
|
66
|
+
Record<string, TtscLintTypeScriptNoRestrictedTypesTypeValue>
|
|
67
|
+
>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Options for `typescript/no-floating-promises`. */
|
|
71
|
+
export interface ITtscLintTypeScriptNoFloatingPromisesRuleOptions {
|
|
72
|
+
/** Functions whose returned Promises may be discarded safely. */
|
|
73
|
+
allowForKnownSafeCalls?: readonly TtscLintTypeOrValueSpecifier[];
|
|
74
|
+
/** Promise types whose values may be discarded safely. */
|
|
75
|
+
allowForKnownSafePromises?: readonly TtscLintTypeOrValueSpecifier[];
|
|
76
|
+
/** Also inspect catchable structural thenables. Defaults to `false`. */
|
|
77
|
+
checkThenables?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Ignore immediately invoked function-expression results. Defaults to
|
|
80
|
+
* `false`.
|
|
81
|
+
*/
|
|
82
|
+
ignoreIIFE?: boolean;
|
|
83
|
+
/** Treat `void` as an explicit discard marker. Defaults to `true`. */
|
|
84
|
+
ignoreVoid?: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Policy for one `@ts-<directive>` comment kind in `typescript/ban-ts-comment`.
|
|
89
|
+
*
|
|
90
|
+
* - `true` — report every use of the directive.
|
|
91
|
+
* - `false` — allow the directive unconditionally.
|
|
92
|
+
* - `"allow-with-description"` — allow the directive when it is followed by a
|
|
93
|
+
* description of at least `minimumDescriptionLength` characters.
|
|
94
|
+
* - `{ descriptionFormat }` — additionally require the description to match the
|
|
95
|
+
* given regular expression (evaluated with Go's RE2 `regexp` syntax, which
|
|
96
|
+
* covers the usual patterns such as `"^: TS\\d+ because .+$"`).
|
|
97
|
+
*/
|
|
98
|
+
export type TtscLintTypeScriptBanTsCommentDirectiveConfig =
|
|
99
|
+
| boolean
|
|
100
|
+
| "allow-with-description"
|
|
101
|
+
| {
|
|
102
|
+
/**
|
|
103
|
+
* Regular expression the directive description must match. Matched
|
|
104
|
+
* against the raw text following the directive, including its leading
|
|
105
|
+
* whitespace, so anchored patterns usually start with `^: `.
|
|
106
|
+
*/
|
|
107
|
+
descriptionFormat: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* `typescript/ban-ts-comment` rule options.
|
|
112
|
+
*
|
|
113
|
+
* Absent directive keys keep the upstream recommended defaults: `@ts-check` is
|
|
114
|
+
* allowed, `@ts-expect-error` is allowed with a description, and `@ts-ignore` /
|
|
115
|
+
* `@ts-nocheck` are reported.
|
|
116
|
+
*/
|
|
117
|
+
export interface ITtscLintTypeScriptBanTsCommentRuleOptions {
|
|
118
|
+
/**
|
|
119
|
+
* Minimum description length (counted in Unicode 16.0 extended grapheme
|
|
120
|
+
* clusters, so one emoji is one character) for directives configured as
|
|
121
|
+
* `"allow-with-description"` or `{ descriptionFormat }`.
|
|
122
|
+
*
|
|
123
|
+
* @default 3
|
|
124
|
+
*/
|
|
125
|
+
minimumDescriptionLength?: number;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Policy for `@ts-check` pragma comments.
|
|
129
|
+
*
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
"ts-check"?: TtscLintTypeScriptBanTsCommentDirectiveConfig;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Policy for `@ts-expect-error` directive comments.
|
|
136
|
+
*
|
|
137
|
+
* @default "allow-with-description"
|
|
138
|
+
*/
|
|
139
|
+
"ts-expect-error"?: TtscLintTypeScriptBanTsCommentDirectiveConfig;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Policy for `@ts-ignore` directive comments.
|
|
143
|
+
*
|
|
144
|
+
* @default true
|
|
145
|
+
*/
|
|
146
|
+
"ts-ignore"?: TtscLintTypeScriptBanTsCommentDirectiveConfig;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Policy for `@ts-nocheck` pragma comments.
|
|
150
|
+
*
|
|
151
|
+
* @default true
|
|
152
|
+
*/
|
|
153
|
+
"ts-nocheck"?: TtscLintTypeScriptBanTsCommentDirectiveConfig;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Positions governed by `checksVoidReturn` in `typescript/no-misused-promises`.
|
|
158
|
+
*
|
|
159
|
+
* Omitted keys default to `true`.
|
|
160
|
+
*/
|
|
161
|
+
export interface ITtscLintTypeScriptNoMisusedPromisesChecksVoidReturnOptions {
|
|
162
|
+
/** Check Promise-returning callbacks passed as call/construct arguments. */
|
|
163
|
+
arguments?: boolean;
|
|
164
|
+
|
|
165
|
+
/** Check Promise-returning JSX attribute expressions. */
|
|
166
|
+
attributes?: boolean;
|
|
167
|
+
|
|
168
|
+
/** Check Promise-returning methods against extended/implemented types. */
|
|
169
|
+
inheritedMethods?: boolean;
|
|
170
|
+
|
|
171
|
+
/** Check Promise-returning functions in contextually typed properties. */
|
|
172
|
+
properties?: boolean;
|
|
173
|
+
|
|
174
|
+
/** Check Promise-returning functions returned from void-function factories. */
|
|
175
|
+
returns?: boolean;
|
|
176
|
+
|
|
177
|
+
/** Check Promise-returning functions assigned to variables. */
|
|
178
|
+
variables?: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** `typescript/no-misused-promises` rule options. */
|
|
182
|
+
export interface ITtscLintTypeScriptNoMisusedPromisesRuleOptions {
|
|
183
|
+
/**
|
|
184
|
+
* Check thenables used in boolean condition and predicate positions.
|
|
185
|
+
*
|
|
186
|
+
* @default true
|
|
187
|
+
*/
|
|
188
|
+
checksConditionals?: boolean;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Check thenables spread into object literals.
|
|
192
|
+
*
|
|
193
|
+
* @default true
|
|
194
|
+
*/
|
|
195
|
+
checksSpreads?: boolean;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Check Promise-returning functions where a void return is expected.
|
|
199
|
+
*
|
|
200
|
+
* @default true
|
|
201
|
+
*/
|
|
202
|
+
checksVoidReturn?:
|
|
203
|
+
| boolean
|
|
204
|
+
| ITtscLintTypeScriptNoMisusedPromisesChecksVoidReturnOptions;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* `typescript/switch-exhaustiveness-check` rule options.
|
|
209
|
+
*
|
|
210
|
+
* The defaults require every enumerable union member to have an explicit
|
|
211
|
+
* `case`, allow a redundant `default` on an already exhaustive switch, and do
|
|
212
|
+
* not require a `default` for open types such as `string` or `number`.
|
|
213
|
+
*
|
|
214
|
+
* @reference https://typescript-eslint.io/rules/switch-exhaustiveness-check
|
|
215
|
+
*/
|
|
216
|
+
export interface ITtscLintTypeScriptSwitchExhaustivenessCheckRuleOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Allow a `default` clause on a switch whose finite members are already
|
|
219
|
+
* covered explicitly.
|
|
220
|
+
*
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
allowDefaultCaseForExhaustiveSwitch?: boolean;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Treat a real `default` clause or matching trailing comment as coverage for
|
|
227
|
+
* otherwise missing finite members.
|
|
228
|
+
*
|
|
229
|
+
* @default false
|
|
230
|
+
*/
|
|
231
|
+
considerDefaultExhaustiveForUnions?: boolean;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Regular expression matched against the trimmed body of the last comment
|
|
235
|
+
* after the final `case`. The default marker is `/^no default$/iu`.
|
|
236
|
+
*
|
|
237
|
+
* Custom patterns use Go's RE2 `regexp` syntax.
|
|
238
|
+
*/
|
|
239
|
+
defaultCaseCommentPattern?: string;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Require a real `default` clause or matching trailing comment when the
|
|
243
|
+
* discriminant contains an open, non-literal type.
|
|
244
|
+
*
|
|
245
|
+
* @default false
|
|
246
|
+
*/
|
|
247
|
+
requireDefaultForNonUnion?: boolean;
|
|
248
|
+
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
TtscLintRuleOptionsSetting,
|
|
3
|
+
TtscLintRuleSetting,
|
|
4
|
+
} from "../TtscLintRuleSetting";
|
|
5
|
+
import type {
|
|
6
|
+
ITtscLintTypeScriptBanTsCommentRuleOptions,
|
|
7
|
+
ITtscLintTypeScriptNoFloatingPromisesRuleOptions,
|
|
8
|
+
ITtscLintTypeScriptNoMisusedPromisesRuleOptions,
|
|
9
|
+
ITtscLintTypeScriptNoRestrictedTypesRuleOptions,
|
|
10
|
+
ITtscLintTypeScriptSwitchExhaustivenessCheckRuleOptions,
|
|
11
|
+
} from "./ITtscLintTypeScriptRuleOptions";
|
|
2
12
|
|
|
3
13
|
/**
|
|
4
14
|
* TypeScript-only rules and `@typescript-eslint` plugin equivalents, exposed
|
|
@@ -41,25 +51,34 @@ export interface ITtscLintTypeScriptRules {
|
|
|
41
51
|
"typescript/array-type"?: TtscLintRuleSetting;
|
|
42
52
|
|
|
43
53
|
/**
|
|
44
|
-
* Reject `await`
|
|
54
|
+
* Reject non-awaitable ordinary `await` operands and native Promise
|
|
55
|
+
* aggregator members.
|
|
45
56
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
57
|
+
* Also reject sync-only `for await...of` and `await using` constructs.
|
|
58
|
+
*
|
|
59
|
+
* Type-aware. The Checker resolves Promise and well-known-symbol protocols,
|
|
60
|
+
* including each Promise aggregator input's synchronous iterator yield type.
|
|
61
|
+
* Ordinary `await` findings offer an opt-in editor suggestion, while
|
|
62
|
+
* automatic fix and fix-all paths leave the source unchanged.
|
|
48
63
|
*
|
|
49
64
|
* @reference https://typescript-eslint.io/rules/await-thenable
|
|
50
65
|
*/
|
|
51
66
|
"typescript/await-thenable"?: TtscLintRuleSetting;
|
|
52
67
|
|
|
53
68
|
/**
|
|
54
|
-
* Reject `@ts
|
|
69
|
+
* Reject `@ts-<directive>` comments, or require them to carry a description.
|
|
55
70
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
71
|
+
* With the upstream recommended defaults, `@ts-ignore` and `@ts-nocheck` are
|
|
72
|
+
* reported, `@ts-check` is allowed, and `@ts-expect-error` is allowed when
|
|
73
|
+
* followed by a description of at least three characters. Each directive is
|
|
74
|
+
* individually configurable as `boolean`, `"allow-with-description"`, or `{
|
|
75
|
+
* descriptionFormat }`, with `minimumDescriptionLength` governing the
|
|
76
|
+
* description-required forms. Banned `@ts-ignore` findings offer replacement
|
|
77
|
+
* with `@ts-expect-error` only as an opt-in editor suggestion.
|
|
59
78
|
*
|
|
60
79
|
* @reference https://typescript-eslint.io/rules/ban-ts-comment
|
|
61
80
|
*/
|
|
62
|
-
"typescript/ban-ts-comment"?:
|
|
81
|
+
"typescript/ban-ts-comment"?: TtscLintRuleOptionsSetting<ITtscLintTypeScriptBanTsCommentRuleOptions>;
|
|
63
82
|
|
|
64
83
|
/**
|
|
65
84
|
* Reject `// tslint:disable` and related TSLint directive comments left
|
|
@@ -307,12 +326,13 @@ export interface ITtscLintTypeScriptRules {
|
|
|
307
326
|
*
|
|
308
327
|
* Type-aware via the Checker. A floating promise loses its rejection channel
|
|
309
328
|
* and runs out of order with surrounding code. Acceptable sinks are `await`,
|
|
310
|
-
*
|
|
311
|
-
* `
|
|
329
|
+
* callable rejection handlers, assignment, the `void` operator by default,
|
|
330
|
+
* and `return`. A `.finally(...)` call is clean only when its receiver was
|
|
331
|
+
* already handled.
|
|
312
332
|
*
|
|
313
333
|
* @reference https://typescript-eslint.io/rules/no-floating-promises
|
|
314
334
|
*/
|
|
315
|
-
"typescript/no-floating-promises"?:
|
|
335
|
+
"typescript/no-floating-promises"?: TtscLintRuleOptionsSetting<ITtscLintTypeScriptNoFloatingPromisesRuleOptions>;
|
|
316
336
|
|
|
317
337
|
/**
|
|
318
338
|
* Reject `for (const k in arr)` where `arr` is statically typed as an array
|
|
@@ -392,15 +412,13 @@ export interface ITtscLintTypeScriptRules {
|
|
|
392
412
|
/**
|
|
393
413
|
* Reject Promise values supplied where a non-Promise was expected.
|
|
394
414
|
*
|
|
395
|
-
* Covers conditional
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
* `Array#forEach`, JSX event handlers), where the returned Promise is
|
|
399
|
-
* silently dropped.
|
|
415
|
+
* Covers conditional and predicate positions, Promise object spreads,
|
|
416
|
+
* synchronous disposal, and Promise-returning functions in void-return
|
|
417
|
+
* argument, JSX, inherited-method, property, return, and variable contexts.
|
|
400
418
|
*
|
|
401
419
|
* @reference https://typescript-eslint.io/rules/no-misused-promises
|
|
402
420
|
*/
|
|
403
|
-
"typescript/no-misused-promises"?:
|
|
421
|
+
"typescript/no-misused-promises"?: TtscLintRuleOptionsSetting<ITtscLintTypeScriptNoMisusedPromisesRuleOptions>;
|
|
404
422
|
|
|
405
423
|
/**
|
|
406
424
|
* Reject spread expressions whose operand is syntactically wrong for the
|
|
@@ -479,19 +497,13 @@ export interface ITtscLintTypeScriptRules {
|
|
|
479
497
|
"typescript/no-redundant-type-constituents"?: TtscLintRuleSetting;
|
|
480
498
|
|
|
481
499
|
/**
|
|
482
|
-
* Reject
|
|
483
|
-
*
|
|
484
|
-
* and
|
|
485
|
-
* explicit call signatures convey the intended type without the
|
|
486
|
-
* runtime-boxing semantics that the wrapper names imply.
|
|
487
|
-
*
|
|
488
|
-
* AST-only baseline: shadow guard reuses the same file-scope check as
|
|
489
|
-
* `no-wrapper-object-types` so a user-declared `interface String {}` is not
|
|
490
|
-
* flagged as the global wrapper.
|
|
500
|
+
* Reject the exact type spellings configured in the `types` map. The rule is
|
|
501
|
+
* a no-op without options. Entries can carry a custom message, an automatic
|
|
502
|
+
* replacement, and editor-only replacement suggestions.
|
|
491
503
|
*
|
|
492
504
|
* @reference https://typescript-eslint.io/rules/no-restricted-types
|
|
493
505
|
*/
|
|
494
|
-
"typescript/no-restricted-types"?:
|
|
506
|
+
"typescript/no-restricted-types"?: TtscLintRuleOptionsSetting<ITtscLintTypeScriptNoRestrictedTypesRuleOptions>;
|
|
495
507
|
|
|
496
508
|
/**
|
|
497
509
|
* Reject `require(...)` calls and `import x = require(...)` declarations.
|
|
@@ -614,7 +626,8 @@ export interface ITtscLintTypeScriptRules {
|
|
|
614
626
|
|
|
615
627
|
/**
|
|
616
628
|
* Reject `<T extends unknown>` and similar constraints that match everything.
|
|
617
|
-
* Autofixable: drops the constraint
|
|
629
|
+
* Autofixable: drops the constraint while retaining the disambiguating comma
|
|
630
|
+
* required by single-parameter generic arrows in TSX, MTS, and CTS files.
|
|
618
631
|
*
|
|
619
632
|
* @reference https://typescript-eslint.io/rules/no-unnecessary-type-constraint
|
|
620
633
|
*/
|
|
@@ -632,11 +645,14 @@ export interface ITtscLintTypeScriptRules {
|
|
|
632
645
|
"typescript/no-unsafe-argument"?: TtscLintRuleSetting;
|
|
633
646
|
|
|
634
647
|
/**
|
|
635
|
-
* Reject
|
|
636
|
-
*
|
|
637
|
-
*
|
|
648
|
+
* Reject direct and nested `any` values escaping through assignment
|
|
649
|
+
* boundaries. Covers annotated and inferred variables, reassignments,
|
|
650
|
+
* defaults, class members, contextual properties, spreads, and
|
|
651
|
+
* destructuring.
|
|
638
652
|
*
|
|
639
|
-
* Type-aware via the Checker.
|
|
653
|
+
* Type-aware via the Checker. Matching generic references are compared
|
|
654
|
+
* recursively with cycle protection. `any` may flow into `unknown`, including
|
|
655
|
+
* a corresponding nested generic argument. The rule has no options.
|
|
640
656
|
*
|
|
641
657
|
* @reference https://typescript-eslint.io/rules/no-unsafe-assignment
|
|
642
658
|
*/
|
|
@@ -795,7 +811,12 @@ export interface ITtscLintTypeScriptRules {
|
|
|
795
811
|
"typescript/parameter-properties"?: TtscLintRuleSetting;
|
|
796
812
|
|
|
797
813
|
/**
|
|
798
|
-
* Prefer `as const` over `as "literal"
|
|
814
|
+
* Prefer `as const` over literal type assertions (`as "literal"`,
|
|
815
|
+
* `<"literal">`) and matching literal type annotations on variable and
|
|
816
|
+
* class-property declarations. Literals are compared by raw source spelling.
|
|
817
|
+
* Assertions are autofixable. Annotation findings expose an editor quick fix
|
|
818
|
+
* that removes the annotation and appends `as const`; `ttsc fix` never
|
|
819
|
+
* applies that suggestion automatically.
|
|
799
820
|
*
|
|
800
821
|
* @reference https://typescript-eslint.io/rules/prefer-as-const
|
|
801
822
|
*/
|
|
@@ -1117,18 +1138,19 @@ export interface ITtscLintTypeScriptRules {
|
|
|
1117
1138
|
"typescript/strict-boolean-expressions"?: TtscLintRuleSetting;
|
|
1118
1139
|
|
|
1119
1140
|
/**
|
|
1120
|
-
* Require every member of a
|
|
1121
|
-
* explicit `case
|
|
1141
|
+
* Require every enumerable member of a discriminant to be covered by an
|
|
1142
|
+
* explicit `case`.
|
|
1122
1143
|
*
|
|
1123
|
-
* Type-aware via the Checker.
|
|
1124
|
-
*
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1144
|
+
* Type-aware via the Checker. Singleton literals, literal unions, enums,
|
|
1145
|
+
* nullish members, bigint and boolean literals, unique symbols, constrained
|
|
1146
|
+
* generics, and literal pieces of intersections are enumerable. Open
|
|
1147
|
+
* primitive pieces remain unenumerated without hiding adjacent finite
|
|
1148
|
+
* members. Under the default options, a `default` clause does not replace
|
|
1149
|
+
* explicit finite-member coverage.
|
|
1128
1150
|
*
|
|
1129
1151
|
* @reference https://typescript-eslint.io/rules/switch-exhaustiveness-check
|
|
1130
1152
|
*/
|
|
1131
|
-
"typescript/switch-exhaustiveness-check"?:
|
|
1153
|
+
"typescript/switch-exhaustiveness-check"?: TtscLintRuleOptionsSetting<ITtscLintTypeScriptSwitchExhaustivenessCheckRuleOptions>;
|
|
1132
1154
|
|
|
1133
1155
|
/**
|
|
1134
1156
|
* Reject `/// <reference path="..." />`, `/// <reference types="" />`, and
|