Skip to content

Commit 66e7c98

Browse files
committed
Enable quotes rule
1 parent d3f63db commit 66e7c98

27 files changed

+137
-138
lines changed

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ module.exports = {
105105
// TODO: https://github.com/typescript-eslint/typescript-eslint/issues/1265
106106
// "@typescript-eslint/prefer-nullish-coalescing": "error",
107107
"@typescript-eslint/prefer-readonly": "off",
108-
// "@typescript-eslint/quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: false }],
109-
"@typescript-eslint/quotes": "off",
108+
"@typescript-eslint/quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: false }],
110109
"@typescript-eslint/require-array-sort-compare": "off",
111110
"@typescript-eslint/camelcase": "off",
112111

src/LuaPrinter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class LuaPrinter {
191191
let header = "";
192192

193193
if (!this.options.noHeader) {
194-
header += `--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]\n`;
194+
header += "--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]\n";
195195
}
196196

197197
const luaLibImport = this.options.luaLibImport ?? LuaLibImportKind.Require;
@@ -200,7 +200,7 @@ export class LuaPrinter {
200200
(luaLibImport === LuaLibImportKind.Require && luaLibFeatures.size > 0)
201201
) {
202202
// Require lualib bundle
203-
header += `require("lualib_bundle");\n`;
203+
header += 'require("lualib_bundle");\n';
204204
} else if (luaLibImport === LuaLibImportKind.Inline && luaLibFeatures.size > 0) {
205205
// Inline lualib features
206206
header += "-- Lua Library inline imports\n";
@@ -443,7 +443,7 @@ export class LuaPrinter {
443443
public printRepeatStatement(statement: lua.RepeatStatement): SourceNode {
444444
const chunks: SourceChunk[] = [];
445445

446-
chunks.push(this.indent(`repeat\n`));
446+
chunks.push(this.indent("repeat\n"));
447447

448448
this.pushIndent();
449449
chunks.push(this.printBlock(statement.body));

src/transformation/utils/diagnostics.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ const createDiagnosticFactory = <TArgs extends any[]>(message: string | ((...arg
1111
messageText: typeof message === "string" ? message : message(...args),
1212
}));
1313

14-
export const forbiddenForIn = createDiagnosticFactory(`Iterating over arrays with 'for ... in' is not allowed.`);
14+
export const forbiddenForIn = createDiagnosticFactory("Iterating over arrays with 'for ... in' is not allowed.");
1515

1616
export const unsupportedNoSelfFunctionConversion = createDiagnosticFactory((name?: string) => {
1717
const nameReference = name ? ` '${name}'` : "";
1818
return (
1919
`Unable to convert function with a 'this' parameter to function${nameReference} with no 'this'. ` +
20-
`To fix, wrap in an arrow function, or declare with 'this: void'.`
20+
"To fix, wrap in an arrow function, or declare with 'this: void'."
2121
);
2222
});
2323

2424
export const unsupportedSelfFunctionConversion = createDiagnosticFactory((name?: string) => {
2525
const nameReference = name ? ` '${name}'` : "";
2626
return (
2727
`Unable to convert function with no 'this' parameter to function${nameReference} with 'this'. ` +
28-
`To fix, wrap in an arrow function, or declare with 'this: any'.`
28+
"To fix, wrap in an arrow function, or declare with 'this: any'."
2929
);
3030
});
3131

@@ -37,7 +37,7 @@ export const unsupportedOverloadAssignment = createDiagnosticFactory((name?: str
3737
);
3838
});
3939

40-
export const decoratorInvalidContext = createDiagnosticFactory(`Decorator function cannot have 'this: void'.`);
40+
export const decoratorInvalidContext = createDiagnosticFactory("Decorator function cannot have 'this: void'.");
4141

4242
export const annotationInvalidArgumentCount = createDiagnosticFactory(
4343
(kind: AnnotationKind, got: number, expected: number) => `'@${kind}' expects ${expected} arguments, but got ${got}.`
@@ -48,23 +48,23 @@ export const extensionCannotConstruct = createDiagnosticFactory(
4848
);
4949

5050
export const extensionCannotExtend = createDiagnosticFactory(
51-
`Cannot extend classes with '@extension' or '@metaExtension' annotation.`
51+
"Cannot extend classes with '@extension' or '@metaExtension' annotation."
5252
);
5353

5454
export const extensionCannotExport = createDiagnosticFactory(
55-
`Cannot export classes with '@extension' or '@metaExtension' annotation.`
55+
"Cannot export classes with '@extension' or '@metaExtension' annotation."
5656
);
5757

5858
export const extensionInvalidInstanceOf = createDiagnosticFactory(
59-
`Cannot use instanceof on classes with '@extension' or '@metaExtension' annotation.`
59+
"Cannot use instanceof on classes with '@extension' or '@metaExtension' annotation."
6060
);
6161

6262
export const extensionAndMetaExtensionConflict = createDiagnosticFactory(
63-
`Cannot use both '@extension' and '@metaExtension' annotations on the same class.`
63+
"Cannot use both '@extension' and '@metaExtension' annotations on the same class."
6464
);
6565

6666
export const metaExtensionMissingExtends = createDiagnosticFactory(
67-
`'@metaExtension' annotation requires the extension of the metatable class.`
67+
"'@metaExtension' annotation requires the extension of the metatable class."
6868
);
6969

7070
export const invalidForRangeCall = createDiagnosticFactory((message: string) => `Invalid @forRange call: ${message}.`);

src/transformation/visitors/class/members/accessors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export function transformAccessorDeclarations(
3939

4040
importLuaLibFeature(context, LuaLibFeature.Descriptors);
4141
const call = isStaticNode(firstAccessor)
42-
? lua.createCallExpression(lua.createIdentifier(`__TS__ObjectDefineProperty`), [
42+
? lua.createCallExpression(lua.createIdentifier("__TS__ObjectDefineProperty"), [
4343
lua.cloneIdentifier(className),
4444
propertyName,
4545
descriptor,
4646
])
47-
: lua.createCallExpression(lua.createIdentifier(`__TS__SetDescriptor`), [
47+
: lua.createCallExpression(lua.createIdentifier("__TS__SetDescriptor"), [
4848
lua.createTableIndexExpression(lua.cloneIdentifier(className), lua.createStringLiteral("prototype")),
4949
propertyName,
5050
descriptor,

src/transformation/visitors/lua-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function transformLuaTablePropertyAccessInAssignment(
124124

125125
const [luaTable, propertyName] = parseLuaTableExpression(context, node);
126126
if (propertyName === "length") {
127-
context.diagnostics.push(luaTableForbiddenUsage(node, `A LuaTable object's length cannot be re-assigned`));
127+
context.diagnostics.push(luaTableForbiddenUsage(node, "A LuaTable object's length cannot be re-assigned"));
128128
return lua.createTableIndexExpression(luaTable, lua.createStringLiteral(propertyName), node);
129129
}
130130

src/transpilation/bundle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function bundleTranspiledFiles(
4242
);
4343

4444
// If any of the modules contains a require for lualib_bundle, add it to the module table.
45-
const lualibRequired = transpiledFiles.some(f => f.lua?.includes(`require("lualib_bundle")`));
45+
const lualibRequired = transpiledFiles.some(f => f.lua?.includes('require("lualib_bundle")'));
4646
if (lualibRequired) {
4747
moduleTableEntries.push(`["lualib_bundle"] = function() ${getLuaLibBundle(emitHost)} end,\n`);
4848
}
@@ -90,7 +90,7 @@ end\n`;
9090

9191
function moduleSourceNode(transpiledFile: TranspiledFile, modulePath: string): SourceNode {
9292
const tableEntryHead = `[${modulePath}] = function() `;
93-
const tableEntryTail = `end,\n`;
93+
const tableEntryTail = "end,\n";
9494

9595
if (transpiledFile.lua && transpiledFile.sourceMapNode) {
9696
return joinSourceChunks([tableEntryHead, transpiledFile.sourceMapNode, tableEntryTail]);
@@ -100,8 +100,8 @@ function moduleSourceNode(transpiledFile: TranspiledFile, modulePath: string): S
100100
}
101101

102102
function createModuleTableNode(fileChunks: SourceChunk[]): SourceNode {
103-
const tableHead = `____modules = {\n`;
104-
const tableEnd = `}\n`;
103+
const tableHead = "____modules = {\n";
104+
const tableEnd = "}\n";
105105

106106
return joinSourceChunks([tableHead, ...fileChunks, tableEnd]);
107107
}

src/transpilation/diagnostics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ export const luaBundleEntryIsRequired = createDiagnosticFactory(
3434
export const usingLuaBundleWithInlineMightGenerateDuplicateCode = createSerialDiagnosticFactory(() => ({
3535
category: ts.DiagnosticCategory.Warning,
3636
messageText:
37-
`Using 'luaBundle' with 'luaLibImport: "inline"' might generate duplicate code. ` +
38-
`It is recommended to use 'luaLibImport: "require"'.`,
37+
"Using 'luaBundle' with 'luaLibImport: \"inline\"' might generate duplicate code. " +
38+
"It is recommended to use 'luaLibImport: \"require\"'.",
3939
}));

src/transpilation/emit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function emitTranspiledFiles(
5454
luaLibImport === LuaLibImportKind.Require ||
5555
luaLibImport === LuaLibImportKind.Always)
5656
) {
57-
const lualibRequired = files.some(f => f.text?.includes(`require("lualib_bundle")`));
57+
const lualibRequired = files.some(f => f.text?.includes('require("lualib_bundle")'));
5858
if (lualibRequired) {
5959
let outPath = path.resolve(rootDir, "lualib_bundle.lua");
6060
if (outDir !== rootDir) {

test/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ expect.extend({
2323
);
2424

2525
if (this.isNot && expected !== undefined) {
26-
throw new Error(`expect(actual).not.toHaveDiagnostics(expected) is not supported`);
26+
throw new Error("expect(actual).not.toHaveDiagnostics(expected) is not supported");
2727
}
2828

2929
return {

test/unit/annotations/customConstructor.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test("CustomCreate", () => {
1919
}
2020
`;
2121

22-
const result = util.transpileAndExecute(`return new Point2D(1, 2).x;`, undefined, luaHeader, tsHeader);
22+
const result = util.transpileAndExecute("return new Point2D(1, 2).x;", undefined, luaHeader, tsHeader);
2323

2424
expect(result).toBe(1);
2525
});

0 commit comments

Comments
 (0)