Skip to content

Commit 5aed0de

Browse files
committed
Fixed missing whitespaces between type ops
To check style we jsut run tslint To fix style we run tslint -> clang-format -> tslint
1 parent e14c271 commit 5aed0de

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"release-major": "npm version major",
2424
"preversion": "npm run build && npm test",
2525
"postversion": "git push && git push --tags",
26-
"style-check": "gts check",
27-
"style-fix": "gts fix"
26+
"style-check": "tslint -p .",
27+
"style-fix": "gts fix && tslint -p . --fix"
2828
},
2929
"bin": {
3030
"tstl": "./dist/index.js"

src/LuaAST.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ export enum SyntaxKind {
7676
}
7777

7878
// TODO maybe name this PrefixUnary? not sure it makes sense to do so, because all unary ops in Lua are prefix
79-
export type UnaryOperator = SyntaxKind.NegationOperator|SyntaxKind.LengthOperator|SyntaxKind.NotOperator|SyntaxKind.BitwiseNotOperator;
79+
export type UnaryOperator = SyntaxKind.NegationOperator | SyntaxKind.LengthOperator | SyntaxKind.NotOperator | SyntaxKind.BitwiseNotOperator;
8080

8181
export type BinaryOperator =
82-
SyntaxKind.AdditionOperator|SyntaxKind.SubractionOperator|SyntaxKind.MultiplicationOperator|SyntaxKind.DivisionOperator|
83-
SyntaxKind.FloorDivisionOperator|SyntaxKind.ModuloOperator|SyntaxKind.PowerOperator|SyntaxKind.ConcatOperator|
84-
SyntaxKind.EqualityOperator|SyntaxKind.InequalityOperator|SyntaxKind.LessThanOperator|SyntaxKind.LessEqualOperator|
85-
SyntaxKind.GreaterThanOperator|SyntaxKind.GreaterEqualOperator|SyntaxKind.AndOperator|SyntaxKind.OrOperator|
86-
SyntaxKind.BitwiseAndOperator|SyntaxKind.BitwiseOrOperator|SyntaxKind.BitwiseExclusiveOrOperator|
87-
SyntaxKind.BitwiseRightShiftOperator|SyntaxKind.BitwiseLeftShiftOperator|SyntaxKind.BitwiseNotOperator;
82+
SyntaxKind.AdditionOperator | SyntaxKind.SubractionOperator | SyntaxKind.MultiplicationOperator | SyntaxKind.DivisionOperator |
83+
SyntaxKind.FloorDivisionOperator | SyntaxKind.ModuloOperator | SyntaxKind.PowerOperator | SyntaxKind.ConcatOperator |
84+
SyntaxKind.EqualityOperator | SyntaxKind.InequalityOperator | SyntaxKind.LessThanOperator | SyntaxKind.LessEqualOperator |
85+
SyntaxKind.GreaterThanOperator | SyntaxKind.GreaterEqualOperator | SyntaxKind.AndOperator | SyntaxKind.OrOperator |
86+
SyntaxKind.BitwiseAndOperator | SyntaxKind.BitwiseOrOperator | SyntaxKind.BitwiseExclusiveOrOperator |
87+
SyntaxKind.BitwiseRightShiftOperator | SyntaxKind.BitwiseLeftShiftOperator | SyntaxKind.BitwiseNotOperator;
8888

89-
export type Operator = UnaryOperator|BinaryOperator;
89+
export type Operator = UnaryOperator | BinaryOperator;
9090

9191
// TODO For future sourcemap support?
9292
export interface TextRange {
@@ -109,7 +109,7 @@ export function createNode(kind: SyntaxKind, parent?: Node, tsOriginal?: ts.Node
109109
return {kind, parent, pos, end};
110110
}
111111

112-
export function setParent(node: Node|Node[]| undefined, parent: Node): void {
112+
export function setParent(node: Node | Node[] | undefined, parent: Node): void {
113113
if (!node) {
114114
return;
115115
}
@@ -178,8 +178,8 @@ export function isVariableDeclarationStatement(node: Node): node is VariableDecl
178178
}
179179

180180
export function createVariableDeclarationStatement(
181-
left: IdentifierOrTableIndexExpression|IdentifierOrTableIndexExpression[],
182-
right?: Expression|Expression[],
181+
left: IdentifierOrTableIndexExpression | IdentifierOrTableIndexExpression[],
182+
right?: Expression | Expression[],
183183
parent?: Node,
184184
tsOriginal?: ts.Node): VariableDeclarationStatement {
185185
const statement = createNode(SyntaxKind.VariableDeclarationStatement, parent, tsOriginal) as VariableDeclarationStatement;
@@ -210,8 +210,8 @@ export function isAssignmentStatement(node: Node): node is AssignmentStatement {
210210
}
211211

212212
export function createAssignmentStatement(
213-
left: IdentifierOrTableIndexExpression|IdentifierOrTableIndexExpression[],
214-
right: Expression| Expression[],
213+
left: IdentifierOrTableIndexExpression | IdentifierOrTableIndexExpression[],
214+
right: Expression | Expression[],
215215
parent?: Node,
216216
tsOriginal?: ts.Node): AssignmentStatement {
217217
const statement = createNode(SyntaxKind.AssignmentStatement, parent, tsOriginal) as AssignmentStatement;
@@ -234,15 +234,15 @@ export interface IfStatement extends Statement {
234234
kind: SyntaxKind.IfStatement;
235235
condtion: Expression;
236236
ifBlock: Block;
237-
elseBlock?: Block|IfStatement;
237+
elseBlock?: Block | IfStatement;
238238
}
239239

240240
export function isIfStatement(node: Node): node is IfStatement {
241241
return node.kind === SyntaxKind.IfStatement;
242242
}
243243

244244
export function createIfStatement(
245-
condtion: Expression, ifBlock: Block, elseBlock?: Block|IfStatement, parent?: Node, tsOriginal?: ts.Node): IfStatement {
245+
condtion: Expression, ifBlock: Block, elseBlock?: Block | IfStatement, parent?: Node, tsOriginal?: ts.Node): IfStatement {
246246
const statement = createNode(SyntaxKind.IfStatement, parent, tsOriginal) as IfStatement;
247247
setParent(condtion, statement);
248248
statement.condtion = condtion;
@@ -448,7 +448,7 @@ export function createNilLiteral(parent?: Node, tsOriginal?: ts.Node): NilLitera
448448
}
449449

450450
export interface BooleanLiteral extends Expression {
451-
kind: SyntaxKind.TrueKeyword|SyntaxKind.FalseKeyword;
451+
kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword;
452452
}
453453

454454
export function isBooleanLiteral(node: Node): node is BooleanLiteral {
@@ -715,4 +715,4 @@ export function createTableIndexExpression(
715715
return expression;
716716
}
717717

718-
export type IdentifierOrTableIndexExpression = Identifier|TableIndexExpression;
718+
export type IdentifierOrTableIndexExpression = Identifier | TableIndexExpression;

src/LuaTransformer.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {LuaLibFeature} from "./LuaLib";
88
import {ContextType, TSHelper as tsHelper} from "./TSHelper";
99
import {TSTLErrors} from "./TSTLErrors";
1010

11-
type StatementVisitResult = tstl.Statement|tstl.Statement[]|undefined;
12-
type ExpressionVisitResult = tstl.Expression|undefined;
11+
type StatementVisitResult = tstl.Statement | tstl.Statement[] | undefined;
12+
type ExpressionVisitResult = tstl.Expression | undefined;
1313

1414
export enum ScopeType {
1515
Function,
@@ -138,7 +138,7 @@ export class LuaTransformer {
138138
}
139139

140140
/** Convers an array of ts.Statements into an array of tstl.Statements */
141-
public transformStatements(statements: ts.Statement[]| ReadonlyArray<ts.Statement>): tstl.Statement[] {
141+
public transformStatements(statements: ts.Statement[] | ReadonlyArray<ts.Statement>): tstl.Statement[] {
142142
const tstlStatements: tstl.Statement[] = [];
143143
(statements as ts.Statement[]).forEach(statement => {
144144
tstlStatements.push(...this.statementVisitResultToStatementArray(this.transformStatement(statement)));
@@ -558,7 +558,7 @@ export class LuaTransformer {
558558
}
559559

560560
public transformParameters(parameters: ts.NodeArray<ts.ParameterDeclaration>, context?: tstl.Identifier):
561-
[tstl.Identifier[], tstl.DotsLiteral, tstl.Identifier|undefined] {
561+
[tstl.Identifier[], tstl.DotsLiteral, tstl.Identifier | undefined] {
562562
// Build parameter string
563563
const paramNames: tstl.Identifier[] = [];
564564
if (context) {
@@ -744,8 +744,8 @@ export class LuaTransformer {
744744
}
745745

746746
public computeEnumMembers(node: ts.EnumDeclaration):
747-
Array<{name: ts.PropertyName, value: tstl.NumericLiteral|tstl.StringLiteral, original: ts.Node}> {
748-
let val: tstl.NumericLiteral|tstl.StringLiteral;
747+
Array<{name: ts.PropertyName, value: tstl.NumericLiteral | tstl.StringLiteral, original: ts.Node}> {
748+
let val: tstl.NumericLiteral | tstl.StringLiteral;
749749
let hasStringInitializers = false;
750750

751751
return node.members.map(member => {
@@ -856,7 +856,7 @@ export class LuaTransformer {
856856
return result;
857857
}
858858

859-
public transformExpressionStatement(statement: ts.ExpressionStatement|ts.Expression): tstl.Statement {
859+
public transformExpressionStatement(statement: ts.ExpressionStatement | ts.Expression): tstl.Statement {
860860
const expression = ts.isExpressionStatement(statement) ? statement.expression : statement;
861861
if (ts.isBinaryExpression(expression)) {
862862
const [isCompound, replacementOperator] = tsHelper.isBinaryAssignmentToken(expression.operatorToken.kind);
@@ -1491,7 +1491,7 @@ export class LuaTransformer {
14911491
return tstl.createTableExpression(properties, undefined, node);
14921492
}
14931493

1494-
public transformFunctionExpression(node: ts.FunctionLikeDeclaration, context: tstl.Identifier|undefined): ExpressionVisitResult {
1494+
public transformFunctionExpression(node: ts.FunctionLikeDeclaration, context: tstl.Identifier | undefined): ExpressionVisitResult {
14951495
const type = this.checker.getTypeAtLocation(node);
14961496
const hasContext = tsHelper.getFunctionContextType(type, this.checker) !== ContextType.Void;
14971497
// Build parameter string
@@ -2158,7 +2158,7 @@ export class LuaTransformer {
21582158
this.luaLibFeatureSet.add(feature);
21592159
}
21602160

2161-
public createImmediatelyInvokedFunctionExpression(statements: tstl.Statement[], result: tstl.Expression|tstl.Expression[]):
2161+
public createImmediatelyInvokedFunctionExpression(statements: tstl.Statement[], result: tstl.Expression | tstl.Expression[]):
21622162
tstl.CallExpression {
21632163
const body = statements ? statements.slice(0) : [];
21642164
body.push(tstl.createReturnStatement(Array.isArray(result) ? result : [result]));

src/TSHelper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class TSHelper {
5656
return result;
5757
}
5858

59-
public static getExtendedType(node: ts.ClassLikeDeclarationBase, checker: ts.TypeChecker): ts.Type|undefined {
59+
public static getExtendedType(node: ts.ClassLikeDeclarationBase, checker: ts.TypeChecker): ts.Type | undefined {
6060
if (node && node.heritageClauses) {
6161
for (const clause of node.heritageClauses) {
6262
if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
@@ -83,7 +83,7 @@ export class TSHelper {
8383
return false;
8484
}
8585

86-
public static isIdentifierExported(identifier: ts.Identifier, scope: ts.ModuleDeclaration|ts.SourceFile, checker: ts.TypeChecker):
86+
public static isIdentifierExported(identifier: ts.Identifier, scope: ts.ModuleDeclaration | ts.SourceFile, checker: ts.TypeChecker):
8787
boolean {
8888
const identifierSymbol = checker.getTypeAtLocation(scope).getSymbol();
8989
if (identifierSymbol.exports)
@@ -305,7 +305,7 @@ export class TSHelper {
305305
node.operator !== ts.SyntaxKind.PlusToken && node.operator !== ts.SyntaxKind.TildeToken;
306306
}
307307

308-
public static getUnaryCompoundAssignmentOperator(node: ts.PrefixUnaryExpression|ts.PostfixUnaryExpression): ts.BinaryOperator {
308+
public static getUnaryCompoundAssignmentOperator(node: ts.PrefixUnaryExpression | ts.PostfixUnaryExpression): ts.BinaryOperator {
309309
switch (node.operator) {
310310
case ts.SyntaxKind.PlusPlusToken:
311311
return ts.SyntaxKind.PlusToken;

tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"ban-keywords",
7676
"allow-leading-underscore",
7777
"allow-pascal-case"
78-
]
78+
],
79+
"whitespace": [true, "check-type-operator", "check-decl", "check-rest-spread", "check-typecast"]
7980
},
8081
"rulesDirectory": []
8182
}

0 commit comments

Comments
 (0)