mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Enable max-statements-per-line lint rule (#45475)
* Enable the rule * Fix all the violations
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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!;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) };
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user