1
1
import * as _ from "lodash" ;
2
2
3
+ const maxLineLength = 150 ;
4
+
3
5
function indent ( line : string ) : string { return line === "" ? "" : " " + line ; }
4
6
5
7
export abstract class CodeElement {
@@ -46,7 +48,7 @@ export class FnCall extends CodeElement implements Expression {
46
48
argInLines [ argInLines . length - 1 ] += "," ;
47
49
}
48
50
const oneLine = this . fnName + "(" + argsInLines . join ( " " ) + ")" ;
49
- if ( oneLine . length < 80 )
51
+ if ( oneLine . length < maxLineLength )
50
52
return [ oneLine ] ;
51
53
return [
52
54
this . fnName + "(" ,
@@ -74,7 +76,7 @@ export class BraceInitialiser extends CodeElement implements Expression {
74
76
argInLines [ argInLines . length - 1 ] += "," ;
75
77
}
76
78
const oneLine = this . typename + " { " + argsInLines . join ( " " ) + " }" ;
77
- if ( oneLine . length < 80 )
79
+ if ( oneLine . length < maxLineLength )
78
80
return [ oneLine ] ;
79
81
return [
80
82
this . typename + " {" ,
@@ -138,7 +140,7 @@ export class Assignment extends CodeElement implements Statement {
138
140
rhsInLines [ rhsInLines . length - 1 ] += ";" ;
139
141
if ( rhsInLines . length === 1 ) {
140
142
const oneLine = this . lhs + " = " + rhsInLines [ 0 ] ;
141
- if ( oneLine . length < 100 )
143
+ if ( oneLine . length < maxLineLength )
142
144
return [ oneLine ] ;
143
145
}
144
146
return [
@@ -169,15 +171,15 @@ export class Declaration extends CodeElement implements Statement, Member {
169
171
rhsInLines [ rhsInLines . length - 1 ] += ";" ;
170
172
const name = this . name + ( rhsInLines . length === 0 ? ";" : " =" ) ;
171
173
const oneLineLhs = `${ this . modifiedType } ${ name } ` ;
172
- if ( oneLineLhs . length >= 80 )
174
+ if ( oneLineLhs . length >= maxLineLength )
173
175
return [
174
176
this . modifiedType ,
175
177
indent ( name ) ,
176
178
...rhsInLines . map ( ( arg ) => indent ( indent ( arg ) ) ) ,
177
179
] ;
178
180
if ( rhsInLines . length <= 1 ) {
179
181
const oneLine = rhsInLines . length === 0 ? oneLineLhs : `${ oneLineLhs } ${ rhsInLines [ 0 ] } ` ;
180
- if ( oneLine . length < 80 )
182
+ if ( oneLine . length < maxLineLength )
181
183
return [ oneLine ] ;
182
184
}
183
185
return [
@@ -203,7 +205,7 @@ export class Return extends CodeElement implements Statement {
203
205
valueInLines [ valueInLines . length - 1 ] += ";" ;
204
206
if ( valueInLines . length === 1 ) {
205
207
const oneLine = "return " + valueInLines [ 0 ] ;
206
- if ( oneLine . length < 100 )
208
+ if ( oneLine . length < maxLineLength )
207
209
return [ oneLine ] ;
208
210
}
209
211
return [
0 commit comments