Skip to content

Commit a702f4b

Browse files
committed
Enable more eslint rules
1 parent d4d27cf commit a702f4b

File tree

17 files changed

+41
-20
lines changed

17 files changed

+41
-20
lines changed

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,28 @@ module.exports = {
112112
{ enforceForRenamedProperties: false },
113113
],
114114
"prefer-numeric-literals": ["error"],
115+
"no-lonely-if": ["error"],
116+
"prefer-rest-params": ["error"],
117+
"prefer-spread": ["error"],
118+
"no-useless-computed-key": ["error"],
119+
"for-direction": ["error"],
120+
"no-compare-neg-zero": ["error"],
121+
"no-dupe-else-if": ["error"],
122+
"no-empty": ["error", { allowEmptyCatch: true }],
123+
"no-implicit-coercion": ["error", { boolean: true, number: true, string: true }],
124+
"operator-assignment": ["error"],
125+
"no-path-concat": ["error"],
126+
"no-compare-neg-zero": ["error"],
127+
"no-control-regex": ["error"],
128+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
129+
"one-var": ["error", "never"],
130+
"prefer-exponentiation-operator": ["error"],
131+
"prefer-object-spread": ["error"],
132+
"no-useless-call": ["off"],
133+
"no-useless-catch": ["error"],
134+
"no-useless-concat": ["error"],
135+
"no-useless-escape": ["error"],
136+
"no-useless-return": ["error"],
115137

116138
"import/no-default-export": "error",
117139
},

src/LuaAST.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export function createNode(kind: SyntaxKind, tsOriginal?: ts.Node): Node {
145145
}
146146

147147
export function cloneNode<T extends Node>(node: T): T {
148-
return Object.assign({}, node);
148+
return { ...node };
149149
}
150150

151151
export function setNodePosition<T extends Node>(node: T, position: TextRange): T {

src/LuaPrinter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const escapeString = (value: string) => `"${value.replace(escapeStringReg
3131
* `foo.bar` => passes (`function foo.bar()` is valid)
3232
* `getFoo().bar` => fails (`function getFoo().bar()` would be illegal)
3333
*/
34-
const isValidLuaFunctionDeclarationName = (str: string) => /^[a-zA-Z0-9_\.]+$/.test(str);
34+
const isValidLuaFunctionDeclarationName = (str: string) => /^[a-zA-Z0-9_.]+$/.test(str);
3535

3636
/**
3737
* Returns true if expression contains no function calls.
@@ -217,7 +217,7 @@ export class LuaPrinter {
217217
}
218218

219219
protected pushIndent(): void {
220-
this.currentIndent = this.currentIndent + " ";
220+
this.currentIndent += " ";
221221
}
222222

223223
protected popIndent(): void {

src/lualib/ArrayFind.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function __TS__ArrayFind<T>(
1111
if (predicate(elem, k, arr)) {
1212
return elem;
1313
}
14-
k = k + 1;
14+
k += 1;
1515
}
1616

1717
return undefined;

src/lualib/ArrayReduceRight.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function __TS__ArrayReduceRight<T>(
1515
accumulator = select(1, ...initial);
1616
} else if (len > 0) {
1717
accumulator = arr[k];
18-
k = k - 1;
18+
k -= 1;
1919
} else {
2020
throw "Reduce of empty array with no initial value";
2121
}

src/lualib/ArrayReverse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ function __TS__ArrayReverse(this: void, arr: any[]): any[] {
55
const temp = arr[j];
66
arr[j] = arr[i];
77
arr[i] = temp;
8-
i = i + 1;
9-
j = j - 1;
8+
i += 1;
9+
j -= 1;
1010
}
1111
return arr;
1212
}

src/lualib/InstanceOf.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function __TS__InstanceOf(this: void, obj: LuaClassInstance, classTbl: LuaClass)
44
}
55

66
if (classTbl[Symbol.hasInstance] !== undefined) {
7+
// eslint-disable-next-line no-implicit-coercion
78
return !!classTbl[Symbol.hasInstance](obj);
89
}
910

src/lualib/Iterator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function __TS__Iterator<T>(this: void, iterable: Iterable<T>): (this: void) => T
1212
} else {
1313
let i = 0;
1414
return () => {
15-
i = i + 1;
15+
i += 1;
1616
return iterable[i];
1717
};
1818
}

src/lualib/Map.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Map = class Map<K, V> {
4242
this.firstKey = undefined;
4343
this.lastKey = undefined;
4444
this.size = 0;
45-
return;
4645
}
4746

4847
public delete(key: K): boolean {
@@ -79,7 +78,6 @@ Map = class Map<K, V> {
7978
for (const key of this.keys()) {
8079
callback(this.items.get(key), key, this);
8180
}
82-
return;
8381
}
8482

8583
public get(key: K): V | undefined {

src/lualib/Set.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Set = class Set<T> {
5656
this.firstKey = undefined;
5757
this.lastKey = undefined;
5858
this.size = 0;
59-
return;
6059
}
6160

6261
public delete(value: T): boolean {

0 commit comments

Comments
 (0)