Skip to content

Commit 1f3a981

Browse files
committed
Set "arrowParens" option to "always"
1 parent 375e009 commit 1f3a981

File tree

97 files changed

+396
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+396
-384
lines changed

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"tabWidth": 4,
44
"trailingComma": "es5",
55
"endOfLine": "lf",
6-
"overrides": [{ "files": ["**/*.md", "**/*.yml"], "options": { "tabWidth": 2 } }]
6+
"overrides": [{ "files": ["**/*.md", "**/*.yml"], "options": { "tabWidth": 2 } }],
7+
"arrowParens": "always"
78
}

src/LuaPrinter.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const escapeStringMap: Record<string, string> = {
2323
"\0": "\\0",
2424
};
2525

26-
export const escapeString = (value: string) => `"${value.replace(escapeStringRegExp, char => escapeStringMap[char])}"`;
26+
export const escapeString = (value: string) =>
27+
`"${value.replace(escapeStringRegExp, (char) => escapeStringMap[char])}"`;
2728

2829
/**
2930
* Checks that a name is valid for use in lua function declaration syntax:
@@ -45,7 +46,7 @@ function isSimpleExpression(expression: lua.Expression): boolean {
4546

4647
case lua.SyntaxKind.TableExpression:
4748
const tableExpression = expression as lua.TableExpression;
48-
return tableExpression.fields.every(e => isSimpleExpression(e));
49+
return tableExpression.fields.every((e) => isSimpleExpression(e));
4950

5051
case lua.SyntaxKind.TableFieldExpression:
5152
const fieldExpression = expression as lua.TableFieldExpression;
@@ -271,7 +272,7 @@ export class LuaPrinter {
271272

272273
private nodeStartsWithParenthesis(sourceNode: SourceNode): boolean {
273274
let result: boolean | undefined;
274-
sourceNode.walk(chunk => {
275+
sourceNode.walk((chunk) => {
275276
if (result === undefined) {
276277
chunk = chunk.trimLeft(); // Ignore leading whitespace
277278

@@ -358,11 +359,11 @@ export class LuaPrinter {
358359
// Print all local functions as `local function foo()` instead of `local foo = function` to allow recursion
359360
chunks.push(this.printFunctionDefinition(statement));
360361
} else {
361-
chunks.push(...this.joinChunksWithComma(statement.left.map(e => this.printExpression(e))));
362+
chunks.push(...this.joinChunksWithComma(statement.left.map((e) => this.printExpression(e))));
362363

363364
if (statement.right) {
364365
chunks.push(" = ");
365-
chunks.push(...this.joinChunksWithComma(statement.right.map(e => this.printExpression(e))));
366+
chunks.push(...this.joinChunksWithComma(statement.right.map((e) => this.printExpression(e))));
366367
}
367368
}
368369

@@ -386,9 +387,9 @@ export class LuaPrinter {
386387
}
387388
}
388389

389-
chunks.push(...this.joinChunksWithComma(statement.left.map(e => this.printExpression(e))));
390+
chunks.push(...this.joinChunksWithComma(statement.left.map((e) => this.printExpression(e))));
390391
chunks.push(" = ");
391-
chunks.push(...this.joinChunksWithComma(statement.right.map(e => this.printExpression(e))));
392+
chunks.push(...this.joinChunksWithComma(statement.right.map((e) => this.printExpression(e))));
392393

393394
return this.createSourceNode(statement, chunks);
394395
}
@@ -472,8 +473,8 @@ export class LuaPrinter {
472473
}
473474

474475
public printForInStatement(statement: lua.ForInStatement): SourceNode {
475-
const names = this.joinChunksWithComma(statement.names.map(i => this.printIdentifier(i)));
476-
const expressions = this.joinChunksWithComma(statement.expressions.map(e => this.printExpression(e)));
476+
const names = this.joinChunksWithComma(statement.names.map((i) => this.printIdentifier(i)));
477+
const expressions = this.joinChunksWithComma(statement.expressions.map((e) => this.printExpression(e)));
477478

478479
const chunks: SourceChunk[] = [];
479480

@@ -502,7 +503,7 @@ export class LuaPrinter {
502503

503504
const chunks: SourceChunk[] = [];
504505

505-
chunks.push(...this.joinChunksWithComma(statement.expressions.map(e => this.printExpression(e))));
506+
chunks.push(...this.joinChunksWithComma(statement.expressions.map((e) => this.printExpression(e))));
506507

507508
return this.createSourceNode(statement, [this.indent(), "return ", ...chunks]);
508509
}
@@ -573,7 +574,7 @@ export class LuaPrinter {
573574
}
574575

575576
private printFunctionParameters(expression: lua.FunctionExpression): SourceChunk[] {
576-
const parameterChunks = (expression.params ?? []).map(i => this.printIdentifier(i));
577+
const parameterChunks = (expression.params ?? []).map((i) => this.printIdentifier(i));
577578

578579
if (expression.dots) {
579580
parameterChunks.push(this.printDotsLiteral(expression.dots));
@@ -594,7 +595,7 @@ export class LuaPrinter {
594595
chunks.push(" ");
595596
const returnNode: SourceChunk[] = [
596597
"return ",
597-
...this.joinChunksWithComma(returnStatement.expressions.map(e => this.printExpression(e))),
598+
...this.joinChunksWithComma(returnStatement.expressions.map((e) => this.printExpression(e))),
598599
];
599600
chunks.push(this.createSourceNode(returnStatement, returnNode));
600601
chunks.push(this.createSourceNode(expression, " end"));
@@ -750,7 +751,7 @@ export class LuaPrinter {
750751
const chunks: SourceChunk[] = [];
751752

752753
if (expressions.every(isSimpleExpression)) {
753-
chunks.push(...this.joinChunksWithComma(expressions.map(e => this.printExpression(e))));
754+
chunks.push(...this.joinChunksWithComma(expressions.map((e) => this.printExpression(e))));
754755
} else {
755756
chunks.push("\n");
756757
this.pushIndent();

src/cli/information.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function getHelpString(): string {
1919

2020
result += "Options:\n";
2121
for (const option of optionDeclarations) {
22-
const aliasStrings = (option.aliases ?? []).map(a => "-" + a);
22+
const aliasStrings = (option.aliases ?? []).map((a) => "-" + a);
2323
const optionString = [...aliasStrings, "--" + option.name].join("|");
2424

2525
const valuesHint = option.type === "enum" ? option.choices.join("|") : option.type;

src/cli/parse.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const optionDeclarations: CommandLineOption[] = [
7272
export function updateParsedConfigFile(parsedConfigFile: ts.ParsedCommandLine): ParsedCommandLine {
7373
let hasRootLevelOptions = false;
7474
for (const [name, rawValue] of Object.entries(parsedConfigFile.raw)) {
75-
const option = optionDeclarations.find(option => option.name === name);
75+
const option = optionDeclarations.find((option) => option.name === name);
7676
if (!option) continue;
7777

7878
if (parsedConfigFile.raw.tstl === undefined) parsedConfigFile.raw.tstl = {};
@@ -86,7 +86,7 @@ export function updateParsedConfigFile(parsedConfigFile: ts.ParsedCommandLine):
8686
}
8787

8888
for (const [name, rawValue] of Object.entries(parsedConfigFile.raw.tstl)) {
89-
const option = optionDeclarations.find(option => option.name === name);
89+
const option = optionDeclarations.find((option) => option.name === name);
9090
if (!option) {
9191
parsedConfigFile.errors.push(cliDiagnostics.unknownCompilerOption(name));
9292
continue;
@@ -111,10 +111,10 @@ function updateParsedCommandLine(parsedCommandLine: ts.ParsedCommandLine, args:
111111

112112
const isShorthand = !args[i].startsWith("--");
113113
const argumentName = args[i].substr(isShorthand ? 1 : 2);
114-
const option = optionDeclarations.find(option => {
114+
const option = optionDeclarations.find((option) => {
115115
if (option.name.toLowerCase() === argumentName.toLowerCase()) return true;
116116
if (isShorthand && option.aliases) {
117-
return option.aliases.some(a => a.toLowerCase() === argumentName.toLowerCase());
117+
return option.aliases.some((a) => a.toLowerCase() === argumentName.toLowerCase());
118118
}
119119

120120
return false;
@@ -124,7 +124,7 @@ function updateParsedCommandLine(parsedCommandLine: ts.ParsedCommandLine, args:
124124
// Ignore errors caused by tstl specific compiler options
125125
const tsInvalidCompilerOptionErrorCode = 5023;
126126
parsedCommandLine.errors = parsedCommandLine.errors.filter(
127-
e => !(e.code === tsInvalidCompilerOptionErrorCode && String(e.messageText).endsWith(`'${args[i]}'.`))
127+
(e) => !(e.code === tsInvalidCompilerOptionErrorCode && String(e.messageText).endsWith(`'${args[i]}'.`))
128128
);
129129

130130
const { error, value, increment } = readCommandLineArgument(option, args[i + 1]);
@@ -192,7 +192,7 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
192192
};
193193
}
194194

195-
const enumValue = option.choices.find(c => c.toLowerCase() === value.toLowerCase());
195+
const enumValue = option.choices.find((c) => c.toLowerCase() === value.toLowerCase());
196196
if (enumValue === undefined) {
197197
const optionChoices = option.choices.join(", ");
198198
return {

src/cli/report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export const prepareDiagnosticForFormatting = (diagnostic: ts.Diagnostic) =>
55

66
export function createDiagnosticReporter(pretty: boolean, system = ts.sys): ts.DiagnosticReporter {
77
const reporter = ts.createDiagnosticReporter(system, pretty);
8-
return diagnostic => reporter(prepareDiagnosticForFormatting(diagnostic));
8+
return (diagnostic) => reporter(prepareDiagnosticForFormatting(diagnostic));
99
}

src/cli/tsconfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function createConfigFileUpdater(
5656
optionsToExtend: CompilerOptions
5757
): (options: ts.CompilerOptions) => ts.Diagnostic[] {
5858
const configFileMap = new WeakMap<ts.TsConfigSourceFile, ts.ParsedCommandLine>();
59-
return options => {
59+
return (options) => {
6060
const { configFile, configFilePath } = options;
6161
if (!configFile || !configFilePath) return [];
6262

src/lualib/StringReplace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function __TS__StringReplace(
1414
const [result] = string.gsub(
1515
source,
1616
searchValue,
17-
match => (replaceValue as (substring: string) => string)(match),
17+
(match) => (replaceValue as (substring: string) => string)(match),
1818
1
1919
);
2020
return result;

src/transformation/context/context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class TransformationContext {
5454
public transformNode(node: ts.Node, isExpression?: boolean): lua.Node[];
5555
public transformNode(node: ts.Node, isExpression?: boolean): lua.Node[] {
5656
// TODO: Move to visitors?
57-
if (node.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.DeclareKeyword)) {
57+
if (node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.DeclareKeyword)) {
5858
return [];
5959
}
6060

@@ -105,10 +105,10 @@ export class TransformationContext {
105105
}
106106

107107
public transformStatements(node: StatementLikeNode | readonly StatementLikeNode[]): lua.Statement[] {
108-
return castArray(node).flatMap(n => this.transformNode(n) as lua.Statement[]);
108+
return castArray(node).flatMap((n) => this.transformNode(n) as lua.Statement[]);
109109
}
110110

111111
public superTransformStatements(node: StatementLikeNode | readonly StatementLikeNode[]): lua.Statement[] {
112-
return castArray(node).flatMap(n => this.superTransformNode(n) as lua.Statement[]);
112+
return castArray(node).flatMap((n) => this.superTransformNode(n) as lua.Statement[]);
113113
}
114114
}

src/transformation/utils/annotations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface Annotation {
2525
}
2626

2727
function createAnnotation(name: string, args: string[]): Annotation | undefined {
28-
const kind = Object.values(AnnotationKind).find(k => k.toLowerCase() === name.toLowerCase());
28+
const kind = Object.values(AnnotationKind).find((k) => k.toLowerCase() === name.toLowerCase());
2929
if (kind !== undefined) {
3030
return { kind, args };
3131
}
@@ -78,7 +78,7 @@ export function getFileAnnotations(sourceFile: ts.SourceFile): AnnotationsMap {
7878
// Manually collect jsDoc because `getJSDocTags` includes tags only from closest comment
7979
const jsDoc = sourceFile.statements[0].jsDoc;
8080
if (jsDoc) {
81-
for (const tag of jsDoc.flatMap(x => x.tags ?? [])) {
81+
for (const tag of jsDoc.flatMap((x) => x.tags ?? [])) {
8282
const tagName = tag.tagName.text;
8383
const annotation = createAnnotation(tagName, tag.comment ? tag.comment.split(" ") : []);
8484
if (annotation) {
@@ -157,7 +157,7 @@ export function isInTupleReturnFunction(context: TransformationContext, node: ts
157157

158158
// Check all overloads for directive
159159
const signatures = functionType.getCallSignatures();
160-
if (signatures?.some(s => getSignatureAnnotations(context, s).has(AnnotationKind.TupleReturn))) {
160+
if (signatures?.some((s) => getSignatureAnnotations(context, s).has(AnnotationKind.TupleReturn))) {
161161
return true;
162162
}
163163

src/transformation/utils/export.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getSymbolInfo } from "./symbols";
77
import { findFirstNodeAbove } from "./typescript";
88

99
export function hasDefaultExportModifier(node: ts.Node): boolean {
10-
return (node.modifiers ?? []).some(modifier => modifier.kind === ts.SyntaxKind.DefaultKeyword);
10+
return (node.modifiers ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword);
1111
}
1212

1313
export const createDefaultExportIdentifier = (original: ts.Node): lua.Identifier =>
@@ -19,7 +19,7 @@ export const createDefaultExportStringLiteral = (original: ts.Node): lua.StringL
1919
export function getExportedSymbolDeclaration(symbol: ts.Symbol): ts.Declaration | undefined {
2020
const declarations = symbol.getDeclarations();
2121
if (declarations) {
22-
return declarations.find(d => (ts.getCombinedModifierFlags(d) & ts.ModifierFlags.Export) !== 0);
22+
return declarations.find((d) => (ts.getCombinedModifierFlags(d) & ts.ModifierFlags.Export) !== 0);
2323
}
2424
}
2525

@@ -94,7 +94,7 @@ export function getExportedSymbolsFromScope(
9494
}
9595

9696
export function getDependenciesOfSymbol(context: TransformationContext, originalSymbol: ts.Symbol): ts.Symbol[] {
97-
return getExportedSymbolsFromScope(context, context.sourceFile).filter(exportSymbol =>
97+
return getExportedSymbolsFromScope(context, context.sourceFile).filter((exportSymbol) =>
9898
exportSymbol.declarations
9999
.filter(ts.isExportSpecifier)
100100
.map(context.checker.getExportSpecifierLocalTargetSymbol)

0 commit comments

Comments
 (0)