@inthedark/dxlint 0.1.2 → 0.1.3
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/bin/dxlint-linux-x64 +0 -0
- package/bin/dxlint-win32-x64.exe +0 -0
- package/package.json +2 -2
- package/std/core/lines.dx +3 -3
- package/std/ts/expressions.dx +1 -1
- package/std/ts/format.dx +8 -8
- package/std/ts/indentation.dx +59 -59
- package/std/ts/jsx.dx +9 -9
- package/std/ts/layout/blocks.dx +5 -5
- package/std/ts/layout/calls.dx +8 -8
- package/std/ts/layout/expressions.dx +3 -3
- package/std/ts/layout/literals.dx +2 -2
- package/std/ts/layout/separators.dx +4 -4
- package/std/ts/layout/text.dx +1 -1
- package/std/ts/license.dx +5 -5
- package/std/ts/parentheses.dx +1 -1
- package/std/ts/problems/expressions.dx +2 -2
- package/std/ts/restrictions/comments.dx +1 -1
- package/std/ts/restrictions.dx +11 -11
- package/std/ts/scoping.dx +7 -7
- package/std/ts/structure.dx +9 -9
- package/std/ts/style/classes.dx +2 -2
- package/std/ts/style/declarations.dx +1 -1
- package/std/ts/style/signatures.dx +2 -2
- package/std/ts/style/types.dx +6 -6
- package/std/ts/suggestions/accessors.dx +1 -1
- package/std/ts/suggestions/builtins.dx +1 -1
- package/std/ts/suggestions/comparisons.dx +1 -1
- package/std/ts/suggestions/curly.dx +1 -1
- package/std/ts/suggestions/directives.dx +1 -1
- package/std/ts/suggestions/expressions.dx +1 -1
- package/std/ts/suggestions/functions.dx +3 -3
- package/std/ts/suggestions/object-shorthand.dx +2 -2
- package/std/ts/typed/return-await.dx +1 -1
- package/std/whitespace.dx +2 -2
package/bin/dxlint-linux-x64
CHANGED
|
Binary file
|
package/bin/dxlint-win32-x64.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inthedark/dxlint",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "let you and your agents own your linter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/std/core/lines.dx
CHANGED
|
@@ -14,14 +14,14 @@ define {
|
|
|
14
14
|
|
|
15
15
|
in .* layer lines match core_file_tail /[^\n]\z/
|
|
16
16
|
in core_file_tail rule shared-eol-last warn "Newline required at end of file but not found." {
|
|
17
|
-
option mode "always" | "never" = "always" "whether files end in a newline"
|
|
17
|
+
default option mode "always" | "never" = "always" "whether files end in a newline"
|
|
18
18
|
when mode == "always"
|
|
19
19
|
report at end_offset
|
|
20
20
|
fix as text "\n"
|
|
21
21
|
}
|
|
22
22
|
in .* layer lines match core_final_newlines /(?:\r?\n)+\z/
|
|
23
23
|
in core_final_newlines rule shared-eol-last:never warn "Newline not allowed at end of file." {
|
|
24
|
-
option mode "always" | "never" = "always" "whether files end in a newline"
|
|
24
|
+
default option mode "always" | "never" = "always" "whether files end in a newline"
|
|
25
25
|
when mode == "never"
|
|
26
26
|
report at { start: end_offset - (if ends_with(text, "\r\n") then 2 else 1), end: end_offset }
|
|
27
27
|
fix as ""
|
|
@@ -43,7 +43,7 @@ define {
|
|
|
43
43
|
|
|
44
44
|
in core_line match core_line_break /\r\n|[\n\r\u{2028}\u{2029}]/
|
|
45
45
|
in core_line_break rule shared-linebreak-style {
|
|
46
|
-
option mode "unix" | "windows" = "unix"
|
|
46
|
+
default option mode "unix" | "windows" = "unix"
|
|
47
47
|
when mode == "unix" && text != "\n" || mode == "windows" && text != "\r\n"
|
|
48
48
|
fix as if mode == "unix" then "\n" else "\r\n"
|
|
49
49
|
warn if mode == "unix" then "Expected linebreaks to be 'LF' but found 'CRLF'." else "Expected linebreaks to be 'CRLF' but found 'LF'."
|
package/std/ts/expressions.dx
CHANGED
|
@@ -256,7 +256,7 @@ fn logical_assignment_fix(source, n, info) = if !expression_fix_clean(n) then nu
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
in ts_assignment, ts_logical, ts_if rule es-logical-assignment-operators {
|
|
259
|
-
option mode ("always" | "never") = "always" "logical assignment policy"
|
|
259
|
+
default option mode ("always" | "never") = "always" "logical assignment policy"
|
|
260
260
|
option enforceForIfStatements boolean = false "include conditional assignments"
|
|
261
261
|
when not ts_if || enforceForIfStatements
|
|
262
262
|
let logical_info logical_assignment_info(node)
|
package/std/ts/format.dx
CHANGED
|
@@ -110,7 +110,7 @@ in ts_variable_declaration.kind rule es-no-var warn "Unexpected var, use let or
|
|
|
110
110
|
# ---- spacing ---------------------------------------------------------------
|
|
111
111
|
|
|
112
112
|
in ts_open_paren rule es-space-in-parens:after {
|
|
113
|
-
option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
113
|
+
default option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
114
114
|
option exceptions ("{}" | "[]" | "()" | "empty")[] = [] "invert spacing for nested delimiters"
|
|
115
115
|
let paren_edge token(node, "after")
|
|
116
116
|
when mode != "never" || count(exceptions) > 0 || paren_edge.start != end_offset
|
|
@@ -132,7 +132,7 @@ in ts_open_paren rule es-space-in-parens:after {
|
|
|
132
132
|
warn if paren_space != "" then "There should be no space after this paren." else "There must be a space after this paren."
|
|
133
133
|
}
|
|
134
134
|
in ts_close_paren rule es-space-in-parens:before {
|
|
135
|
-
option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
135
|
+
default option mode "always" | "never" = "never" "spacing inside parentheses"
|
|
136
136
|
option exceptions ("{}" | "[]" | "()" | "empty")[] = [] "invert spacing for nested delimiters"
|
|
137
137
|
let paren_edge token(node, "before")
|
|
138
138
|
when mode != "never" || count(exceptions) > 0 || paren_edge.end != offset
|
|
@@ -161,7 +161,7 @@ fn format_gap_text(gap, spaced, comments) = (if spaced then " " else "") {
|
|
|
161
161
|
join ""
|
|
162
162
|
}
|
|
163
163
|
in ts_array, ts_array_pattern rule es-array-bracket-spacing {
|
|
164
|
-
option style "always" | "never" = "never" "spacing inside array brackets"
|
|
164
|
+
default option style "always" | "never" = "never" "spacing inside array brackets"
|
|
165
165
|
option singleValue boolean | null = null "override spacing around a single element"
|
|
166
166
|
option objectsInArrays boolean | null = null "override spacing beside object elements"
|
|
167
167
|
option arraysInArrays boolean | null = null "override spacing beside nested arrays"
|
|
@@ -195,7 +195,7 @@ in ts_array, ts_array_pattern rule es-array-bracket-spacing {
|
|
|
195
195
|
}
|
|
196
196
|
in ts_dot, ts_punctuator, ts_member.optional rule es-dot-location {
|
|
197
197
|
@ts_token_context
|
|
198
|
-
option style "object" | "property" = "property" "line for a member-access dot"
|
|
198
|
+
default option style "object" | "property" = "property" "line for a member-access dot"
|
|
199
199
|
when text == "." || text == "?."
|
|
200
200
|
when parent is (ts_member, ts_qualified_name, ts_import_type, ts_meta_property, ts_jsx_name)
|
|
201
201
|
when if style == "object" then position(offset).js_line != position(token(node, "before").end).js_line
|
|
@@ -210,7 +210,7 @@ in ts_dot, ts_punctuator, ts_member.optional rule es-dot-location {
|
|
|
210
210
|
|
|
211
211
|
@macro format_template_curly {
|
|
212
212
|
@ts_token_context
|
|
213
|
-
option mode "always" | "never" = "never" "spacing inside template substitutions"
|
|
213
|
+
default option mode "always" | "never" = "never" "spacing inside template substitutions"
|
|
214
214
|
let template_before { value space_before.text; re_find /\s*$/; nonempty } ?? ""
|
|
215
215
|
let template_after { value space_after.text; re_find /^\s*/; nonempty } ?? ""
|
|
216
216
|
}
|
|
@@ -240,7 +240,7 @@ in ts_template.quasi rule es-template-curly-spacing:missing-before warn "Expecte
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
@macro format_template_tag {
|
|
243
|
-
option style "always" | "never" = "never" "spacing after a template tag"
|
|
243
|
+
default option style "always" | "never" = "never" "spacing after a template tag"
|
|
244
244
|
let tag_gap ts_token_space(source, quasi.node, true)
|
|
245
245
|
let tag_comments { value overlapping(ts_comment); filter (comment) comment.offset >= tag_gap.start && comment.end_offset <= tag_gap.end }
|
|
246
246
|
let tag_line_comment any(tag_comments, comment => comment is ts_line_comment)
|
|
@@ -317,7 +317,7 @@ in ts_arrow.operator, ts_punctuator rule es-arrow-spacing:unexpected-after warn
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
@macro format_arrow_parens {
|
|
320
|
-
option style "always" | "as-needed" = "always" "parentheses around one arrow parameter"
|
|
320
|
+
default option style "always" | "as-needed" = "always" "parentheses around one arrow parameter"
|
|
321
321
|
option requireForBlockBody boolean = false "keep parentheses with a block body"
|
|
322
322
|
}
|
|
323
323
|
in ts_parameter let format_arrow_plain name is ts_identifier && optional == null && type == null && init == null && count(modifier) == 0 && count(decorator) == 0
|
|
@@ -376,7 +376,7 @@ in ts_assignment_pattern let format_curly_tail right.format_curly_tail.nonempty
|
|
|
376
376
|
in ts_as, ts_satisfies let format_curly_tail type.format_curly_tail.nonempty ?? type.node
|
|
377
377
|
in ts_mapped_type let format_object_tail type.format_curly_tail.nonempty ?? type.node
|
|
378
378
|
@macro format_object_curly_options {
|
|
379
|
-
option style "always" | "never" = "never" "spaces inside object-like braces"
|
|
379
|
+
default option style "always" | "never" = "never" "spaces inside object-like braces"
|
|
380
380
|
option arraysInObjects boolean | null = null "override spacing beside array values and index signatures"
|
|
381
381
|
option objectsInObjects boolean | null = null "override spacing beside object values"
|
|
382
382
|
option overrides { [node: string]: "always" | "never" } = {} "spacing by syntax kind"
|
package/std/ts/indentation.dx
CHANGED
|
@@ -242,95 +242,95 @@ in ts_variable_declaration let indent_declaration_offset null
|
|
|
242
242
|
|
|
243
243
|
in ts_line rule es-indent {
|
|
244
244
|
indent reset indent_reset
|
|
245
|
-
option mode int(0..) | "tab" = 4 "spaces per level, or tab"
|
|
246
|
-
option
|
|
247
|
-
option
|
|
248
|
-
option
|
|
249
|
-
option
|
|
250
|
-
option
|
|
251
|
-
option
|
|
252
|
-
option
|
|
253
|
-
option
|
|
254
|
-
option
|
|
255
|
-
option
|
|
256
|
-
option
|
|
257
|
-
option
|
|
258
|
-
option
|
|
259
|
-
option
|
|
260
|
-
option
|
|
261
|
-
option
|
|
262
|
-
option
|
|
263
|
-
option
|
|
264
|
-
option
|
|
265
|
-
option
|
|
245
|
+
default option mode int(0..) | "tab" = 4 "spaces per level, or tab"
|
|
246
|
+
option tabLength number(1..) = 4 "spaces per raw-template tab in tab mode"
|
|
247
|
+
option switchCase int(0..) = 1
|
|
248
|
+
option variableDeclarator indent_list_offset = 1
|
|
249
|
+
option variableDeclaratorVar indent_list_offset | null = null
|
|
250
|
+
option variableDeclaratorLet indent_list_offset | null = null
|
|
251
|
+
option variableDeclaratorConst indent_list_offset | null = null
|
|
252
|
+
option variableDeclaratorUsing indent_list_offset | null = null
|
|
253
|
+
option memberExpression int(0..) = 1
|
|
254
|
+
option functionDeclarationParameters indent_list_offset = 1
|
|
255
|
+
option functionDeclarationBody int(0..) = 1
|
|
256
|
+
option functionDeclarationReturnType int(0..) = 1
|
|
257
|
+
option functionExpressionParameters indent_list_offset = 1
|
|
258
|
+
option functionExpressionBody int(0..) = 1
|
|
259
|
+
option functionExpressionReturnType int(0..) = 1
|
|
260
|
+
option staticBlock int(0..) = 1
|
|
261
|
+
option callExpression indent_list_offset = 1
|
|
262
|
+
option arrayExpression indent_list_offset = 1
|
|
263
|
+
option objectExpression indent_list_offset = 1
|
|
264
|
+
option importDeclaration indent_list_offset = 1
|
|
265
|
+
option assignmentOperator int(0..) = 1
|
|
266
266
|
option outerIIFEBody int(0..) = 1
|
|
267
|
-
option
|
|
268
|
-
option
|
|
267
|
+
option flatTernaryExpressions boolean = false
|
|
268
|
+
option offsetTernaryExpressions boolean = false "extra depth for grouped ternary branches"
|
|
269
269
|
|
|
270
270
|
indent in ts_block, ts_interface, ts_namespace.body
|
|
271
271
|
indent in ts_class from indent_class_head
|
|
272
272
|
indent ts_class.token from if is (ts_open_brace, ts_close_brace) then parent.indent_class_head else if contains(["class", "abstract", "declare"], text) then parent.offset else offset by 0
|
|
273
273
|
indent ts_enum.token from if is ts_open_brace then parent.offset else offset by 0
|
|
274
274
|
indent indent_generic_arguments.token, indent_generic_parameters.token from if offset == parent.indent_angle_close then parent.indent_angle_open else offset by 0
|
|
275
|
-
indent in ts_array, ts_array_pattern, ts_tuple_type by indent_numeric(
|
|
276
|
-
indent in ts_object, ts_object_pattern, ts_enum, ts_type_literal by indent_numeric(
|
|
275
|
+
indent in ts_array, ts_array_pattern, ts_tuple_type by indent_numeric(arrayExpression)
|
|
276
|
+
indent in ts_object, ts_object_pattern, ts_enum, ts_type_literal by indent_numeric(objectExpression)
|
|
277
277
|
indent in ts_parenthesized, ts_parenthesized_type, ts_computed_key, ts_mapped_type
|
|
278
|
-
indent ts_template.expression from indent_template_code_anchor(parent.node, index, mode,
|
|
279
|
-
indent ts_template.quasi from if index == 0 then offset else indent_template_code_anchor(parent.node, index - 1, mode,
|
|
278
|
+
indent ts_template.expression from indent_template_code_anchor(parent.node, index, mode, tabLength, false) by if { value parent.node; indent_template_parts index; indent_template_relative } then 1 else 0
|
|
279
|
+
indent ts_template.quasi from if index == 0 then offset else indent_template_code_anchor(parent.node, index - 1, mode, tabLength, true) by 0
|
|
280
280
|
indent in ts_index from indent_index_open
|
|
281
|
-
indent ts_index.token from if text == "]" then parent.indent_index_open else if text == "?." then parent.offset else parent.optional.offset.nonempty ?? parent.offset by if text == "]" then 0 else indent_numeric(
|
|
282
|
-
indent in indent_calls from indent_call_anchor by { value indent_arguments_offset.nonempty ??
|
|
281
|
+
indent ts_index.token from if text == "]" then parent.indent_index_open else if text == "?." then parent.offset else parent.optional.offset.nonempty ?? parent.offset by if text == "]" then 0 else indent_numeric(memberExpression)
|
|
282
|
+
indent in indent_calls from indent_call_anchor by { value indent_arguments_offset.nonempty ?? callExpression; indent_numeric }
|
|
283
283
|
indent indent_calls.token from if text == "?." then indent_optional_call_anchor(parent) else if is (ts_open_paren, ts_close_paren) then parent.indent_call_anchor else offset by if text == "?." then 1 else 0
|
|
284
|
-
indent in ts_function.body, ts_arrow.body, ts_method.body from indent_function_anchor(parent.indent_body_root) by if parent.indent_outer_iife then parent.indent_body_offset.nonempty ?? indent_numeric(outerIIFEBody) else indent_function_offset(parent, parent.indent_body_offset,
|
|
285
|
-
indent in ts_static_block.body by parent.indent_body_offset.nonempty ??
|
|
284
|
+
indent in ts_function.body, ts_arrow.body, ts_method.body from indent_function_anchor(parent.indent_body_root) by if parent.indent_outer_iife then parent.indent_body_offset.nonempty ?? indent_numeric(outerIIFEBody) else indent_function_offset(parent, parent.indent_body_offset, functionDeclarationBody, functionExpressionBody)
|
|
285
|
+
indent in ts_static_block.body by parent.indent_body_offset.nonempty ?? staticBlock
|
|
286
286
|
indent ts_function.parameter, ts_arrow.parameter, ts_method.parameter by {
|
|
287
287
|
value parent
|
|
288
|
-
indent_function_offset parent.indent_parameters_offset
|
|
288
|
+
indent_function_offset parent.indent_parameters_offset functionDeclarationParameters functionExpressionParameters
|
|
289
289
|
indent_numeric
|
|
290
290
|
}
|
|
291
|
-
indent ts_function.return_type from parent.indent_return_anchor by indent_function_offset(parent, parent.indent_return_type_offset,
|
|
292
|
-
indent ts_function.token from if is ts_close_paren then indent_function_anchor(parent.indent_body_root) else if offset == parent.indent_return_colon then parent.indent_return_anchor else offset by if is ts_close_paren then 0 else indent_function_offset(parent, parent.indent_return_type_offset,
|
|
291
|
+
indent ts_function.return_type from parent.indent_return_anchor by indent_function_offset(parent, parent.indent_return_type_offset, functionDeclarationReturnType, functionExpressionReturnType)
|
|
292
|
+
indent ts_function.token from if is ts_close_paren then indent_function_anchor(parent.indent_body_root) else if offset == parent.indent_return_colon then parent.indent_return_anchor else offset by if is ts_close_paren then 0 else indent_function_offset(parent, parent.indent_return_type_offset, functionDeclarationReturnType, functionExpressionReturnType)
|
|
293
293
|
indent ts_arrow.token, ts_method.token from if is ts_close_paren then indent_function_anchor(parent.indent_body_root) else offset by 0
|
|
294
294
|
indent ts_arrow.return_type, ts_parameter.type
|
|
295
|
-
indent ts_call.argument, ts_new.argument, ts_import_call.argument from parent.indent_call_anchor by { value parent.indent_arguments_offset.nonempty ??
|
|
296
|
-
indent ts_switch.case by
|
|
295
|
+
indent ts_call.argument, ts_new.argument, ts_import_call.argument from parent.indent_call_anchor by { value parent.indent_arguments_offset.nonempty ?? callExpression; indent_numeric }
|
|
296
|
+
indent ts_switch.case by switchCase
|
|
297
297
|
indent ts_case.body by if is ts_block && count(parent.body.nodes) == 1 then 0 else 1
|
|
298
298
|
indent ts_variable_declaration.declaration class declarators by {
|
|
299
299
|
value parent
|
|
300
|
-
style: indent_variable_mode
|
|
300
|
+
style: indent_variable_mode variableDeclarator variableDeclaratorVar variableDeclaratorLet variableDeclaratorConst variableDeclaratorUsing
|
|
301
301
|
value indent_declaration_level(parent, style, mode)
|
|
302
302
|
}
|
|
303
303
|
indent in ts_variable_declaration class declarators by {
|
|
304
304
|
value node
|
|
305
|
-
style: indent_variable_mode
|
|
305
|
+
style: indent_variable_mode variableDeclarator variableDeclaratorVar variableDeclaratorLet variableDeclaratorConst variableDeclaratorUsing
|
|
306
306
|
value indent_declaration_level(node, style, mode)
|
|
307
307
|
}
|
|
308
|
-
indent ts_declarator.token from token_neighbours.before.start by if text == "=" then indent_numeric(
|
|
309
|
-
indent ts_member.property, ts_member.token, ts_member.optional, ts_index.optional, ts_meta_property.token by indent_numeric(
|
|
308
|
+
indent ts_declarator.token from token_neighbours.before.start by if text == "=" then indent_numeric(assignmentOperator) else 0
|
|
309
|
+
indent ts_member.property, ts_member.token, ts_member.optional, ts_index.optional, ts_meta_property.token by indent_numeric(memberExpression)
|
|
310
310
|
indent ts_call.optional from indent_optional_call_anchor(parent)
|
|
311
|
-
indent ts_import.specifier by indent_numeric(
|
|
311
|
+
indent ts_import.specifier by indent_numeric(importDeclaration)
|
|
312
312
|
indent ts_import.token, ts_export.token from if parent.indent_module_tail != null && offset >= parent.indent_module_tail && node not ts_semicolon then parent.offset else offset
|
|
313
313
|
indent ts_import.from, ts_export.from from if parent.indent_module_from != null then parent.offset else offset
|
|
314
314
|
indent ts_export.specifier
|
|
315
|
-
indent ts_assignment.right, ts_assignment_pattern.right by indent_numeric(
|
|
315
|
+
indent ts_assignment.right, ts_assignment_pattern.right by indent_numeric(assignmentOperator)
|
|
316
316
|
indent ts_class_property.key from if offset != parent.offset && (is ts_computed_key || first(parent.decorator.nodes) == null) then parent.offset else offset by if is ts_computed_key then 0 else 1
|
|
317
|
-
indent ts_class_property.token from if text == "=" then token_neighbours.before.start else if text == ";" then parent.init.token_neighbours.before.start.nonempty ?? parent.key.last_token.start else offset by if text == ";" then 1 else indent_numeric(
|
|
318
|
-
indent ts_class_property.init from token_neighbours.before.start by indent_numeric(
|
|
319
|
-
indent ts_declarator.init from token_neighbours.before.start by indent_numeric(
|
|
320
|
-
indent ts_import_equals.value, ts_type_parameter.default from token_neighbours.before.start by indent_numeric(
|
|
321
|
-
indent ts_import_equals.token, ts_type_parameter.token from if text == "=" then token_neighbours.before.start else offset by indent_numeric(
|
|
317
|
+
indent ts_class_property.token from if text == "=" then token_neighbours.before.start else if text == ";" then parent.init.token_neighbours.before.start.nonempty ?? parent.key.last_token.start else offset by if text == ";" then 1 else indent_numeric(assignmentOperator)
|
|
318
|
+
indent ts_class_property.init from token_neighbours.before.start by indent_numeric(assignmentOperator)
|
|
319
|
+
indent ts_declarator.init from token_neighbours.before.start by indent_numeric(assignmentOperator)
|
|
320
|
+
indent ts_import_equals.value, ts_type_parameter.default from token_neighbours.before.start by indent_numeric(assignmentOperator)
|
|
321
|
+
indent ts_import_equals.token, ts_type_parameter.token from if text == "=" then token_neighbours.before.start else offset by indent_numeric(assignmentOperator)
|
|
322
322
|
indent ts_arrow.body from indent_function_anchor(parent.indent_body_root) by if is ts_block then 0 else 1
|
|
323
323
|
indent ts_property.value, ts_return.argument, ts_throw.argument
|
|
324
324
|
indent ts_conditional.consequent, ts_conditional.alternate by {
|
|
325
325
|
value statement: containing(ts_statement)
|
|
326
|
-
value indent_ternary_level(node,
|
|
326
|
+
value indent_ternary_level(node, flatTernaryExpressions, offsetTernaryExpressions, statement)
|
|
327
327
|
}
|
|
328
328
|
# An anchor at the branch itself skips this candidate; own-line branches keep ordinary collapsing.
|
|
329
329
|
indent ts_conditional.consequent, ts_conditional.alternate from if position(first_token.start).js_line == position(token_neighbours.before.start).js_line && position(parent.offset).js_line < position(first_token.start).js_line then token_neighbours.before.start else offset class branches by {
|
|
330
330
|
value statement: containing(ts_statement)
|
|
331
|
-
value indent_ternary_anchor_level(node,
|
|
331
|
+
value indent_ternary_anchor_level(node, flatTernaryExpressions, offsetTernaryExpressions, statement)
|
|
332
332
|
}
|
|
333
|
-
indent ts_conditional.token by if
|
|
333
|
+
indent ts_conditional.token by if flatTernaryExpressions && { value statement: containing(ts_statement); value indent_flat_ternary(parent, statement) } then 0 else 1
|
|
334
334
|
indent ts_conditional_type.consequent, ts_conditional_type.alternate, ts_conditional_type.token by if parent is ts_conditional_type.alternate && position(parent.extends.last_token.end).js_line == position(parent.consequent.first_token.start).js_line then 0 else 1
|
|
335
335
|
indent in ts_jsx_element, ts_jsx_fragment
|
|
336
336
|
indent in ts_jsx_opening
|
|
@@ -340,8 +340,8 @@ in ts_line rule es-indent {
|
|
|
340
340
|
indent in ts_jsx_fragment.closing from parent.offset by 1
|
|
341
341
|
indent ts_jsx_closing.name from token_neighbours.before.start
|
|
342
342
|
indent ts_jsx_opening.token, ts_jsx_closing.token from parent.parent.offset by indent_jsx_token_level(node)
|
|
343
|
-
indent ts_jsx_attribute.token from parent.offset by indent_numeric(
|
|
344
|
-
indent ts_jsx_attribute.value from token_neighbours.before.start by indent_numeric(
|
|
343
|
+
indent ts_jsx_attribute.token from parent.offset by indent_numeric(assignmentOperator)
|
|
344
|
+
indent ts_jsx_attribute.value from token_neighbours.before.start by indent_numeric(assignmentOperator)
|
|
345
345
|
indent ts_function_type.parameter, ts_method_signature.parameter, ts_call_signature.parameter
|
|
346
346
|
indent ts_function_type.return_type, ts_method_signature.return_type, ts_call_signature.return_type
|
|
347
347
|
indent indent_generic_arguments.type_argument, indent_generic_parameters.type_parameter from parent.indent_angle_open
|
|
@@ -364,8 +364,8 @@ in ts_line rule es-indent {
|
|
|
364
364
|
let list_item indent_first_list_item(first_nodes, first_offset)
|
|
365
365
|
let list_mode if list_item == null then 1 else {
|
|
366
366
|
value list_item.parent
|
|
367
|
-
variable: indent_variable_mode
|
|
368
|
-
value indent_list_mode(list_item,
|
|
367
|
+
variable: indent_variable_mode variableDeclarator variableDeclaratorVar variableDeclaratorLet variableDeclaratorConst variableDeclaratorUsing
|
|
368
|
+
value indent_list_mode(list_item, callExpression, functionDeclarationParameters, functionExpressionParameters, arrayExpression, objectExpression, importDeclaration, variable)
|
|
369
369
|
}
|
|
370
370
|
let binary_right { value overlapping(ts_binary.right, first_offset, first_offset + 1); first }
|
|
371
371
|
let logical_right { value overlapping(ts_logical.right, first_offset, first_offset + 1); first }
|
|
@@ -399,8 +399,8 @@ in ts_line rule es-indent {
|
|
|
399
399
|
let comment_next { value comment_list.indent_items; filter (item) item.first_token.start >= comment.end_offset; first }
|
|
400
400
|
let comment_list_mode {
|
|
401
401
|
value comment_next.parent
|
|
402
|
-
variable: indent_variable_mode
|
|
403
|
-
value indent_list_mode(comment_next,
|
|
402
|
+
variable: indent_variable_mode variableDeclarator variableDeclaratorVar variableDeclaratorLet variableDeclaratorConst variableDeclaratorUsing
|
|
403
|
+
value indent_list_mode(comment_next, callExpression, functionDeclarationParameters, functionExpressionParameters, arrayExpression, objectExpression, importDeclaration, variable)
|
|
404
404
|
}
|
|
405
405
|
let comment_list_range comment_next.indent_list_previous != null && comment_next.indent_list_previous.last_token.end <= comment.offset && position(comment_next.indent_list_previous.last_token.end).js_line > position(comment_list.indent_list_open.offset).js_line && !(comment_list_mode == "first" && position(comment_next.first_token.start).js_column == len(comment_next.indent) + 1)
|
|
406
406
|
let before_wanted indent_expected(comment_before, unit)
|
|
@@ -408,7 +408,7 @@ in ts_line rule es-indent {
|
|
|
408
408
|
# Only line-leading declaration semicolons are unchecked; inline ones retain their declaration offset.
|
|
409
409
|
let after_wanted {
|
|
410
410
|
value comment_after.parent
|
|
411
|
-
variable: indent_variable_mode
|
|
411
|
+
variable: indent_variable_mode variableDeclarator variableDeclaratorVar variableDeclaratorLet variableDeclaratorConst variableDeclaratorUsing
|
|
412
412
|
value indent_comment_after(comment_policy, unit, variable)
|
|
413
413
|
}
|
|
414
414
|
when comment == null || comment_list_range || !(comment_before != null && comment.space_before.blank_gaps == 0 && indent == before_wanted || comment_after != null && comment.space_after.blank_gaps == 0 && indent == after_wanted)
|
|
@@ -421,10 +421,10 @@ in ts_line rule es-indent {
|
|
|
421
421
|
}
|
|
422
422
|
let aligned_anchor if aligned_first == null then "" else if aligned_quasi != null then indent_expected(aligned_quasi, unit) else if position(aligned_first.first_token.start).js_line == position(aligned_first.parent.offset).js_line then list_item.parent_indent else indent_expected(aligned_first, unit)
|
|
423
423
|
let aligned_column if aligned_quasi == null then len(aligned_first.indent) else position(aligned_quasi.offset).js_column - 1
|
|
424
|
-
let comment_wanted if comment_policy == null then null else indent_comment_wanted(comment_policy, after_wanted, unit,
|
|
424
|
+
let comment_wanted if comment_policy == null then null else indent_comment_wanted(comment_policy, after_wanted, unit, switchCase)
|
|
425
425
|
let attribute_node indent_attribute_node(first_offset)
|
|
426
426
|
# Raw JSX text uses the tag line's actual indentation, not virtual code-token offsets.
|
|
427
|
-
let wanted if jsx_text != null then jsx_text.parent.indent unit else if jsx_member != null then indent_expected(jsx_member.indent_jsx_closing_anchor, unit) { value
|
|
427
|
+
let wanted if jsx_text != null then jsx_text.parent.indent unit else if jsx_member != null then indent_expected(jsx_member.indent_jsx_closing_anchor, unit) { value memberExpression; levels: indent_numeric; value indent_steps(unit, levels) } else if type_of(comment_wanted) != "null" then comment_wanted else if attribute_node != null then indent_expected(attribute_node, unit) else if aligned_first != null then aligned_anchor {
|
|
428
428
|
value result: if mode == "tab" then "\t" else " "
|
|
429
429
|
value result_2: position(aligned_first.first_token.start).js_column - 1 - aligned_column
|
|
430
430
|
value repeat(result, result_2)
|
package/std/ts/jsx.dx
CHANGED
|
@@ -25,7 +25,7 @@ in ts_jsx_attribute, ts_jsx_spread_attribute {
|
|
|
25
25
|
let jsx_prop_indent_extra previous.jsx_prop_indent_extra == true || !jsx_prop_indent_operator && !contains(jsx_prop_indent_line, "<") && (if previous == null then parent.jsx_prop_indent_operator else previous.jsx_prop_indent_operator)
|
|
26
26
|
}
|
|
27
27
|
in ts_jsx_attribute, ts_jsx_spread_attribute rule es-jsx-indent-props {
|
|
28
|
-
option mode int | "tab" | "first" = 4 "prop indent size or alignment"
|
|
28
|
+
default option mode int | "tab" | "first" = 4 "prop indent size or alignment"
|
|
29
29
|
let size if mode == "tab" then 1 else mode
|
|
30
30
|
let base_indent if mode == "tab" then jsx_indent_tabs(parent.jsx_line_prefix) else jsx_indent_spaces(parent.jsx_line_prefix)
|
|
31
31
|
let actual if mode == "tab" then jsx_indent_tabs(jsx_line_prefix) else jsx_indent_spaces(jsx_line_prefix)
|
|
@@ -200,7 +200,7 @@ in ts_jsx_element, ts_jsx_fragment rule es-jsx-wrap-multilines {
|
|
|
200
200
|
fix at edit if expression_fix_retains_comments(original, edit.text) as edit.text
|
|
201
201
|
}
|
|
202
202
|
in ts_jsx_element, ts_jsx_fragment rule es-jsx-function-call-newline {
|
|
203
|
-
option mode "always" | "multiline" = "multiline" "call argument linebreak policy"
|
|
203
|
+
default option mode "always" | "multiline" = "multiline" "call argument linebreak policy"
|
|
204
204
|
when jsx_call_argument && (mode == "always" || jsx_break(text))
|
|
205
205
|
when !space_before.line_break || next_token not ts_comma && !space_after.line_break
|
|
206
206
|
warn "Missing line break around JSX"
|
|
@@ -256,7 +256,7 @@ in ts_jsx_expression {
|
|
|
256
256
|
let jsx_presence_comments { value descendants(ts_comment); count }
|
|
257
257
|
}
|
|
258
258
|
in ts_jsx_expression, ts_jsx_text, ts_string, ts_jsx_element, ts_jsx_fragment rule es-jsx-curly-brace-presence {
|
|
259
|
-
option mode "always" | "never" | "ignore" = "never" "default brace policy"
|
|
259
|
+
default option mode "always" | "never" | "ignore" = "never" "default brace policy"
|
|
260
260
|
option props "always" | "never" | "ignore" | null = null "attribute literal brace policy"
|
|
261
261
|
option children "always" | "never" | "ignore" | null = null "child literal brace policy"
|
|
262
262
|
option propElementValues "always" | "never" | "ignore" = "ignore" "JSX element attribute brace policy"
|
|
@@ -474,7 +474,7 @@ in jsx_self_closing_brackets rule es-jsx-closing-bracket-location:self-closing {
|
|
|
474
474
|
@jsx_closing_bracket_body
|
|
475
475
|
}
|
|
476
476
|
in ts_open_angle rule es-jsx-closing-tag-location {
|
|
477
|
-
option mode "tag-aligned" | "line-aligned" = "tag-aligned" "closing-tag alignment"
|
|
477
|
+
default option mode "tag-aligned" | "line-aligned" = "tag-aligned" "closing-tag alignment"
|
|
478
478
|
let here position(offset)
|
|
479
479
|
let expected if mode == "tag-aligned" then position(parent.parent.opening.offset).js_column else jsx_indent(parent.parent.opening.jsx_line_prefix) + 1
|
|
480
480
|
let own_line jsx_trim_space(jsx_line_prefix) == ""
|
|
@@ -544,7 +544,7 @@ fn jsx_contains_quote(text, double) = { value result: if double then '"' else "'
|
|
|
544
544
|
value re_test(text, result_2)
|
|
545
545
|
}
|
|
546
546
|
in ts_jsx_attribute.value rule es-jsx-quotes {
|
|
547
|
-
option mode "prefer-double" | "prefer-single" = "prefer-double" "preferred attribute quote"
|
|
547
|
+
default option mode "prefer-double" | "prefer-single" = "prefer-double" "preferred attribute quote"
|
|
548
548
|
let double mode == "prefer-double"
|
|
549
549
|
when is ts_string
|
|
550
550
|
when slice(text, 0, 1) != (if double then '"' else "'") && !{ value result: len(text) - 1; value slice(text, 1, result); jsx_contains_quote double }
|
|
@@ -556,7 +556,7 @@ in ts_jsx_attribute.value rule es-jsx-quotes {
|
|
|
556
556
|
fix at node as quote body quote
|
|
557
557
|
}
|
|
558
558
|
@macro jsx_equals_spacing_body {
|
|
559
|
-
option mode "always" | "never" = "never" "spacing around equals"
|
|
559
|
+
default option mode "always" | "never" = "never" "spacing around equals"
|
|
560
560
|
when parent is ts_jsx_attribute
|
|
561
561
|
when { value if jsx_equals_before then space_before.text else space_after.text; jsx_js_space } != (mode == "always")
|
|
562
562
|
report at if jsx_equals_before then space_before else space_after
|
|
@@ -592,7 +592,7 @@ in ts_jsx_attribute let jsx_prop_name jsx_strip_space(name)
|
|
|
592
592
|
in ts_parenthesized let jsx_unparenthesized_text expression.jsx_unparenthesized_text.nonempty ?? expression
|
|
593
593
|
in ts_jsx_spread_attribute let jsx_prop_name argument.jsx_unparenthesized_text.nonempty ?? argument
|
|
594
594
|
in ts_jsx_attribute, ts_jsx_spread_attribute rule es-jsx-first-prop-new-line {
|
|
595
|
-
option mode "always" | "never" | "multiline" | "multiline-multiprop" | "multiprop" = "multiline-multiprop" "first prop placement"
|
|
595
|
+
default option mode "always" | "never" | "multiline" | "multiline-multiprop" | "multiprop" = "multiline-multiprop" "first prop placement"
|
|
596
596
|
let should_wrap mode == "always" || mode == "multiline" && !parent.jsx_opening_single || mode == "multiline-multiprop" && !parent.jsx_opening_single && parent.jsx_property_count > 1 || mode == "multiprop" && parent.jsx_property_count > 1
|
|
597
597
|
let should_inline mode == "never" || mode == "multiprop" && !parent.jsx_opening_single && parent.jsx_property_count <= 1
|
|
598
598
|
when jsx_prop_first && (should_wrap && jsx_prop_headline || should_inline && !jsx_prop_headline)
|
|
@@ -622,8 +622,8 @@ in jsx_max_props_multiline rule es-jsx-max-props-per-line:multiline {
|
|
|
622
622
|
@jsx_max_props_body
|
|
623
623
|
}
|
|
624
624
|
@macro jsx_props_style_body {
|
|
625
|
-
option
|
|
626
|
-
when if need_wrap then jsx_prop_same && (jsx_prop_first || jsx_prop_run >
|
|
625
|
+
option maxPerLine int(1..) = 1 "maximum props per line when wrapping"
|
|
626
|
+
when if need_wrap then jsx_prop_same && (jsx_prop_first || jsx_prop_run > maxPerLine && (jsx_prop_run - 1) % maxPerLine == 0) else !jsx_prop_same
|
|
627
627
|
report at if is ts_jsx_attribute then name.node else node
|
|
628
628
|
warn if need_wrap then "Prop `{jsx_prop_name}` must be placed on a new line" else "Prop `{jsx_prop_name}` should not be placed on a new line"
|
|
629
629
|
fix at space_before if jsx_gap_safe(space_before.text) as if need_wrap then "\n" else " "
|
package/std/ts/layout/blocks.dx
CHANGED
|
@@ -5,7 +5,7 @@ import .ts/layout/shared
|
|
|
5
5
|
define {
|
|
6
6
|
|
|
7
7
|
@macro layout_block_space_options {
|
|
8
|
-
option style "always" | "never" = "always" "spaces inside non-empty blocks"
|
|
8
|
+
default option style "always" | "never" = "always" "spaces inside non-empty blocks"
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
@macro layout_switch_colon_options {
|
|
@@ -51,7 +51,7 @@ fn layout_line_breaks(gap) = re_count(gap, /\r\n|[\n\r\u{2028}\u{2029}]/)
|
|
|
51
51
|
fn layout_padding_reduced(gap) = "\n" { value gap; re_find /[^\n\r\u{2028}\u{2029}]*$/ }
|
|
52
52
|
fn layout_padding_mode(style, blocks, switches, classes, owner) = if owner.layout_block_module.nonempty ?? false then null else if style != null then style else if blocks == null && switches == null && classes == null then "always" else if owner is ts_class then classes else if owner is ts_switch then switches else blocks
|
|
53
53
|
@macro layout_padding_options {
|
|
54
|
-
option style "always" | "never" | "start" | "end" | null = null "padding at block boundaries"
|
|
54
|
+
default option style "always" | "never" | "start" | "end" | null = null "padding at block boundaries"
|
|
55
55
|
option blocks "always" | "never" | "start" | "end" | null = null "statement block padding"
|
|
56
56
|
option switches "always" | "never" | "start" | "end" | null = null "switch padding"
|
|
57
57
|
option classes "always" | "never" | "start" | "end" | null = null "class padding"
|
|
@@ -152,7 +152,7 @@ fn layout_member_gap_fix(source, start, end, padded) = {
|
|
|
152
152
|
else { start: insertion, end: insertion, text: "\n" }
|
|
153
153
|
}
|
|
154
154
|
in ts_class.member rule es-lines-between-class-members {
|
|
155
|
-
option style "always" | "never" = "always" "blank lines between class members"
|
|
155
|
+
default option style "always" | "never" = "always" "blank lines between class members"
|
|
156
156
|
option enforce { blankLine: "always" | "never"; prev: "method" | "field" | "*"; next: "method" | "field" | "*" }[] = [] "policy by neighbouring member kinds"
|
|
157
157
|
option exceptAfterSingleLine boolean = false "skip after single-line members"
|
|
158
158
|
option exceptAfterOverload boolean = true "skip overload signatures"
|
|
@@ -181,7 +181,7 @@ in ts_class.member rule es-lines-between-class-members {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
in ts_open_brace rule es-space-before-blocks {
|
|
184
|
-
option style "always" | "never" = "always" "spaces before blocks"
|
|
184
|
+
default option style "always" | "never" = "always" "spaces before blocks"
|
|
185
185
|
option functions "always" | "never" | "off" | null = null "function body policy"
|
|
186
186
|
option keywords "always" | "never" | "off" | null = null "statement body policy"
|
|
187
187
|
option classes "always" | "never" | "off" | null = null "class body policy"
|
|
@@ -243,7 +243,7 @@ in ts_colon rule es-switch-colon-spacing:after {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
@macro layout_brace_options {
|
|
246
|
-
option style "1tbs" | "stroustrup" | "allman" = "1tbs" "brace layout"
|
|
246
|
+
default option style "1tbs" | "stroustrup" | "allman" = "1tbs" "brace layout"
|
|
247
247
|
option allowSingleLine boolean = false "allow single-line block bodies"
|
|
248
248
|
when parent is (ts_block, ts_static_block, ts_switch, ts_class)
|
|
249
249
|
when !(parent.layout_brace_excluded.nonempty ?? false)
|
package/std/ts/layout/calls.dx
CHANGED
|
@@ -6,7 +6,7 @@ import .ts/format
|
|
|
6
6
|
define {
|
|
7
7
|
|
|
8
8
|
in ts_open_paren rule es-space-before-function-paren {
|
|
9
|
-
option style "always" | "never" = "always" "spaces before function parameter lists"
|
|
9
|
+
default option style "always" | "never" = "always" "spaces before function parameter lists"
|
|
10
10
|
option named "always" | "never" | "ignore" | null = null "named function policy"
|
|
11
11
|
option anonymous "always" | "never" | "ignore" | null = null "anonymous function policy"
|
|
12
12
|
option asyncArrow "always" | "never" | "ignore" | null = null "async arrow policy"
|
|
@@ -39,10 +39,10 @@ fn layout_invocation_chain(gap, allow_newlines, before, after) = {
|
|
|
39
39
|
value if after then (if re_test(prefix, /\s$/) then prefix else prefix " ") else trim_end(prefix)
|
|
40
40
|
}
|
|
41
41
|
in ts_open_paren rule es-function-call-spacing {
|
|
42
|
-
option mode "always" | "never" = "never" "spacing before invocation parentheses"
|
|
42
|
+
default option mode "always" | "never" = "never" "spacing before invocation parentheses"
|
|
43
43
|
option allowNewlines boolean = false "allow line breaks before invocation parentheses"
|
|
44
|
-
option
|
|
45
|
-
option
|
|
44
|
+
option chainBefore boolean = true "space before optional invocation punctuation"
|
|
45
|
+
option chainAfter boolean = true "space after optional invocation punctuation"
|
|
46
46
|
when parent is (ts_call, ts_new, ts_import_call)
|
|
47
47
|
when offset >= parent.layout_invocation_end
|
|
48
48
|
let invocation_optional parent.layout_invocation_optional
|
|
@@ -50,23 +50,23 @@ in ts_open_paren rule es-function-call-spacing {
|
|
|
50
50
|
let invocation_spaced invocation_prefix.spaced || space_before.spaced
|
|
51
51
|
let bad_newline mode == "always" && !allowNewlines && (invocation_prefix.line_break || space_before.line_break)
|
|
52
52
|
let bad_space if mode == "never" then invocation_spaced
|
|
53
|
-
else if invocation_optional then invocation_prefix.spaced !=
|
|
53
|
+
else if invocation_optional then invocation_prefix.spaced != chainBefore || space_before.spaced != chainAfter
|
|
54
54
|
else !invocation_spaced
|
|
55
55
|
when bad_newline || bad_space
|
|
56
56
|
report at { start: invocation_prefix.start, end: offset }
|
|
57
57
|
warn if bad_newline then "Unexpected newline between function name and paren."
|
|
58
|
-
else if mode == "never" || invocation_optional && (!
|
|
58
|
+
else if mode == "never" || invocation_optional && (!chainBefore && invocation_prefix.spaced || !chainAfter && space_before.spaced) then "Unexpected whitespace between function name and paren."
|
|
59
59
|
else "Missing space between function name and paren."
|
|
60
60
|
let invocation_insert mode == "always" && !invocation_optional && !invocation_spaced
|
|
61
61
|
let invocation_gap byte_slice(source, invocation_prefix.start, offset)
|
|
62
62
|
let invocation_fix if mode == "never" then (if invocation_optional then "?." else "")
|
|
63
|
-
else if invocation_optional then layout_invocation_chain(invocation_gap, allowNewlines,
|
|
63
|
+
else if invocation_optional then layout_invocation_chain(invocation_gap, allowNewlines, chainBefore, chainAfter) else " "
|
|
64
64
|
fix at { start: if invocation_insert then offset else invocation_prefix.start, end: offset } if invocation_insert || !(invocation_prefix.comments || space_before.comments) as invocation_fix
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
# Empty constructor argument lists belong to this new expression, not its callee.
|
|
68
68
|
in ts_new rule es-new-parens {
|
|
69
|
-
option style "always" | "never" = "always" "empty constructor parentheses"
|
|
69
|
+
default option style "always" | "never" = "always" "empty constructor parentheses"
|
|
70
70
|
let constructor_open opener.ts_open_paren.offset
|
|
71
71
|
let constructor_close closer.ts_close_paren.offset
|
|
72
72
|
when count(argument) == 0
|
|
@@ -6,7 +6,7 @@ import .ts/expression-fixes
|
|
|
6
6
|
define {
|
|
7
7
|
|
|
8
8
|
@macro layout_computed_space_options {
|
|
9
|
-
option style "always" | "never" = "never" "spaces inside computed property brackets"
|
|
9
|
+
default option style "always" | "never" = "never" "spaces inside computed property brackets"
|
|
10
10
|
option enforceForClassMembers boolean = true "check class member keys"
|
|
11
11
|
}
|
|
12
12
|
group computed_spacing_owners ts_computed_key, ts_index, ts_indexed_access
|
|
@@ -20,7 +20,7 @@ in ts_function let generator_star_named name != null
|
|
|
20
20
|
in ts_method let generator_star_shorthand parent is ts_object
|
|
21
21
|
@macro layout_yield_star_options {
|
|
22
22
|
@ts_token_context
|
|
23
|
-
option mode "before" | "after" | "both" | "neither" = "after" "spacing around yield star"
|
|
23
|
+
default option mode "before" | "after" | "both" | "neither" = "after" "spacing around yield star"
|
|
24
24
|
option before boolean | null = null "override space before star"
|
|
25
25
|
option after boolean | null = null "override space after star"
|
|
26
26
|
}
|
|
@@ -200,7 +200,7 @@ in ts_unary, ts_update, ts_new, ts_await, ts_yield, ts_non_null rule es-space-un
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
in ts_ellipsis rule es-rest-spread-spacing {
|
|
203
|
-
option style "always" | "never" = "never" "spacing after rest and spread"
|
|
203
|
+
default option style "always" | "never" = "never" "spacing after rest and spread"
|
|
204
204
|
when parent is (ts_rest, ts_spread) && next_token != null
|
|
205
205
|
let spread_space layout_comma_space(space_after.text, false)
|
|
206
206
|
when (spread_space != "") != (style == "always")
|
|
@@ -19,7 +19,7 @@ fn layout_quote_piece_text(piece, old, target) =
|
|
|
19
19
|
else if piece == target || target == "`" && piece == "${{" then "\\" piece
|
|
20
20
|
else piece
|
|
21
21
|
in quoted_literals rule es-quotes {
|
|
22
|
-
option style "double" | "single" | "backtick" = "double" "string delimiters"
|
|
22
|
+
default option style "double" | "single" | "backtick" = "double" "string delimiters"
|
|
23
23
|
option avoidEscape boolean = false "allow alternate quotes to avoid escapes"
|
|
24
24
|
option allowTemplateLiterals "never" | "avoidEscape" | "always" = "never" "allow unused template delimiters"
|
|
25
25
|
let quote_template is ts_template
|
|
@@ -84,7 +84,7 @@ fn layout_property_quote_sites(n) = {
|
|
|
84
84
|
value filter(sites, site => site != null)
|
|
85
85
|
}
|
|
86
86
|
in ts_property, ts_pattern_property, ts_property_signature, ts_enum_member, ts_object, ts_interface, ts_type_literal, ts_enum, ts_import, ts_export rule es-quote-props {
|
|
87
|
-
option style "always" | "as-needed" | "consistent" | "consistent-as-needed" = "always" "property quoting policy"
|
|
87
|
+
default option style "always" | "as-needed" | "consistent" | "consistent-as-needed" = "always" "property quoting policy"
|
|
88
88
|
option keywords boolean = false "require quotes on reserved words"
|
|
89
89
|
option unnecessary boolean = true "report redundant quotes"
|
|
90
90
|
option numbers boolean = false "require quoted numeric keys"
|
|
@@ -23,7 +23,7 @@ in ts_import_attribute_comma {
|
|
|
23
23
|
}
|
|
24
24
|
in ts_comma, ts_import_attribute_comma let comma_style_checked comma_style_owner is comma_style_lists
|
|
25
25
|
in ts_comma, ts_import_attribute_comma rule es-comma-style {
|
|
26
|
-
option style "last" | "first" = "last" "comma line position"
|
|
26
|
+
default option style "last" | "first" = "last" "comma line position"
|
|
27
27
|
when if style == "last" then space_before.line_break else space_after.line_break
|
|
28
28
|
when comma_style_checked
|
|
29
29
|
when comma_style_owner not (ts_array, ts_array_pattern) || comma_style_previous != null
|
|
@@ -57,7 +57,7 @@ fn layout_attribute_sites(sites, style, policies) = {
|
|
|
57
57
|
}) else []
|
|
58
58
|
}
|
|
59
59
|
in ts_array, ts_array_pattern, ts_object, ts_object_pattern, ts_function, ts_arrow, ts_method, ts_function_type, ts_call, ts_new, ts_import_call, ts_import, ts_export, ts_enum, ts_tuple_type, ts_class, ts_interface, ts_type_alias, ts_type_reference, ts_method_signature, ts_call_signature, ts_import_attributes rule es-comma-dangle {
|
|
60
|
-
option style trailing_comma_mode = "never" "trailing comma policy"
|
|
60
|
+
default option style trailing_comma_mode = "never" "trailing comma policy"
|
|
61
61
|
option arrays trailing_comma_mode | null = null "array policy"
|
|
62
62
|
option objects trailing_comma_mode | null = null "object policy"
|
|
63
63
|
option functions trailing_comma_mode | null = null "parameter and argument policy"
|
|
@@ -95,7 +95,7 @@ in ts_variable_declaration let layout_semi_initializer parent is ts_for && offse
|
|
|
95
95
|
in ts_semicolon let layout_semi_header if parent is ts_for then parent.init != null && (parent.test == null && previous_token not ts_semicolon || offset < parent.test.offset) || parent.test != null && offset >= parent.test.end_offset else parent.layout_semi_initializer.nonempty ?? false
|
|
96
96
|
in ts_semicolon let layout_semi_statement parent is layout_semi_owner && end_offset == parent.end_offset
|
|
97
97
|
in ts_semicolon rule es-semi-style {
|
|
98
|
-
option style "last" | "first" = "last" "semicolon line position"
|
|
98
|
+
default option style "last" | "first" = "last" "semicolon line position"
|
|
99
99
|
when layout_semi_header || layout_semi_statement
|
|
100
100
|
let semi_at_end style == "last" || layout_semi_header
|
|
101
101
|
when if semi_at_end then position(offset).js_line != position(token(node, "before").end).js_line
|
|
@@ -167,7 +167,7 @@ fn layout_next_position_len(source, offset) = {
|
|
|
167
167
|
value if char == "\r" && byte_char(source, offset + 1) == "\n" then 2 else byte_len(char)
|
|
168
168
|
}
|
|
169
169
|
in semicolon_statement rule es-semi {
|
|
170
|
-
option mode "always" | "never" = "always" "statement semicolon policy"
|
|
170
|
+
default option mode "always" | "never" = "always" "statement semicolon policy"
|
|
171
171
|
option omitLastInOneLineBlock boolean = false "omit final semicolons in single-line blocks"
|
|
172
172
|
option omitLastInOneLineClassBody boolean = false "omit final semicolons in single-line class bodies"
|
|
173
173
|
option beforeStatementContinuationChars "always" | "any" | "never" = "any" "semicolons before continuation characters"
|
package/std/ts/layout/text.dx
CHANGED
|
@@ -43,7 +43,7 @@ in multiple_space_gap rule es-no-multi-spaces {
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
@macro layout_comment_policy {
|
|
46
|
-
option style "always" | "never" = "always" "spacing inside comment delimiters"
|
|
46
|
+
default option style "always" | "never" = "always" "spacing inside comment delimiters"
|
|
47
47
|
option exceptions string[] = [] "repeated sequences exempt from spacing"
|
|
48
48
|
option markers string[] = [] "comment prefix markers"
|
|
49
49
|
let comment_block is ts_block_comment
|
package/std/ts/license.dx
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
define {
|
|
9
9
|
|
|
10
10
|
@macro license_text ({ value to: @newline; value replace(license, "\n", to) })
|
|
11
|
-
@macro license_wanted license != "" && (
|
|
11
|
+
@macro license_wanted license != "" && (skipFiles == "" || !re_test(file, skipFiles))
|
|
12
12
|
fn license_like(comment) = re_test(comment, /(?i)(?:Copyright|@license|SPDX-License-Identifier)\b/)
|
|
13
13
|
|
|
14
14
|
in ts_program let license_prefix re_find(text, /\A\s*/)
|
|
@@ -18,7 +18,7 @@ in ts_program let license_suffix_space if license_header == null then "" else {
|
|
|
18
18
|
|
|
19
19
|
in ts_program rule es-header:missing warn "Missing license header" {
|
|
20
20
|
option license string = "" "the license header"
|
|
21
|
-
option
|
|
21
|
+
option skipFiles regex = "" "file paths without a header"
|
|
22
22
|
report change
|
|
23
23
|
when @license_wanted && byte_len(license_prefix) < byte_len(text)
|
|
24
24
|
when license_header == null || !license_like(license_header.text)
|
|
@@ -26,7 +26,7 @@ in ts_program rule es-header:missing warn "Missing license header" {
|
|
|
26
26
|
}
|
|
27
27
|
in ts_program rule es-header:invalid warn "Invalid license header" {
|
|
28
28
|
option license string = "" "the license header"
|
|
29
|
-
option
|
|
29
|
+
option skipFiles regex = "" "file paths without a header"
|
|
30
30
|
when @license_wanted && license_header != null
|
|
31
31
|
when license_like(license_header.text) && license_header.text != @license_text
|
|
32
32
|
report at { start: license_header.offset, end: license_header.end_offset }
|
|
@@ -34,7 +34,7 @@ in ts_program rule es-header:invalid warn "Invalid license header" {
|
|
|
34
34
|
}
|
|
35
35
|
in ts_program rule es-header:before warn "Superfluous new lines before license header" {
|
|
36
36
|
option license string = "" "the license header"
|
|
37
|
-
option
|
|
37
|
+
option skipFiles regex = "" "file paths without a header"
|
|
38
38
|
when @license_wanted && license_header != null && contains(license_prefix, "\n")
|
|
39
39
|
when license_header.text == @license_text
|
|
40
40
|
report at license_header.offset
|
|
@@ -42,7 +42,7 @@ in ts_program rule es-header:before warn "Superfluous new lines before license h
|
|
|
42
42
|
}
|
|
43
43
|
in ts_program rule es-header:after warn "{if re_count(license_suffix_space, /\n/) > 2 then 'Superfluous new lines' else 'Missing new line'} after license header" {
|
|
44
44
|
option license string = "" "the license header"
|
|
45
|
-
option
|
|
45
|
+
option skipFiles regex = "" "file paths without a header"
|
|
46
46
|
when @license_wanted && license_header != null
|
|
47
47
|
when license_header.text == @license_text
|
|
48
48
|
let suffix_end license_header.end_offset + byte_len(license_suffix_space)
|
package/std/ts/parentheses.dx
CHANGED
|
@@ -12,7 +12,7 @@ in ts_parenthesized let structure_iife_callee expression.structure_iife_callee
|
|
|
12
12
|
in ts_member, ts_index let structure_iife_callee if (object.structure_iife_callee).direct && contains(["call", "apply"], static_name) then { direct: false, prototype: true, wrapped: (object.structure_iife_callee).wrapped, node: (object.structure_iife_callee).node } else null
|
|
13
13
|
|
|
14
14
|
in ts_call rule es-wrap-iife {
|
|
15
|
-
option mode "outside" | "inside" | "any" = "outside"
|
|
15
|
+
default option mode "outside" | "inside" | "any" = "outside"
|
|
16
16
|
option functionPrototypeMethods boolean = false "include function call/apply invocations"
|
|
17
17
|
let info callee.structure_iife_callee
|
|
18
18
|
when info != null && (functionPrototypeMethods || !info.prototype)
|
|
@@ -18,14 +18,14 @@ in ts_binary rule es-no-compare-neg-zero {
|
|
|
18
18
|
in ts_assignment let is_assignment true
|
|
19
19
|
in ts_parenthesized let wraps_assignment expression.is_assignment == true
|
|
20
20
|
in ts_if.test, ts_while.test, ts_do_while.test, ts_for.test, ts_conditional.test rule es-no-cond-assign {
|
|
21
|
-
option mode "except-parens" | "always" = "except-parens"
|
|
21
|
+
default option mode "except-parens" | "always" = "except-parens"
|
|
22
22
|
when mode == "except-parens"
|
|
23
23
|
when is ts_assignment || parent is ts_conditional && is ts_parenthesized && wraps_assignment == true
|
|
24
24
|
report at unparenthesised_node(node)
|
|
25
25
|
warn "Expected a conditional expression and instead saw an assignment."
|
|
26
26
|
}
|
|
27
27
|
in ts_assignment rule es-no-cond-assign:always {
|
|
28
|
-
option mode "except-parens" | "always" = "except-parens"
|
|
28
|
+
default option mode "except-parens" | "always" = "except-parens"
|
|
29
29
|
let where if conditional_ancestor is ts_if then "an 'if' statement" else if conditional_ancestor is ts_while then "a 'while' statement" else if conditional_ancestor is ts_do_while then "a 'do...while' statement" else if conditional_ancestor is ts_for then "a 'for' statement" else "ConditionalExpression"
|
|
30
30
|
when mode == "always" && conditional_ancestor != null
|
|
31
31
|
warn "Unexpected assignment within {where}."
|
|
@@ -59,7 +59,7 @@ fn comment_case_fix(n, body, mode) = {
|
|
|
59
59
|
}
|
|
60
60
|
in ts_comment let capitalized_comments_checked true
|
|
61
61
|
@macro restriction_capitalized_comment_body {
|
|
62
|
-
option mode "always" | "never" = "always" "required initial letter case"
|
|
62
|
+
default option mode "always" | "never" = "always" "required initial letter case"
|
|
63
63
|
option ignorePattern regex = "" "starting comment text to ignore"
|
|
64
64
|
when capitalized_comments_checked
|
|
65
65
|
when (if mode == "always" then restriction_comment_lowercase else restriction_comment_uppercase)
|
package/std/ts/restrictions.dx
CHANGED
|
@@ -366,7 +366,7 @@ in ts_property, ts_method {
|
|
|
366
366
|
}
|
|
367
367
|
in ts_object let restriction_sort_key_count count(property)
|
|
368
368
|
in ts_property, ts_method, ts_spread rule es-sort-keys {
|
|
369
|
-
option mode "asc" | "desc" = "asc" "key order"
|
|
369
|
+
default option mode "asc" | "desc" = "asc" "key order"
|
|
370
370
|
option caseSensitive boolean = true "compare letter case"
|
|
371
371
|
option natural boolean = false "compare digit sequences numerically"
|
|
372
372
|
option minKeys int(2..) = 2 "minimum object properties"
|
|
@@ -502,7 +502,7 @@ in ts_parameter {
|
|
|
502
502
|
let max_params_counted !restriction_void_this_parameter || node != first(parent.parameter.nodes)
|
|
503
503
|
}
|
|
504
504
|
in restriction_parameter_function rule es-max-params {
|
|
505
|
-
option max int(0..) = 3 "maximum parameters"
|
|
505
|
+
default option max int(0..) = 3 "maximum parameters"
|
|
506
506
|
let amount { value parameter.nodes; filter (p) p.max_params_counted.nonempty ?? true; count }
|
|
507
507
|
when amount > max
|
|
508
508
|
report at restriction_function_head(node)
|
|
@@ -519,7 +519,7 @@ in ts_function_like {
|
|
|
519
519
|
let max_statements_checked true
|
|
520
520
|
}
|
|
521
521
|
in ts_function_like rule es-max-statements {
|
|
522
|
-
option max int(0..) = 10 "maximum statements"
|
|
522
|
+
default option max int(0..) = 10 "maximum statements"
|
|
523
523
|
option ignoreTopLevelFunctions boolean = false "skip top-level functions unless the file has only one"
|
|
524
524
|
when restriction_subtree_statements > max
|
|
525
525
|
when max_statements_checked
|
|
@@ -528,7 +528,7 @@ in ts_function_like rule es-max-statements {
|
|
|
528
528
|
warn "{@restriction_function_name} has too many statements ({restriction_subtree_statements}). Maximum allowed is {max}."
|
|
529
529
|
}
|
|
530
530
|
in ts_function_like rule es-complexity {
|
|
531
|
-
option max int(0..) = 20 "maximum cyclomatic complexity"
|
|
531
|
+
default option max int(0..) = 20 "maximum cyclomatic complexity"
|
|
532
532
|
option variant "classic" | "modified" = "classic" "how switches contribute"
|
|
533
533
|
let amount 1 + (if variant == "classic" then restriction_subtree_classic else restriction_subtree_modified)
|
|
534
534
|
when amount > max
|
|
@@ -536,7 +536,7 @@ in ts_function_like rule es-complexity {
|
|
|
536
536
|
warn "{@restriction_function_name} has a complexity of {amount}. Maximum allowed is {max}."
|
|
537
537
|
}
|
|
538
538
|
in ts_static_block, ts_class_property.init rule es-complexity:implicit {
|
|
539
|
-
option max int(0..) = 20 "maximum cyclomatic complexity"
|
|
539
|
+
default option max int(0..) = 20 "maximum cyclomatic complexity"
|
|
540
540
|
option variant "classic" | "modified" = "classic" "how switches contribute"
|
|
541
541
|
let amount if is (ts_function, ts_arrow) then 1 else 1 + (if variant == "classic" then restriction_subtree_classic else restriction_subtree_modified)
|
|
542
542
|
when amount > max
|
|
@@ -546,21 +546,21 @@ in ts_static_block, ts_class_property.init rule es-complexity:implicit {
|
|
|
546
546
|
group restriction_depth_control ts_if, ts_switch, ts_try, ts_do_while, ts_while, ts_with, ts_for, ts_for_in, ts_for_of
|
|
547
547
|
in ts_statement, ts_arrow, ts_method, ts_static_block, ts_case let restriction_nesting if is (ts_function_like, ts_static_block) then 0 else (parent.restriction_nesting.nonempty ?? 0) + (if is restriction_depth_control && !(is ts_if && is ts_if.alternate) then 1 else 0)
|
|
548
548
|
in restriction_depth_control rule es-max-depth {
|
|
549
|
-
option max int(0..) = 4 "maximum control-flow nesting"
|
|
549
|
+
default option max int(0..) = 4 "maximum control-flow nesting"
|
|
550
550
|
when !(is ts_if && is ts_if.alternate)
|
|
551
551
|
when restriction_nesting > max
|
|
552
552
|
report at { start: first_token.start, end: first_token.end }
|
|
553
553
|
warn "Blocks are nested too deeply ({restriction_nesting}). Maximum allowed is {max}."
|
|
554
554
|
}
|
|
555
555
|
in ts_function, ts_arrow rule es-max-nested-callbacks {
|
|
556
|
-
option max int(0..) = 10 "maximum callback nesting"
|
|
556
|
+
default option max int(0..) = 10 "maximum callback nesting"
|
|
557
557
|
let amount restriction_callbacks
|
|
558
558
|
when max_nested_callbacks_counted && amount > max
|
|
559
559
|
report at function_warning_site(node)
|
|
560
560
|
warn "Too many nested callbacks ({amount}). Maximum allowed is {max}."
|
|
561
561
|
}
|
|
562
562
|
in ts_program rule es-max-classes-per-file {
|
|
563
|
-
option max int(1..) = 1 "maximum classes"
|
|
563
|
+
default option max int(1..) = 1 "maximum classes"
|
|
564
564
|
option ignoreExpressions boolean = false "count only class declarations"
|
|
565
565
|
let amount if ignoreExpressions then restriction_declared_classes else restriction_classes
|
|
566
566
|
when amount > max
|
|
@@ -608,7 +608,7 @@ fn restriction_function_head(n) = when {
|
|
|
608
608
|
else then { start: n.offset, end: restriction_open_paren(n) }
|
|
609
609
|
}
|
|
610
610
|
in ts_program rule es-max-lines {
|
|
611
|
-
option max int(0..) = 300 "maximum lines"
|
|
611
|
+
default option max int(0..) = 300 "maximum lines"
|
|
612
612
|
option skipComments boolean = false "exclude comment-only lines"
|
|
613
613
|
option skipBlankLines boolean = false "exclude blank lines"
|
|
614
614
|
let lines filter(restriction_line_rows, l => !(skipComments && l.restriction_line_comment || skipBlankLines && l.restriction_line_blank))
|
|
@@ -620,7 +620,7 @@ in ts_program rule es-max-lines {
|
|
|
620
620
|
}
|
|
621
621
|
in ts_function_like let max_lines_per_function_checked !restriction_iife
|
|
622
622
|
in ts_function_like rule es-max-lines-per-function {
|
|
623
|
-
option max int(0..) = 50 "maximum function lines"
|
|
623
|
+
default option max int(0..) = 50 "maximum function lines"
|
|
624
624
|
option skipComments boolean = false "exclude comment-only lines"
|
|
625
625
|
option skipBlankLines boolean = false "exclude blank lines"
|
|
626
626
|
let lines filter(restriction_line_rows, l => !(skipComments && l.restriction_line_comment || skipBlankLines && l.restriction_line_blank))
|
|
@@ -694,7 +694,7 @@ in ts_identifier, ts_private_name {
|
|
|
694
694
|
let id_match_checked contains(["always", "destructuring", "import", "declaration", "reference"], restriction_name_match_context)
|
|
695
695
|
}
|
|
696
696
|
in ts_identifier, ts_private_name rule es-id-match {
|
|
697
|
-
option mode regex = "^.+$" "required identifier pattern"
|
|
697
|
+
default option mode regex = "^.+$" "required identifier pattern"
|
|
698
698
|
when !restriction_name_attributes && id_match_checked && !restriction_name_external
|
|
699
699
|
when !re_test(restriction_identifier_name, mode)
|
|
700
700
|
warn "Identifier '{text}' does not match the pattern '{mode}'."
|
package/std/ts/scoping.dx
CHANGED
|
@@ -218,7 +218,7 @@ in ts_function let scoping_function_context {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
in ts_function rule es-func-names {
|
|
221
|
-
option mode "always" | "as-needed" | "never" = "always"
|
|
221
|
+
default option mode "always" | "as-needed" | "never" = "always"
|
|
222
222
|
option generators "always" | "as-needed" | "never" | null = null "override policy for generators"
|
|
223
223
|
let context scoping_function_context
|
|
224
224
|
let policy if context.generator && generators != null then generators else mode
|
|
@@ -270,7 +270,7 @@ in ts_property, ts_class_property let scoping_name_destination
|
|
|
270
270
|
property: true, commonjs: false, descriptor: if static_name == "value" then parent.scoping_descriptor_context else null, offset: offset}
|
|
271
271
|
in ts_parenthesized let scoping_name_destination parent.scoping_name_destination
|
|
272
272
|
in ts_function rule es-func-name-matching {
|
|
273
|
-
option mode "always" | "never" = "always"
|
|
273
|
+
default option mode "always" | "never" = "always"
|
|
274
274
|
option considerPropertyDescriptor boolean = false
|
|
275
275
|
option includeCommonJSModuleExports boolean = false
|
|
276
276
|
let matched parent.scoping_name_destination
|
|
@@ -548,7 +548,7 @@ in ts_variable_declaration rule es-vars-on-top {
|
|
|
548
548
|
}
|
|
549
549
|
|
|
550
550
|
in ts_function rule es-no-inner-declarations {
|
|
551
|
-
option mode "functions" | "both" = "functions"
|
|
551
|
+
default option mode "functions" | "both" = "functions"
|
|
552
552
|
option blockScopedFunctions "allow" | "disallow" = "allow"
|
|
553
553
|
when parent is (ts_program, ts_block, ts_export, ts_if, ts_labeled, ts_while, ts_do_while, ts_for, ts_for_in, ts_for_of, ts_case)
|
|
554
554
|
when !parent.scoping_body_root && parent not ts_export
|
|
@@ -556,7 +556,7 @@ in ts_function rule es-no-inner-declarations {
|
|
|
556
556
|
warn "Move function declaration to { parent.scoping_declaration_body.nonempty ?? 'program' } root."
|
|
557
557
|
}
|
|
558
558
|
in ts_variable_declaration rule es-no-inner-declarations:variable {
|
|
559
|
-
option mode "functions" | "both" = "functions"
|
|
559
|
+
default option mode "functions" | "both" = "functions"
|
|
560
560
|
option blockScopedFunctions "allow" | "disallow" = "allow"
|
|
561
561
|
when mode == "both" && kind == "var" && !parent.scoping_body_root && parent not ts_export
|
|
562
562
|
warn "Move variable declaration to { parent.scoping_declaration_body.nonempty ?? 'program' } root."
|
|
@@ -642,7 +642,7 @@ in ts_program.binding_declarations rule es-no-shadow {
|
|
|
642
642
|
}
|
|
643
643
|
|
|
644
644
|
in ts_identifier rule es-no-use-before-define {
|
|
645
|
-
option mode "always" | "nofunc" = "always"
|
|
645
|
+
default option mode "always" | "nofunc" = "always"
|
|
646
646
|
option functions boolean = true "check function declarations"
|
|
647
647
|
option classes boolean = true "check class declarations across execution contexts"
|
|
648
648
|
option variables boolean = true "check variables across execution contexts"
|
|
@@ -735,14 +735,14 @@ in ts_variable_declaration {
|
|
|
735
735
|
let scoping_iteration_binding is (ts_for_in.left, ts_for_of.left)
|
|
736
736
|
}
|
|
737
737
|
in ts_declarator rule es-init-declarations {
|
|
738
|
-
option mode "always" | "never" = "always"
|
|
738
|
+
default option mode "always" | "never" = "always"
|
|
739
739
|
option ignoreForLoopInit boolean = false "allow initialized declarations in loop initializers"
|
|
740
740
|
when name.declaration_kind != null && name.ambient != true && mode == "always" && init == null
|
|
741
741
|
when !parent.scoping_iteration_binding
|
|
742
742
|
warn "Variable '{name}' should be initialized on declaration."
|
|
743
743
|
}
|
|
744
744
|
in ts_declarator rule es-init-declarations:never {
|
|
745
|
-
option mode "always" | "never" = "always"
|
|
745
|
+
default option mode "always" | "never" = "always"
|
|
746
746
|
option ignoreForLoopInit boolean = false "allow initialized declarations in loop initializers"
|
|
747
747
|
when name.declaration_kind != null && name.ambient != true && mode == "never"
|
|
748
748
|
when parent.kind != "const" && name.declaration_kind != "using"
|
package/std/ts/structure.dx
CHANGED
|
@@ -375,7 +375,7 @@ in ts_line_comment rule es-line-comment-position {
|
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
@macro structure_comment_style_options {
|
|
378
|
-
option mode "starred-block" | "bare-block" | "separate-lines" = "starred-block"
|
|
378
|
+
default option mode "starred-block" | "bare-block" | "separate-lines" = "starred-block"
|
|
379
379
|
option checkJSDoc boolean = false "check JSDoc when requiring line comments"
|
|
380
380
|
option checkExclamation boolean = false "check exclamation comments when requiring line comments"
|
|
381
381
|
}
|
|
@@ -548,7 +548,7 @@ in ts_line_comment rule es-multiline-comment-style:consecutive {
|
|
|
548
548
|
}
|
|
549
549
|
|
|
550
550
|
in ts_question, ts_colon rule es-multiline-ternary {
|
|
551
|
-
option mode "always" | "always-multiline" | "never" = "always"
|
|
551
|
+
default option mode "always" | "always-multiline" | "never" = "always"
|
|
552
552
|
option ignoreJSX boolean = false "ignore conditionals in JSX expressions"
|
|
553
553
|
when parent is ts_conditional
|
|
554
554
|
when !ignoreJSX || !parent.structure_ternary_jsx
|
|
@@ -577,7 +577,7 @@ in structure_tab_run rule es-no-tabs {
|
|
|
577
577
|
}
|
|
578
578
|
|
|
579
579
|
in ts_line rule es-no-mixed-spaces-and-tabs {
|
|
580
|
-
option mode "default" | "smart-tabs" = "default"
|
|
580
|
+
default option mode "default" | "smart-tabs" = "default"
|
|
581
581
|
let indentation re_find(structure_line_content, /^[ \t]+/)
|
|
582
582
|
let mixed if indentation == null then null
|
|
583
583
|
else if mode == "smart-tabs" then re_find(indentation, /^\t* +\t/)
|
|
@@ -595,7 +595,7 @@ in ts_line rule es-no-mixed-spaces-and-tabs {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
in ts_program rule es-unicode-bom {
|
|
598
|
-
option mode "always" | "never" = "never"
|
|
598
|
+
default option mode "always" | "never" = "never"
|
|
599
599
|
when mode == "always" && !bom || mode == "never" && bom
|
|
600
600
|
fix at { start: 0, end: if mode == "never" then 3 else 0 } as if mode == "always" then "\u{feff}" else ""
|
|
601
601
|
report at 0
|
|
@@ -609,7 +609,7 @@ in ts_regex rule es-wrap-regex {
|
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
in ts_declarator rule es-one-var-declaration-per-line {
|
|
612
|
-
option mode "initializations" | "always" = "initializations"
|
|
612
|
+
default option mode "initializations" | "always" = "initializations"
|
|
613
613
|
when previous_sibling != null && !re_test(previous_gap, /[\n\r\u{2028}\u{2029}]/)
|
|
614
614
|
when !parent.structure_loop_declaration
|
|
615
615
|
when mode == "always" || init != null || previous.init != null
|
|
@@ -646,7 +646,7 @@ fn operand_add(info) =
|
|
|
646
646
|
|| contains(["[", "(", "{{", "=>", ":"], info.before) || operand_assignment(info.before)
|
|
647
647
|
|
|
648
648
|
in ts_program rule es-indent-binary-ops {
|
|
649
|
-
option mode number | "tab" = 2 "indent width or tabs"
|
|
649
|
+
default option mode number | "tab" = 2 "indent width or tabs"
|
|
650
650
|
let width if mode == "tab" then 1 else mode
|
|
651
651
|
let unit if mode == "tab" then "\t" else " "
|
|
652
652
|
let measurements {
|
|
@@ -695,7 +695,7 @@ fn structure_operator_fix(before, after, next, policy, operator, before_comment,
|
|
|
695
695
|
|
|
696
696
|
in ts_binary.operator, ts_logical.operator, ts_assignment.operator, ts_equals, ts_question, ts_colon,
|
|
697
697
|
ts_union.structure_type_operators, ts_intersection.structure_type_operators rule es-operator-linebreak {
|
|
698
|
-
option mode "before" | "after" | "none" | null = null "operator side of a line break"
|
|
698
|
+
default option mode "before" | "after" | "none" | null = null "operator side of a line break"
|
|
699
699
|
option overrides { [key: string]: "before" | "after" | "none" | "ignore" } = {} "operator-specific placement"
|
|
700
700
|
when parent is (ts_binary, ts_logical, ts_assignment)
|
|
701
701
|
|| parent is (ts_conditional, ts_conditional_type) && contains(["?", ":"], text)
|
|
@@ -928,7 +928,7 @@ in ts_call rule es-newline-per-chained-call {
|
|
|
928
928
|
}
|
|
929
929
|
|
|
930
930
|
in ts_arrow.body rule es-implicit-arrow-linebreak {
|
|
931
|
-
option mode "beside" | "below" = "beside"
|
|
931
|
+
default option mode "beside" | "below" = "beside"
|
|
932
932
|
when not ts_block
|
|
933
933
|
let broken space_before.line_break
|
|
934
934
|
when mode == "beside" && broken || mode == "below" && !broken
|
|
@@ -946,7 +946,7 @@ in ts_arrow rule es-no-confusing-arrow {
|
|
|
946
946
|
}
|
|
947
947
|
|
|
948
948
|
in ts_if.consequent, ts_if.alternate, ts_while.body, ts_do_while.body, ts_for.body, ts_for_in.body, ts_for_of.body rule es-nonblock-statement-body-position {
|
|
949
|
-
option mode "beside" | "below" | "any" = "beside"
|
|
949
|
+
default option mode "beside" | "below" | "any" = "beside"
|
|
950
950
|
option overrides { if?: "beside" | "below" | "any"; else?: "beside" | "below" | "any"; while?: "beside" | "below" | "any"; do?: "beside" | "below" | "any"; for?: "beside" | "below" | "any" } = {} "position by statement"
|
|
951
951
|
let kind if parent is ts_if then (if is ts_if.alternate then "else" else "if") else if parent is ts_while then "while" else if parent is ts_do_while then "do" else "for"
|
|
952
952
|
let style {
|
package/std/ts/style/classes.dx
CHANGED
|
@@ -96,14 +96,14 @@ in ts_class let setter_member_names [] member.setter_member_name
|
|
|
96
96
|
in ts_method let literal_member_candidate kind == "get" && !contains([] modifier, "override") && body.first_member_literal && (member_static_name == null || !contains(parent.setter_member_names, member_static_name))
|
|
97
97
|
in ts_class_property let literal_member_candidate contains([] modifier, "readonly") && !contains([] modifier, "declare") && !contains([] modifier, "override") && init.member_literal == true && (member_static_name == null || !contains(parent.constructor_member_writes, member_static_name))
|
|
98
98
|
in ts_method.key rule es-class-literal-property-style {
|
|
99
|
-
option mode ("fields" | "getters") = "fields" "Preferred literal member declaration."
|
|
99
|
+
default option mode ("fields" | "getters") = "fields" "Preferred literal member declaration."
|
|
100
100
|
when mode == "fields" && parent.literal_member_candidate
|
|
101
101
|
let shape parent.style_member
|
|
102
102
|
report at { start: shape.key, end: shape.key_end }
|
|
103
103
|
warn "Literals should be exposed using readonly fields."
|
|
104
104
|
}
|
|
105
105
|
in ts_class_property.key rule es-class-literal-property-style:getters {
|
|
106
|
-
option mode ("fields" | "getters") = "fields" "Preferred literal member declaration."
|
|
106
|
+
default option mode ("fields" | "getters") = "fields" "Preferred literal member declaration."
|
|
107
107
|
when mode == "getters" && parent.literal_member_candidate
|
|
108
108
|
let shape parent.style_member
|
|
109
109
|
report at { start: shape.key, end: shape.key_end }
|
|
@@ -67,7 +67,7 @@ fn generic_constructor_replacement(source, owner, construction, annotation, mode
|
|
|
67
67
|
value { start: start, end: generics.end, text: ": " construction.name arguments between }
|
|
68
68
|
}
|
|
69
69
|
in ts_declarator, ts_class_property, ts_parameter rule es-consistent-generic-constructors {
|
|
70
|
-
option mode ("constructor" | "type-annotation") = "constructor" "Preferred location for generic arguments."
|
|
70
|
+
default option mode ("constructor" | "type-annotation") = "constructor" "Preferred location for generic arguments."
|
|
71
71
|
when not ts_parameter || parent is (ts_function, ts_method)
|
|
72
72
|
let construction init.constructor_arguments
|
|
73
73
|
let annotation type.annotation_arguments
|
|
@@ -187,7 +187,7 @@ in ts_method_signature, ts_property_signature let signature_report_end {
|
|
|
187
187
|
value if next != null && contains([";", ","], next.text) then next.end else end_offset
|
|
188
188
|
}
|
|
189
189
|
in ts_method_signature rule es-method-signature-style {
|
|
190
|
-
option mode ("method" | "property") = "property" "Preferred method signature notation."
|
|
190
|
+
default option mode ("method" | "property") = "property" "Preferred method signature notation."
|
|
191
191
|
when mode == "property" && kind != "get" && kind != "set"
|
|
192
192
|
report at { start: offset, end: signature_report_end }
|
|
193
193
|
warn "Shorthand method signature is forbidden. Use a function property instead."
|
|
@@ -195,7 +195,7 @@ in ts_method_signature rule es-method-signature-style {
|
|
|
195
195
|
fix at { start: replacement.start ?? offset, end: replacement.end ?? offset } if replacement != null as replacement.text
|
|
196
196
|
}
|
|
197
197
|
in ts_property_signature rule es-method-signature-style:property {
|
|
198
|
-
option mode ("method" | "property") = "property" "Preferred method signature notation."
|
|
198
|
+
default option mode ("method" | "property") = "property" "Preferred method signature notation."
|
|
199
199
|
when mode == "method" && type.is_function_type == true
|
|
200
200
|
report at { start: offset, end: signature_report_end }
|
|
201
201
|
warn "Function property signature is forbidden. Use a method shorthand instead."
|
package/std/ts/style/types.dx
CHANGED
|
@@ -370,28 +370,28 @@ fn indexed_notation_replacement(source, owner, info) = {
|
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
in ts_type_literal rule es-consistent-indexed-object-style {
|
|
373
|
-
option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
373
|
+
default option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
374
374
|
when mode == "record" && indexed_record_eligible
|
|
375
375
|
warn "A record is preferred over an index signature."
|
|
376
376
|
let replacement indexed_notation_replacement(source, node, indexed_conversion)
|
|
377
377
|
fix if replacement != null as replacement
|
|
378
378
|
}
|
|
379
379
|
in ts_interface rule es-consistent-indexed-object-style:interface {
|
|
380
|
-
option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
380
|
+
default option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
381
381
|
when mode == "record" && indexed_record_eligible
|
|
382
382
|
warn "A record is preferred over an index signature."
|
|
383
383
|
let replacement indexed_notation_replacement(source, node, indexed_conversion)
|
|
384
384
|
fix if replacement != null as replacement
|
|
385
385
|
}
|
|
386
386
|
in ts_mapped_type rule es-consistent-indexed-object-style:mapped {
|
|
387
|
-
option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
387
|
+
default option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
388
388
|
when mode == "record" && indexed_record_eligible
|
|
389
389
|
warn "A record is preferred over an index signature."
|
|
390
390
|
let replacement indexed_notation_replacement(source, node, indexed_conversion)
|
|
391
391
|
fix if replacement != null as replacement
|
|
392
392
|
}
|
|
393
393
|
in ts_type_reference rule es-consistent-indexed-object-style:record {
|
|
394
|
-
option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
394
|
+
default option mode ("record" | "index-signature") = "record" "Preferred indexed object notation."
|
|
395
395
|
when mode == "index-signature" && name == "Record" && count(type_argument) == 2
|
|
396
396
|
warn "An index signature is preferred over a record."
|
|
397
397
|
let replacement indexed_notation_replacement(source, node, indexed_conversion)
|
|
@@ -451,14 +451,14 @@ fn type_definition_type(source, n) = {
|
|
|
451
451
|
value if global_augmentation || open == null || header_end == null then null else type_definition_edit(source, start, close.end_offset, edits)
|
|
452
452
|
}
|
|
453
453
|
in ts_type_alias.name rule es-consistent-type-definitions {
|
|
454
|
-
option mode ("interface" | "type") = "interface" "Preferred object type definition."
|
|
454
|
+
default option mode ("interface" | "type") = "interface" "Preferred object type definition."
|
|
455
455
|
when mode == "interface" && parent.aliases_type_literal
|
|
456
456
|
warn "Use an `interface` instead of a `type`."
|
|
457
457
|
let edit type_definition_interface(source, parent.node)
|
|
458
458
|
fix at { start: edit.start ?? offset, end: edit.end ?? offset } if edit != null as edit.text
|
|
459
459
|
}
|
|
460
460
|
in ts_interface.name rule es-consistent-type-definitions:interface {
|
|
461
|
-
option mode ("interface" | "type") = "interface" "Preferred object type definition."
|
|
461
|
+
default option mode ("interface" | "type") = "interface" "Preferred object type definition."
|
|
462
462
|
when mode == "type"
|
|
463
463
|
warn "Use a `type` instead of an `interface`."
|
|
464
464
|
let edit type_definition_type(source, parent.node)
|
|
@@ -126,7 +126,7 @@ in ts_object rule es-accessor-pairs:descriptor {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
in ts_method, ts_method_signature rule es-grouped-accessor-pairs {
|
|
129
|
-
option mode ("anyOrder" | "getBeforeSet" | "setBeforeGet") = "anyOrder" "accessor order"
|
|
129
|
+
default option mode ("anyOrder" | "getBeforeSet" | "setBeforeGet") = "anyOrder" "accessor order"
|
|
130
130
|
option enforceForTSTypes boolean = false "check type accessors"
|
|
131
131
|
let group_info accessor_pair.grouping
|
|
132
132
|
when accessor_pair.scope != "type" || enforceForTSTypes
|
|
@@ -27,7 +27,7 @@ fn valid_radix(value) = value.type == "number" && value.value >= 2 && value.valu
|
|
|
27
27
|
fn invalid_radix(n) = n is ts_identifier && n.text == "undefined" && n.resolved == "global" || (n is (ts_number, ts_string, ts_boolean, ts_null, ts_regex, ts_bigint) || n is ts_unary && contains(["+", "-"], n.operator) && n.argument is ts_number) && !valid_radix(n.literal_value)
|
|
28
28
|
|
|
29
29
|
in ts_call rule es-radix {
|
|
30
|
-
option mode ("always" | "as-needed") = "always" "legacy radix policy"
|
|
30
|
+
default option mode ("always" | "as-needed") = "always" "legacy radix policy"
|
|
31
31
|
when parse_int_name != null
|
|
32
32
|
let argument_count count(argument)
|
|
33
33
|
let first_argument { value argument.nodes; first; unparenthesised_node }
|
|
@@ -28,7 +28,7 @@ fn comparison_fix(source, n) = {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
in ts_binary rule es-yoda {
|
|
31
|
-
option mode ("never" | "always") = "never" "literal comparison side"
|
|
31
|
+
default option mode ("never" | "always") = "never" "literal comparison side"
|
|
32
32
|
option exceptRange boolean = false "allow parenthesised ordered range checks"
|
|
33
33
|
option onlyEquality boolean = false "apply only to equality operators"
|
|
34
34
|
when contains(["==", "===", "!=", "!==", "<", ">", "<=", ">="], operator)
|
|
@@ -105,7 +105,7 @@ fn curly_replacement(source, n, block) = if !block then "{{" n.text "}}" else {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
@macro suggestion_curly_policy {
|
|
108
|
-
option mode ("all" | "multi" | "multi-line" | "multi-or-nest") = "all" "control body brace policy"
|
|
108
|
+
default option mode ("all" | "multi" | "multi-line" | "multi-or-nest") = "all" "control body brace policy"
|
|
109
109
|
option style ("consistent" | null) = null "consistent braces throughout if chains"
|
|
110
110
|
let curly_info curly_body_info(node, mode, style == "consistent")
|
|
111
111
|
when curly_info != null
|
|
@@ -48,7 +48,7 @@ fn strict_missing(n, scope, mode) =
|
|
|
48
48
|
else then []
|
|
49
49
|
}
|
|
50
50
|
in ts_program, ts_function, ts_arrow, ts_method rule es-strict {
|
|
51
|
-
option mode ("safe" | "never" | "global" | "function") = "safe" "strict directive policy"
|
|
51
|
+
default option mode ("safe" | "never" | "global" | "function") = "safe" "strict directive policy"
|
|
52
52
|
let strict_scope directive_scope
|
|
53
53
|
let strict_mode when {
|
|
54
54
|
ts_source_type(ts_module_program(node)) == "module" then "module"
|
|
@@ -218,7 +218,7 @@ fn assignment_fix_text(source, n, mode, shorthand) = {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
in ts_assignment rule es-operator-assignment {
|
|
221
|
-
option mode ("always" | "never") = "always" "compound arithmetic assignment policy"
|
|
221
|
+
default option mode ("always" | "never") = "always" "compound arithmetic assignment policy"
|
|
222
222
|
let assigned_key left.reference_key_strict
|
|
223
223
|
let shorthand if operator == "=" && right.arithmetic_operator != null && assigned_key != null && (assigned_key == right.strict_left_reference_key || contains(["*", "&", "^", "|"], right.arithmetic_operator) && assigned_key == right.strict_right_reference_key) then right.arithmetic_operator "=" else null
|
|
224
224
|
when if mode == "never" then operator != "=" && !contains(["&&=", "||=", "??="], operator) else shorthand != null
|
|
@@ -123,7 +123,7 @@ fn suggestion_function_style(n) = {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
in ts_function, ts_arrow rule es-func-style {
|
|
126
|
-
option style ("declaration" | "expression") = "expression" "function syntax policy"
|
|
126
|
+
default option style ("declaration" | "expression") = "expression" "function syntax policy"
|
|
127
127
|
option allowArrowFunctions boolean = false "allow arrow expressions"
|
|
128
128
|
option allowTypeAnnotation boolean = false "allow annotated function variables"
|
|
129
129
|
option overrides { namedExports: "" | "declaration" | "expression" | "ignore" } = { namedExports: "" } "named export policy"
|
|
@@ -136,7 +136,7 @@ in ts_function, ts_arrow rule es-func-style {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
in ts_assignment rule es-no-return-assign {
|
|
139
|
-
option mode ("except-parens" | "always") = "except-parens" "assignment return policy"
|
|
139
|
+
default option mode ("except-parens" | "always") = "except-parens" "assignment return policy"
|
|
140
140
|
let return_info return_assignment_context
|
|
141
141
|
when return_info != null && (mode == "always" || parent not ts_parenthesized)
|
|
142
142
|
report at return_info.offset
|
|
@@ -190,7 +190,7 @@ fn arrow_body_block_fix(source, n) = {
|
|
|
190
190
|
else { start: body.offset, end: body.end_offset, text: replacement }
|
|
191
191
|
}
|
|
192
192
|
in ts_arrow rule es-arrow-body-style {
|
|
193
|
-
option mode ("always" | "never" | "as-needed") = "as-needed" "arrow body block policy"
|
|
193
|
+
default option mode ("always" | "never" | "as-needed") = "as-needed" "arrow body block policy"
|
|
194
194
|
option requireReturnForObjectLiteral boolean = false "require a block for object values"
|
|
195
195
|
when body != null
|
|
196
196
|
let body_block body is ts_block
|
|
@@ -118,7 +118,7 @@ fn shorthand_member_fix(source, n, info, longform, method) =
|
|
|
118
118
|
} else n.value.text
|
|
119
119
|
|
|
120
120
|
in ts_property, ts_method rule es-object-shorthand {
|
|
121
|
-
option mode ("always" | "never" | "methods" | "properties" | "consistent" | "consistent-as-needed") = "always" "object shorthand policy"
|
|
121
|
+
default option mode ("always" | "never" | "methods" | "properties" | "consistent" | "consistent-as-needed") = "always" "object shorthand policy"
|
|
122
122
|
option avoidQuotes boolean = false "keep string-literal keys in long form"
|
|
123
123
|
option ignoreConstructors boolean = false "ignore capitalised method names"
|
|
124
124
|
option methodsIgnorePattern string = "" "method names to ignore"
|
|
@@ -139,7 +139,7 @@ in ts_property, ts_method rule es-object-shorthand {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
in ts_object rule es-object-shorthand:consistent {
|
|
142
|
-
option mode ("always" | "never" | "methods" | "properties" | "consistent" | "consistent-as-needed") = "always" "object shorthand policy"
|
|
142
|
+
default option mode ("always" | "never" | "methods" | "properties" | "consistent" | "consistent-as-needed") = "always" "object shorthand policy"
|
|
143
143
|
when mode == "consistent" || mode == "consistent-as-needed"
|
|
144
144
|
when shorthand_consistency == "mixed" || mode == "consistent-as-needed" && shorthand_consistency == "redundant"
|
|
145
145
|
warn if shorthand_consistency == "mixed" then "Unexpected mix of shorthand and non-shorthand properties." else "Expected shorthand for all properties."
|
|
@@ -74,7 +74,7 @@ fn return_await_selected(result, mode) = result.certainty == "never" && result.a
|
|
|
74
74
|
})
|
|
75
75
|
|
|
76
76
|
in ts_function, ts_arrow, ts_method rule es-return-await {
|
|
77
|
-
option mode ("always" | "error-handling-correctness-only" | "in-try-catch" | "never") = "in-try-catch" "Await policy for returned promises"
|
|
77
|
+
default option mode ("always" | "error-handling-correctness-only" | "in-try-catch" | "never") = "in-try-catch" "Await policy for returned promises"
|
|
78
78
|
when contains([] modifier, "async") && body != null
|
|
79
79
|
let owner node
|
|
80
80
|
let resources {
|
package/std/whitespace.dx
CHANGED
|
@@ -10,7 +10,7 @@ in .* layer text match trailing_whitespace /[ \t]+$/ {
|
|
|
10
10
|
|
|
11
11
|
in .* layer text match line_text /^[^\r\n]+/ {
|
|
12
12
|
rule shared-max-line-length warn "line is {len(text)} characters long (max {max})" {
|
|
13
|
-
option max int(1..) = 120 "maximum line length, in characters"
|
|
13
|
+
default option max int(1..) = 120 "maximum line length, in characters"
|
|
14
14
|
when len(text) > max
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -24,7 +24,7 @@ in .* layer text match tab_indent /^ *\t[ \t]*/ {
|
|
|
24
24
|
|
|
25
25
|
in .* layer text match blank_run /\n(?:[ \t]*\r?\n){2,}/ {
|
|
26
26
|
rule shared-blank-lines warn "at most {max} blank lines in a row" {
|
|
27
|
-
option max int(0..) = 2 "blank lines allowed in a row"
|
|
27
|
+
default option max int(0..) = 2 "blank lines allowed in a row"
|
|
28
28
|
when { value text; split "\n"; len } - 2 > max
|
|
29
29
|
fix as "\n" repeat("\n", max)
|
|
30
30
|
}
|