@ttsc/lint 0.30.0 → 0.30.2

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.
@@ -200,6 +200,13 @@ func (formatPrintWidth) Check(ctx *Context, node *shimast.Node) {
200
200
  return
201
201
  }
202
202
 
203
+ // The header and an unbraced body share a layout the control-flow printer
204
+ // preserves verbatim. Reflowing either fragment independently lets its
205
+ // changing columns reverse the other fragment's decision on the next pass.
206
+ if hasUnbracedControlFlowAncestor(node) {
207
+ return
208
+ }
209
+
203
210
  // Abstain on any node nested inside a template-literal substitution.
204
211
  // Prettier renders `${…}` expressions at printWidth:Infinity, it
205
212
  // never breaks an interpolation the source wrote on one line, so
@@ -543,6 +550,35 @@ func hasUncontrolledBinaryExpressionAncestor(node *shimast.Node) bool {
543
550
  return false
544
551
  }
545
552
 
553
+ // hasUnbracedControlFlowAncestor keeps both the header and body of an
554
+ // unsupported control-flow layout intact. A block is a layout boundary: calls
555
+ // inside a braced body can reflow even below an outer unbraced statement.
556
+ func hasUnbracedControlFlowAncestor(node *shimast.Node) bool {
557
+ for parent := node.Parent; parent != nil; parent = parent.Parent {
558
+ if parent.Kind == shimast.KindBlock {
559
+ return false
560
+ }
561
+ var body *shimast.Node
562
+ switch parent.Kind {
563
+ case shimast.KindIfStatement:
564
+ if _, supported := printableIfChildren(parent); !supported {
565
+ return true
566
+ }
567
+ case shimast.KindForStatement, shimast.KindForInStatement,
568
+ shimast.KindForOfStatement, shimast.KindWhileStatement:
569
+ body = singleControlFlowBody(parent)
570
+ case shimast.KindDoStatement:
571
+ body = parent.AsDoStatement().Statement
572
+ case shimast.KindWithStatement:
573
+ body = parent.AsWithStatement().Statement
574
+ }
575
+ if body != nil && body.Kind != shimast.KindBlock {
576
+ return true
577
+ }
578
+ }
579
+ return false
580
+ }
581
+
546
582
  // hasTemplateSubstitutionAncestor reports whether `node` sits inside a
547
583
  // template-literal substitution (`${…}`). formatPrintWidth abstains
548
584
  // on such nodes: Prettier prints template interpolations at infinite
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/lint",
3
- "version": "0.30.0",
3
+ "version": "0.30.2",
4
4
  "description": "Reference ttsc plugin: ESLint-style lint rules over the TypeScript-Go Program used by the type-check pass.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "@types/node": "^25.3.0",
38
38
  "rimraf": "^6.1.2",
39
39
  "typescript": "^7.0.2",
40
- "ttsc": "0.30.0"
40
+ "ttsc": "0.30.2"
41
41
  },
42
42
  "repository": {
43
43
  "type": "git",