@ttsc/lint 0.18.4 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -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 +159 -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 +231 -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 +206 -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,350 @@
|
|
|
1
|
+
/** Case-style keys accepted by `unicorn/filename-case`. */
|
|
2
|
+
export type TtscLintUnicornFilenameCaseName =
|
|
3
|
+
| "camelCase"
|
|
4
|
+
| "camelCaseWithAcronyms"
|
|
5
|
+
| "kebabCase"
|
|
6
|
+
| "snakeCase"
|
|
7
|
+
| "pascalCase";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Options for `unicorn/filename-case`.
|
|
11
|
+
*
|
|
12
|
+
* `case` and `cases` are mutually exclusive: configure either the single
|
|
13
|
+
* enforced style or a map of allowed styles. With neither configured — or with
|
|
14
|
+
* every `cases` entry disabled — the rule enforces kebab-case.
|
|
15
|
+
*
|
|
16
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
|
17
|
+
*/
|
|
18
|
+
export interface ITtscLintUnicornFilenameCaseRuleOptions {
|
|
19
|
+
/** The single filename and directory name case style. @default "kebabCase" */
|
|
20
|
+
case?: TtscLintUnicornFilenameCaseName;
|
|
21
|
+
|
|
22
|
+
/** The allowed filename and directory name case styles. */
|
|
23
|
+
cases?: Partial<Readonly<Record<TtscLintUnicornFilenameCaseName, boolean>>>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Regular-expression strings; a file is exempt when any pattern matches any
|
|
27
|
+
* segment of its project-relative path.
|
|
28
|
+
*/
|
|
29
|
+
ignore?: readonly string[];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Treat additional dot-separated parts of a filename as file extensions,
|
|
33
|
+
* checking only the stem before the first dot.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
multipleFileExtensions?: boolean;
|
|
38
|
+
|
|
39
|
+
/** Check directory names. @default true */
|
|
40
|
+
checkDirectories?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Options for `unicorn/better-regex`.
|
|
45
|
+
*
|
|
46
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-regex.md
|
|
47
|
+
*/
|
|
48
|
+
export interface ITtscLintUnicornBetterRegexRuleOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Sort and merge adjacent character-class ranges (e.g. `[d-ea-c]` ->
|
|
51
|
+
* `[a-e]`). Defaults to `true`; set `false` to keep the source order and only
|
|
52
|
+
* apply the length-reducing shorthands.
|
|
53
|
+
*/
|
|
54
|
+
sortCharacterClasses?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Options for `unicorn/template-indent`.
|
|
59
|
+
*
|
|
60
|
+
* Each selection list replaces the corresponding default list. `indent` is
|
|
61
|
+
* either a positive number of spaces or the exact non-empty whitespace string
|
|
62
|
+
* added after the opening template's source-line margin.
|
|
63
|
+
*
|
|
64
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/template-indent.md
|
|
65
|
+
*/
|
|
66
|
+
export interface ITtscLintUnicornTemplateIndentRuleOptions {
|
|
67
|
+
/** Block-comment contents that select the immediately following template. */
|
|
68
|
+
comments?: readonly string[];
|
|
69
|
+
|
|
70
|
+
/** Function paths whose direct template-literal arguments are checked. */
|
|
71
|
+
functions?: readonly string[];
|
|
72
|
+
|
|
73
|
+
/** Positive space count or exact whitespace unit used inside the template. */
|
|
74
|
+
indent?: number | string;
|
|
75
|
+
|
|
76
|
+
/** AST selectors whose matching template literals are checked. */
|
|
77
|
+
selectors?: readonly string[];
|
|
78
|
+
|
|
79
|
+
/** Identifier or dotted member paths used as checked template tags. */
|
|
80
|
+
tags?: readonly string[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Per-module style policy for `unicorn/import-style`.
|
|
85
|
+
*
|
|
86
|
+
* `false` removes every restriction from the module. An object maps style names
|
|
87
|
+
* (`unassigned`, `default`, `namespace`, `named`) to booleans; with
|
|
88
|
+
* `extendDefaultStyles` the flags merge over the module's built-in entry. A
|
|
89
|
+
* module whose four canonical styles are all explicitly `false` is reported as
|
|
90
|
+
* misconfigured on every reference — use `no-restricted-imports` to ban a
|
|
91
|
+
* module outright.
|
|
92
|
+
*/
|
|
93
|
+
export type TtscLintUnicornImportStyleModuleStyles =
|
|
94
|
+
| false
|
|
95
|
+
| Readonly<Record<string, boolean>>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Options for `unicorn/import-style`.
|
|
99
|
+
*
|
|
100
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/import-style.md
|
|
101
|
+
*/
|
|
102
|
+
export interface ITtscLintUnicornImportStyleRuleOptions {
|
|
103
|
+
/** Check static `import` declarations. @default true */
|
|
104
|
+
checkImport?: boolean;
|
|
105
|
+
|
|
106
|
+
/** Check dynamic `import()` expressions. @default true */
|
|
107
|
+
checkDynamicImport?: boolean;
|
|
108
|
+
|
|
109
|
+
/** Check `export … from` declarations. @default false */
|
|
110
|
+
checkExportFrom?: boolean;
|
|
111
|
+
|
|
112
|
+
/** Check `require(…)` calls. @default true */
|
|
113
|
+
checkRequire?: boolean;
|
|
114
|
+
|
|
115
|
+
/** Merge `styles` into the built-in per-module table. @default true */
|
|
116
|
+
extendDefaultStyles?: boolean;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Allowed import styles per module name. `node:`-prefixed references inherit
|
|
120
|
+
* the bare module name's policy.
|
|
121
|
+
*/
|
|
122
|
+
styles?: Readonly<Record<string, TtscLintUnicornImportStyleModuleStyles>>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Global-variable policy for one `unicorn/isolated-functions` override.
|
|
127
|
+
*
|
|
128
|
+
* `true` / `"writable"` / `"writeable"` permit writes, `false` / `"readonly"`
|
|
129
|
+
* permit reads only, and `"off"` forbids the global entirely inside isolated
|
|
130
|
+
* scopes.
|
|
131
|
+
*/
|
|
132
|
+
export type TtscLintUnicornIsolatedFunctionsGlobalPolicy =
|
|
133
|
+
| boolean
|
|
134
|
+
| "readonly"
|
|
135
|
+
| "writable"
|
|
136
|
+
| "writeable"
|
|
137
|
+
| "off";
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Options for `unicorn/isolated-functions`.
|
|
141
|
+
*
|
|
142
|
+
* Each list replaces the corresponding default. A function is treated as
|
|
143
|
+
* isolated when a call to a name in `functions` receives it as an argument,
|
|
144
|
+
* when it matches one of the `selectors`, or when one of the `comments` markers
|
|
145
|
+
* precedes it; `overrideGlobals` retunes which global names may be read or
|
|
146
|
+
* written inside isolated scopes.
|
|
147
|
+
*
|
|
148
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/isolated-functions.md
|
|
149
|
+
*/
|
|
150
|
+
export interface ITtscLintUnicornIsolatedFunctionsRuleOptions {
|
|
151
|
+
/**
|
|
152
|
+
* Callee names whose call arguments are isolated functions.
|
|
153
|
+
*
|
|
154
|
+
* @default ["makeSynchronous", "workerize"]
|
|
155
|
+
*/
|
|
156
|
+
functions?: readonly string[];
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* AST selectors whose matching functions are isolated.
|
|
160
|
+
*
|
|
161
|
+
* @default [ ]
|
|
162
|
+
*/
|
|
163
|
+
selectors?: readonly string[];
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Comment markers that isolate the function they immediately precede.
|
|
167
|
+
*
|
|
168
|
+
* @default ["@isolated"]
|
|
169
|
+
*/
|
|
170
|
+
comments?: readonly string[];
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Per-name overrides for which globals may be read or written inside isolated
|
|
174
|
+
* scopes.
|
|
175
|
+
*/
|
|
176
|
+
overrideGlobals?: Readonly<
|
|
177
|
+
Record<string, TtscLintUnicornIsolatedFunctionsGlobalPolicy>
|
|
178
|
+
>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Import categories accepted by `unicorn/prevent-abbreviations`. */
|
|
182
|
+
export type TtscLintUnicornPreventAbbreviationsImportMode =
|
|
183
|
+
| boolean
|
|
184
|
+
| "internal";
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Replacement patch for one discouraged name.
|
|
188
|
+
*
|
|
189
|
+
* `false` disables every replacement for the name. An object enables or
|
|
190
|
+
* disables individual replacement spellings.
|
|
191
|
+
*/
|
|
192
|
+
export type TtscLintUnicornPreventAbbreviationsReplacement =
|
|
193
|
+
| false
|
|
194
|
+
| Readonly<Record<string, boolean>>;
|
|
195
|
+
|
|
196
|
+
/** Options for `unicorn/consistent-function-scoping`. */
|
|
197
|
+
export interface ITtscLintUnicornConsistentFunctionScopingRuleOptions {
|
|
198
|
+
/** Also check arrow functions for movable definitions. @default true */
|
|
199
|
+
checkArrowFunctions?: boolean;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Options for `unicorn/prevent-abbreviations`. */
|
|
203
|
+
export interface ITtscLintUnicornPreventAbbreviationsRuleOptions {
|
|
204
|
+
/** Also check property definitions and writes. @default false */
|
|
205
|
+
checkProperties?: boolean;
|
|
206
|
+
|
|
207
|
+
/** Check lexical bindings. @default true */
|
|
208
|
+
checkVariables?: boolean;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Check default and namespace imports from all modules, internal modules, or
|
|
212
|
+
* no modules.
|
|
213
|
+
*
|
|
214
|
+
* @default "internal"
|
|
215
|
+
*/
|
|
216
|
+
checkDefaultAndNamespaceImports?: TtscLintUnicornPreventAbbreviationsImportMode;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Check unaliased named imports from all modules, internal modules, or no
|
|
220
|
+
* modules.
|
|
221
|
+
*
|
|
222
|
+
* @default "internal"
|
|
223
|
+
*/
|
|
224
|
+
checkShorthandImports?: TtscLintUnicornPreventAbbreviationsImportMode;
|
|
225
|
+
|
|
226
|
+
/** Check bindings introduced by shorthand object destructuring. @default false */
|
|
227
|
+
checkShorthandProperties?: boolean;
|
|
228
|
+
|
|
229
|
+
/** Check the physical source filename. @default true */
|
|
230
|
+
checkFilenames?: boolean;
|
|
231
|
+
|
|
232
|
+
/** Merge `replacements` into the canonical default table. @default true */
|
|
233
|
+
extendDefaultReplacements?: boolean;
|
|
234
|
+
|
|
235
|
+
/** Add, remove, or replace discouraged-name mappings. */
|
|
236
|
+
replacements?: Readonly<
|
|
237
|
+
Record<string, TtscLintUnicornPreventAbbreviationsReplacement>
|
|
238
|
+
>;
|
|
239
|
+
|
|
240
|
+
/** Merge `allowList` into the canonical default allow list. @default true */
|
|
241
|
+
extendDefaultAllowList?: boolean;
|
|
242
|
+
|
|
243
|
+
/** Case-sensitive full names to allow or remove from the allow list. */
|
|
244
|
+
allowList?: Readonly<Record<string, boolean>>;
|
|
245
|
+
|
|
246
|
+
/** Regular-expression strings matched against a complete name or basename. */
|
|
247
|
+
ignore?: readonly string[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* One replacement entry for `unicorn/string-content`.
|
|
252
|
+
*
|
|
253
|
+
* The object form of a `patterns` value. A plain string value is shorthand for
|
|
254
|
+
* `{ suggest: value }`.
|
|
255
|
+
*/
|
|
256
|
+
export interface ITtscLintUnicornStringContentPatternOptions {
|
|
257
|
+
/** Replacement text applied to every match of the pattern. */
|
|
258
|
+
suggest: string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Apply the replacement automatically; `false` reports the diagnostic with an
|
|
262
|
+
* opt-in editor suggestion instead.
|
|
263
|
+
*
|
|
264
|
+
* @default true
|
|
265
|
+
*/
|
|
266
|
+
fix?: boolean;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Match the pattern case-sensitively.
|
|
270
|
+
*
|
|
271
|
+
* @default true
|
|
272
|
+
*/
|
|
273
|
+
caseSensitive?: boolean;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Custom diagnostic message; `{{match}}` and `{{suggest}}` placeholders
|
|
277
|
+
* interpolate the pattern source and replacement text.
|
|
278
|
+
*/
|
|
279
|
+
message?: string;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Options for `unicorn/string-content`.
|
|
284
|
+
*
|
|
285
|
+
* The rule has no default patterns: without a configured `patterns` object it
|
|
286
|
+
* reports nothing. Each key is a regular-expression source matched against
|
|
287
|
+
* string-literal values and template-quasi raw text; the FIRST matching pattern
|
|
288
|
+
* per node wins and every occurrence is replaced.
|
|
289
|
+
*
|
|
290
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/string-content.md
|
|
291
|
+
*/
|
|
292
|
+
export interface ITtscLintUnicornStringContentRuleOptions {
|
|
293
|
+
/** Regular-expression sources mapped to replacement text or an entry object. */
|
|
294
|
+
patterns?: Readonly<
|
|
295
|
+
Record<string, string | ITtscLintUnicornStringContentPatternOptions>
|
|
296
|
+
>;
|
|
297
|
+
|
|
298
|
+
/** AST selectors that replace the default Literal/TemplateElement targets. */
|
|
299
|
+
selectors?: readonly string[];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Explicit target runtimes for `unicorn/no-unnecessary-polyfills`.
|
|
304
|
+
*
|
|
305
|
+
* A Browserslist query string, an array of such queries, or a core-js-compat
|
|
306
|
+
* targets object (engine name to a version string or number, plus the special
|
|
307
|
+
* `browsers` / `esmodules` keys). Resolved with the `production` environment
|
|
308
|
+
* against the linted file's directory, exactly as upstream passes the value to
|
|
309
|
+
* core-js-compat.
|
|
310
|
+
*/
|
|
311
|
+
export type TtscLintUnicornNoUnnecessaryPolyfillsTargets =
|
|
312
|
+
| string
|
|
313
|
+
| readonly string[]
|
|
314
|
+
| Readonly<Record<string, string | number | boolean | readonly string[]>>;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Options for `unicorn/no-unnecessary-polyfills`.
|
|
318
|
+
*
|
|
319
|
+
* Without this option the rule resolves targets from Browserslist config
|
|
320
|
+
* discovery and, as a last resort, the nearest `package.json` `engines` field.
|
|
321
|
+
* Set `targets` to pin the baseline explicitly; it mirrors upstream's required
|
|
322
|
+
* `targets` schema property.
|
|
323
|
+
*
|
|
324
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-polyfills.md
|
|
325
|
+
*/
|
|
326
|
+
export interface ITtscLintUnicornNoUnnecessaryPolyfillsRuleOptions {
|
|
327
|
+
/** Browserslist query, array of queries, or a core-js-compat targets object. */
|
|
328
|
+
targets: TtscLintUnicornNoUnnecessaryPolyfillsTargets;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Options for `unicorn/no-typeof-undefined`. */
|
|
332
|
+
export interface ITtscLintUnicornNoTypeofUndefinedRuleOptions {
|
|
333
|
+
/** Also report undeclared global identifiers. @default false */
|
|
334
|
+
checkGlobalVariables?: boolean;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Options for `unicorn/prefer-number-properties`. */
|
|
338
|
+
export interface ITtscLintUnicornPreferNumberPropertiesRuleOptions {
|
|
339
|
+
/** Also replace the global `Infinity` binding. @default false */
|
|
340
|
+
checkInfinity?: boolean;
|
|
341
|
+
|
|
342
|
+
/** Also replace the global `NaN` binding. @default false */
|
|
343
|
+
checkNaN?: boolean;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Options for `unicorn/text-encoding-identifier-case`. */
|
|
347
|
+
export interface ITtscLintUnicornTextEncodingIdentifierCaseRuleOptions {
|
|
348
|
+
/** Prefer `utf-8` instead of `utf8` outside dash-required APIs. @default false */
|
|
349
|
+
withDash?: boolean;
|
|
350
|
+
}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
TtscLintRuleOptionsSetting,
|
|
3
|
+
TtscLintRuleSetting,
|
|
4
|
+
} from "../TtscLintRuleSetting";
|
|
5
|
+
import type {
|
|
6
|
+
ITtscLintUnicornBetterRegexRuleOptions,
|
|
7
|
+
ITtscLintUnicornConsistentFunctionScopingRuleOptions,
|
|
8
|
+
ITtscLintUnicornFilenameCaseRuleOptions,
|
|
9
|
+
ITtscLintUnicornImportStyleRuleOptions,
|
|
10
|
+
ITtscLintUnicornIsolatedFunctionsRuleOptions,
|
|
11
|
+
ITtscLintUnicornNoTypeofUndefinedRuleOptions,
|
|
12
|
+
ITtscLintUnicornNoUnnecessaryPolyfillsRuleOptions,
|
|
13
|
+
ITtscLintUnicornPreferNumberPropertiesRuleOptions,
|
|
14
|
+
ITtscLintUnicornPreventAbbreviationsRuleOptions,
|
|
15
|
+
ITtscLintUnicornStringContentRuleOptions,
|
|
16
|
+
ITtscLintUnicornTemplateIndentRuleOptions,
|
|
17
|
+
ITtscLintUnicornTextEncodingIdentifierCaseRuleOptions,
|
|
18
|
+
} from "./ITtscLintUnicornRuleOptions";
|
|
2
19
|
|
|
3
20
|
/**
|
|
4
21
|
* Modernization and style rules from `eslint-plugin-unicorn`.
|
|
@@ -8,7 +25,8 @@ import type { TtscLintRuleSetting } from "../TtscLintRuleSetting";
|
|
|
8
25
|
* counterparts, forbid known anti-patterns, and pin a consistent style for
|
|
9
26
|
* things ESLint core and `typescript/*` leave underspecified.
|
|
10
27
|
*
|
|
11
|
-
*
|
|
28
|
+
* Most rules are pure AST checks. Binding-aware rules use the TypeScript
|
|
29
|
+
* checker when lexical identity is part of the upstream contract.
|
|
12
30
|
*
|
|
13
31
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn
|
|
14
32
|
*/
|
|
@@ -19,7 +37,7 @@ export interface ITtscLintUnicornRules {
|
|
|
19
37
|
*
|
|
20
38
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-regex.md
|
|
21
39
|
*/
|
|
22
|
-
"unicorn/better-regex"?:
|
|
40
|
+
"unicorn/better-regex"?: TtscLintRuleOptionsSetting<ITtscLintUnicornBetterRegexRuleOptions>;
|
|
23
41
|
|
|
24
42
|
/**
|
|
25
43
|
* Enforce a canonical parameter name (`error`) in `catch` clauses.
|
|
@@ -60,8 +78,9 @@ export interface ITtscLintUnicornRules {
|
|
|
60
78
|
"unicorn/consistent-empty-array-spread"?: TtscLintRuleSetting;
|
|
61
79
|
|
|
62
80
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
81
|
+
* Compare a `const` bound to `indexOf` / `lastIndexOf` / `findIndex` /
|
|
82
|
+
* `findLastIndex` against the `-1` sentinel (`=== -1` / `!== -1`) rather than
|
|
83
|
+
* against zero (`< 0`, `>= 0`, `> -1`).
|
|
65
84
|
*
|
|
66
85
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/consistent-existence-index-check.md
|
|
67
86
|
*/
|
|
@@ -73,11 +92,11 @@ export interface ITtscLintUnicornRules {
|
|
|
73
92
|
*
|
|
74
93
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/consistent-function-scoping.md
|
|
75
94
|
*/
|
|
76
|
-
"unicorn/consistent-function-scoping"?:
|
|
95
|
+
"unicorn/consistent-function-scoping"?: TtscLintRuleOptionsSetting<ITtscLintUnicornConsistentFunctionScopingRuleOptions>;
|
|
77
96
|
|
|
78
97
|
/**
|
|
79
|
-
* Enforce
|
|
80
|
-
*
|
|
98
|
+
* Enforce the `\${` spelling over `$\{` when escaping `${` in template
|
|
99
|
+
* literals.
|
|
81
100
|
*
|
|
82
101
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/consistent-template-literal-escape.md
|
|
83
102
|
*/
|
|
@@ -132,11 +151,11 @@ export interface ITtscLintUnicornRules {
|
|
|
132
151
|
|
|
133
152
|
/**
|
|
134
153
|
* Enforce a single case style (kebab / camel / snake / pascal) for source
|
|
135
|
-
* filenames.
|
|
154
|
+
* filenames and directory names.
|
|
136
155
|
*
|
|
137
156
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
|
138
157
|
*/
|
|
139
|
-
"unicorn/filename-case"?:
|
|
158
|
+
"unicorn/filename-case"?: TtscLintRuleOptionsSetting<ITtscLintUnicornFilenameCaseRuleOptions>;
|
|
140
159
|
|
|
141
160
|
/**
|
|
142
161
|
* Restrict each module's allowed import styles (named only, default only,
|
|
@@ -144,15 +163,16 @@ export interface ITtscLintUnicornRules {
|
|
|
144
163
|
*
|
|
145
164
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/import-style.md
|
|
146
165
|
*/
|
|
147
|
-
"unicorn/import-style"?:
|
|
166
|
+
"unicorn/import-style"?: TtscLintRuleOptionsSetting<ITtscLintUnicornImportStyleRuleOptions>;
|
|
148
167
|
|
|
149
168
|
/**
|
|
150
|
-
* Reject references to outer-scope variables
|
|
151
|
-
*
|
|
169
|
+
* Reject references to outer-scope variables (and `this` / `super`) inside
|
|
170
|
+
* functions that run outside their defining context (e.g., the body of a web
|
|
171
|
+
* worker or a `page.evaluate` payload).
|
|
152
172
|
*
|
|
153
173
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/isolated-functions.md
|
|
154
174
|
*/
|
|
155
|
-
"unicorn/isolated-functions"?:
|
|
175
|
+
"unicorn/isolated-functions"?: TtscLintRuleOptionsSetting<ITtscLintUnicornIsolatedFunctionsRuleOptions>;
|
|
156
176
|
|
|
157
177
|
/**
|
|
158
178
|
* Require `new` when calling builtin constructors like `Error`, `Map`, `Set`,
|
|
@@ -443,7 +463,7 @@ export interface ITtscLintUnicornRules {
|
|
|
443
463
|
*
|
|
444
464
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-typeof-undefined.md
|
|
445
465
|
*/
|
|
446
|
-
"unicorn/no-typeof-undefined"?:
|
|
466
|
+
"unicorn/no-typeof-undefined"?: TtscLintRuleOptionsSetting<ITtscLintUnicornNoTypeofUndefinedRuleOptions>;
|
|
447
467
|
|
|
448
468
|
/**
|
|
449
469
|
* Reject `1` as the explicit depth argument of `Array#flat`; the default is
|
|
@@ -474,7 +494,7 @@ export interface ITtscLintUnicornRules {
|
|
|
474
494
|
*
|
|
475
495
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-polyfills.md
|
|
476
496
|
*/
|
|
477
|
-
"unicorn/no-unnecessary-polyfills"?:
|
|
497
|
+
"unicorn/no-unnecessary-polyfills"?: TtscLintRuleOptionsSetting<ITtscLintUnicornNoUnnecessaryPolyfillsRuleOptions>;
|
|
478
498
|
|
|
479
499
|
/**
|
|
480
500
|
* Reject `.length` / `Infinity` as the end argument to `slice`; omit it to
|
|
@@ -587,8 +607,8 @@ export interface ITtscLintUnicornRules {
|
|
|
587
607
|
"unicorn/no-zero-fractions"?: TtscLintRuleSetting;
|
|
588
608
|
|
|
589
609
|
/**
|
|
590
|
-
* Enforce one consistent case for
|
|
591
|
-
*
|
|
610
|
+
* Enforce one consistent case for a numeric literal's radix prefix, hex
|
|
611
|
+
* digits, and exponent (`0xFF` over `0xff`, `1e10` over `1E10`).
|
|
592
612
|
*
|
|
593
613
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/number-literal-case.md
|
|
594
614
|
*/
|
|
@@ -868,7 +888,7 @@ export interface ITtscLintUnicornRules {
|
|
|
868
888
|
*
|
|
869
889
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-number-properties.md
|
|
870
890
|
*/
|
|
871
|
-
"unicorn/prefer-number-properties"?:
|
|
891
|
+
"unicorn/prefer-number-properties"?: TtscLintRuleOptionsSetting<ITtscLintUnicornPreferNumberPropertiesRuleOptions>;
|
|
872
892
|
|
|
873
893
|
/**
|
|
874
894
|
* Prefer `Object.fromEntries` over `reduce`-into-object patterns.
|
|
@@ -940,8 +960,8 @@ export interface ITtscLintUnicornRules {
|
|
|
940
960
|
"unicorn/prefer-set-size"?: TtscLintRuleSetting;
|
|
941
961
|
|
|
942
962
|
/**
|
|
943
|
-
*
|
|
944
|
-
*
|
|
963
|
+
* Place identifier and strict-comparison gates before complex conditions in
|
|
964
|
+
* boolean `&&` / `||` chains, preserving short-circuit evaluation safety.
|
|
945
965
|
*
|
|
946
966
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-simple-condition-first.md
|
|
947
967
|
*/
|
|
@@ -1042,12 +1062,14 @@ export interface ITtscLintUnicornRules {
|
|
|
1042
1062
|
"unicorn/prefer-type-error"?: TtscLintRuleSetting;
|
|
1043
1063
|
|
|
1044
1064
|
/**
|
|
1045
|
-
*
|
|
1046
|
-
*
|
|
1065
|
+
* Replace discouraged words in bindings, compound names, properties, and
|
|
1066
|
+
* filenames according to the canonical replacement table. The legacy rule ID
|
|
1067
|
+
* retains the final upstream behavior from before its June 2026 rename to
|
|
1068
|
+
* `name-replacements`.
|
|
1047
1069
|
*
|
|
1048
|
-
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/
|
|
1070
|
+
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/42abe74908e8/docs/rules/prevent-abbreviations.md
|
|
1049
1071
|
*/
|
|
1050
|
-
"unicorn/prevent-abbreviations"?:
|
|
1072
|
+
"unicorn/prevent-abbreviations"?: TtscLintRuleOptionsSetting<ITtscLintUnicornPreventAbbreviationsRuleOptions>;
|
|
1051
1073
|
|
|
1052
1074
|
/**
|
|
1053
1075
|
* Enforce a single style (always leading `./` vs. never) for relative URLs
|
|
@@ -1095,12 +1117,13 @@ export interface ITtscLintUnicornRules {
|
|
|
1095
1117
|
"unicorn/require-post-message-target-origin"?: TtscLintRuleSetting;
|
|
1096
1118
|
|
|
1097
1119
|
/**
|
|
1098
|
-
*
|
|
1099
|
-
* for straight ones).
|
|
1120
|
+
* Rewrite configured `patterns` inside string literals and template quasis
|
|
1121
|
+
* (e.g., curly quotes for straight ones). No default patterns: a bare
|
|
1122
|
+
* severity reports nothing.
|
|
1100
1123
|
*
|
|
1101
1124
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/string-content.md
|
|
1102
1125
|
*/
|
|
1103
|
-
"unicorn/string-content"?:
|
|
1126
|
+
"unicorn/string-content"?: TtscLintRuleOptionsSetting<ITtscLintUnicornStringContentRuleOptions>;
|
|
1104
1127
|
|
|
1105
1128
|
/**
|
|
1106
1129
|
* Enforce a consistent presence/absence of `{}` braces around `case` clauses
|
|
@@ -1111,28 +1134,29 @@ export interface ITtscLintUnicornRules {
|
|
|
1111
1134
|
"unicorn/switch-case-braces"?: TtscLintRuleSetting;
|
|
1112
1135
|
|
|
1113
1136
|
/**
|
|
1114
|
-
*
|
|
1115
|
-
* `case`
|
|
1137
|
+
* Require a terminating `break`, `continue`, `return`, or `throw` to sit
|
|
1138
|
+
* inside a `case` clause's sole block instead of immediately after it.
|
|
1116
1139
|
*
|
|
1117
1140
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/switch-case-break-position.md
|
|
1118
1141
|
*/
|
|
1119
1142
|
"unicorn/switch-case-break-position"?: TtscLintRuleSetting;
|
|
1120
1143
|
|
|
1121
1144
|
/**
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1145
|
+
* Normalize selected multiline template bodies while preserving substitutions
|
|
1146
|
+
* and raw escape spelling.
|
|
1124
1147
|
*
|
|
1125
1148
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/template-indent.md
|
|
1126
1149
|
*/
|
|
1127
|
-
"unicorn/template-indent"?:
|
|
1150
|
+
"unicorn/template-indent"?: TtscLintRuleOptionsSetting<ITtscLintUnicornTemplateIndentRuleOptions>;
|
|
1128
1151
|
|
|
1129
1152
|
/**
|
|
1130
|
-
* Enforce
|
|
1131
|
-
* `"
|
|
1153
|
+
* Enforce canonical text-encoding identifiers: dash-less `"utf8"` by default,
|
|
1154
|
+
* dashed `"utf-8"` for APIs that require it or when `withDash` is enabled,
|
|
1155
|
+
* and lowercase `"ascii"`.
|
|
1132
1156
|
*
|
|
1133
1157
|
* @reference https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/text-encoding-identifier-case.md
|
|
1134
1158
|
*/
|
|
1135
|
-
"unicorn/text-encoding-identifier-case"?:
|
|
1159
|
+
"unicorn/text-encoding-identifier-case"?: TtscLintRuleOptionsSetting<ITtscLintUnicornTextEncodingIdentifierCaseRuleOptions>;
|
|
1136
1160
|
|
|
1137
1161
|
/**
|
|
1138
1162
|
* Require `throw new Error(...)` over `throw Error(...)`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./ITtscLintBoundariesRuleOptions";
|
|
2
2
|
export * from "./ITtscLintBoundariesRules";
|
|
3
3
|
export * from "./ITtscLintContributorRules";
|
|
4
|
+
export * from "./ITtscLintCoreRuleOptions";
|
|
4
5
|
export * from "./ITtscLintCoreRules";
|
|
5
6
|
export * from "./ITtscLintCypressRuleOptions";
|
|
6
7
|
export * from "./ITtscLintCypressRules";
|
|
@@ -26,6 +27,8 @@ export * from "./ITtscLintStorybookRules";
|
|
|
26
27
|
export * from "./ITtscLintTanstackQueryRules";
|
|
27
28
|
export * from "./ITtscLintTestingLibraryRuleOptions";
|
|
28
29
|
export * from "./ITtscLintTestingLibraryRules";
|
|
30
|
+
export * from "./ITtscLintTypeScriptRuleOptions";
|
|
29
31
|
export * from "./ITtscLintTypeScriptRules";
|
|
32
|
+
export * from "./ITtscLintUnicornRuleOptions";
|
|
30
33
|
export * from "./ITtscLintUnicornRules";
|
|
31
34
|
export * from "./ITtscLintVitestRules";
|