Enable max-statements-per-line lint rule (#45475)

* Enable the rule

* Fix all the violations
This commit is contained in:
Ryan Cavanaugh
2021-08-16 13:53:51 -07:00
committed by GitHub
parent 339ad92b98
commit e00b5ecd40
37 changed files with 215 additions and 109 deletions
+3 -3
View File
@@ -2100,7 +2100,7 @@ namespace FourSlash {
}
private printMembersOrCompletions(info: ts.CompletionInfo | undefined) {
if (info === undefined) { return "No completion info."; }
if (info === undefined) return "No completion info.";
const { entries } = info;
function pad(s: string, length: number) {
@@ -2836,7 +2836,7 @@ namespace FourSlash {
public verifyTodoComments(descriptors: string[], spans: Range[]) {
const actual = this.languageService.getTodoComments(this.activeFile.fileName,
descriptors.map(d => { return { text: d, priority: 0 }; }));
descriptors.map(d => ({ text: d, priority: 0 })));
if (actual.length !== spans.length) {
this.raiseError(`verifyTodoComments failed - expected total spans to be ${spans.length}, but was ${actual.length}`);
@@ -4498,7 +4498,7 @@ namespace FourSlash {
// put ranges in the correct order
localRanges = localRanges.sort((a, b) => a.pos < b.pos ? -1 : a.pos === b.pos && a.end > b.end ? -1 : 1);
localRanges.forEach((r) => { ranges.push(r); });
localRanges.forEach(r => ranges.push(r));
return {
content: output,
+3 -1
View File
@@ -9,7 +9,9 @@ globalThis.assert = _chai.assert;
{
// chai's builtin `assert.isFalse` is featureful but slow - we don't use those features,
// so we'll just overwrite it as an alterative to migrating a bunch of code off of chai
assert.isFalse = (expr: any, msg: string) => { if (expr !== false) throw new Error(msg); };
assert.isFalse = (expr: any, msg: string) => {
if (expr !== false) throw new Error(msg);
};
const assertDeepImpl = assert.deepEqual;
assert.deepEqual = (a, b, msg) => {
+1 -1
View File
@@ -219,7 +219,7 @@ namespace Harness {
}
public Close() {
if (this.currentLine !== undefined) { this.lines.push(this.currentLine); }
if (this.currentLine !== undefined) this.lines.push(this.currentLine);
this.currentLine = undefined!;
}
+8 -2
View File
@@ -113,7 +113,11 @@ namespace Utils {
});
const childNodesAndArrays: any[] = [];
ts.forEachChild(node, child => { childNodesAndArrays.push(child); }, array => { childNodesAndArrays.push(array); });
ts.forEachChild(node, child => {
childNodesAndArrays.push(child);
}, array => {
childNodesAndArrays.push(array);
});
for (const childName in node) {
if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator" ||
@@ -198,7 +202,9 @@ namespace Utils {
return result;
}
function getNodeFlagName(f: number) { return getFlagName((ts as any).NodeFlags, f); }
function getNodeFlagName(f: number) {
return getFlagName((ts as any).NodeFlags, f);
}
function serializeNode(n: ts.Node): any {
const o: any = { kind: getKindName(n.kind) };
+3 -1
View File
@@ -29,7 +29,9 @@ namespace Harness {
const resChildren: ts.Node[] = [];
// push onto work queue in reverse order to maintain preorder traversal
ts.forEachChild(elem, c => { resChildren.unshift(c); });
ts.forEachChild(elem, c => {
resChildren.unshift(c);
});
work.push(...resChildren);
}
}
+6 -2
View File
@@ -848,14 +848,18 @@ namespace vfs {
// no difference if links are empty
if (!changedLinks.size) return false;
changedLinks.forEach((node, basename) => { FileSystem.trackCreatedInode(container, basename, changed, node); });
changedLinks.forEach((node, basename) => {
FileSystem.trackCreatedInode(container, basename, changed, node);
});
return true;
}
private static trackDeletedInodes(container: FileSet, baseLinks: ReadonlyMap<string, Inode>) {
// no difference if links are empty
if (!baseLinks.size) return false;
baseLinks.forEach((node, basename) => { container[basename] = isDirectory(node) ? new Rmdir() : new Unlink(); });
baseLinks.forEach((node, basename) => {
container[basename] = isDirectory(node) ? new Rmdir() : new Unlink();
});
return true;
}