Skip to content

Commit 35a3d85

Browse files
author
Armando Aguirre
committed
Fixed lint issues
1 parent ee37d8e commit 35a3d85

File tree

6 files changed

+49
-42
lines changed

6 files changed

+49
-42
lines changed

src/harness/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,4 +832,4 @@ namespace ts.server {
832832
throw new Error("dispose is not available through the server layer.");
833833
}
834834
}
835-
}
835+
}

src/harness/fourslashImpl.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,8 +3659,8 @@ namespace FourSlash {
36593659
}
36603660

36613661
public toggleLineComment(newFileContent: string): void {
3662-
let changes: ts.TextChange[] = [];
3663-
for (let range of this.getRanges()) {
3662+
const changes: ts.TextChange[] = [];
3663+
for (const range of this.getRanges()) {
36643664
changes.push.apply(changes, this.languageService.toggleLineComment(this.activeFile.fileName, range));
36653665
}
36663666

@@ -3670,8 +3670,8 @@ namespace FourSlash {
36703670
}
36713671

36723672
public toggleMultilineComment(newFileContent: string): void {
3673-
let changes: ts.TextChange[] = [];
3674-
for (let range of this.getRanges()) {
3673+
const changes: ts.TextChange[] = [];
3674+
for (const range of this.getRanges()) {
36753675
changes.push.apply(changes, this.languageService.toggleMultilineComment(this.activeFile.fileName, range));
36763676
}
36773677

@@ -3681,8 +3681,8 @@ namespace FourSlash {
36813681
}
36823682

36833683
public commentSelection(newFileContent: string): void {
3684-
let changes: ts.TextChange[] = [];
3685-
for (let range of this.getRanges()) {
3684+
const changes: ts.TextChange[] = [];
3685+
for (const range of this.getRanges()) {
36863686
changes.push.apply(changes, this.languageService.commentSelection(this.activeFile.fileName, range));
36873687
}
36883688

@@ -3692,8 +3692,8 @@ namespace FourSlash {
36923692
}
36933693

36943694
public uncommentSelection(newFileContent: string): void {
3695-
let changes: ts.TextChange[] = [];
3696-
for (let range of this.getRanges()) {
3695+
const changes: ts.TextChange[] = [];
3696+
for (const range of this.getRanges()) {
36973697
changes.push.apply(changes, this.languageService.uncommentSelection(this.activeFile.fileName, range));
36983698
}
36993699

src/server/session.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,28 +2711,28 @@ namespace ts.server {
27112711
return this.requiredResponse(this.provideCallHierarchyOutgoingCalls(request.arguments));
27122712
},
27132713
[CommandNames.ToggleLineComment]: (request: protocol.ToggleLineCommentRequest) => {
2714-
return this.requiredResponse(this.toggleLineComment(request.arguments, /*simplifiedResult*/true));
2714+
return this.requiredResponse(this.toggleLineComment(request.arguments, /*simplifiedResult*/ true));
27152715
},
27162716
[CommandNames.ToggleLineCommentFull]: (request: protocol.ToggleLineCommentRequest) => {
2717-
return this.requiredResponse(this.toggleLineComment(request.arguments, /*simplifiedResult*/false));
2717+
return this.requiredResponse(this.toggleLineComment(request.arguments, /*simplifiedResult*/ false));
27182718
},
27192719
[CommandNames.ToggleMultilineComment]: (request: protocol.ToggleMultilineCommentRequest) => {
2720-
return this.requiredResponse(this.toggleMultilineComment(request.arguments, /*simplifiedResult*/true));
2720+
return this.requiredResponse(this.toggleMultilineComment(request.arguments, /*simplifiedResult*/ true));
27212721
},
27222722
[CommandNames.ToggleMultilineCommentFull]: (request: protocol.ToggleMultilineCommentRequest) => {
2723-
return this.requiredResponse(this.toggleMultilineComment(request.arguments, /*simplifiedResult*/false));
2723+
return this.requiredResponse(this.toggleMultilineComment(request.arguments, /*simplifiedResult*/ false));
27242724
},
27252725
[CommandNames.CommentSelection]: (request: protocol.CommentSelectionRequest) => {
2726-
return this.requiredResponse(this.commentSelection(request.arguments, /*simplifiedResult*/true));
2726+
return this.requiredResponse(this.commentSelection(request.arguments, /*simplifiedResult*/ true));
27272727
},
27282728
[CommandNames.CommentSelectionFull]: (request: protocol.CommentSelectionRequest) => {
2729-
return this.requiredResponse(this.commentSelection(request.arguments, /*simplifiedResult*/false));
2729+
return this.requiredResponse(this.commentSelection(request.arguments, /*simplifiedResult*/ false));
27302730
},
27312731
[CommandNames.UncommentSelection]: (request: protocol.UncommentSelectionRequest) => {
2732-
return this.requiredResponse(this.uncommentSelection(request.arguments, /*simplifiedResult*/true));
2732+
return this.requiredResponse(this.uncommentSelection(request.arguments, /*simplifiedResult*/ true));
27332733
},
27342734
[CommandNames.UncommentSelectionFull]: (request: protocol.UncommentSelectionRequest) => {
2735-
return this.requiredResponse(this.uncommentSelection(request.arguments, /*simplifiedResult*/false));
2735+
return this.requiredResponse(this.uncommentSelection(request.arguments, /*simplifiedResult*/ false));
27362736
},
27372737
});
27382738

src/services/services.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ namespace ts {
19821982
lineStarts: sourceFile.getLineStarts(),
19831983
firstLine: sourceFile.getLineAndCharacterOfPosition(textRange.pos).line,
19841984
lastLine: sourceFile.getLineAndCharacterOfPosition(textRange.end).line
1985-
}
1985+
};
19861986
}
19871987

19881988
function toggleLineComment(fileName: string, textRange: TextRange, insertComment?: boolean): TextChange[] {
@@ -1992,9 +1992,9 @@ namespace ts {
19921992

19931993
let isCommenting = insertComment || false;
19941994
let leftMostPosition = Number.MAX_VALUE;
1995-
let lineTextStarts = new Map<number>();
1995+
const lineTextStarts = new Map<number>();
19961996
const whiteSpaceRegex = new RegExp(/\S/);
1997-
const isJsx = isInsideJsxElement(sourceFile, lineStarts[firstLine])
1997+
const isJsx = isInsideJsxElement(sourceFile, lineStarts[firstLine]);
19981998
const openComment = isJsx ? "{/*" : "//";
19991999

20002000
// Check each line before any text changes.
@@ -2021,15 +2021,17 @@ namespace ts {
20212021
if (lineTextStart !== undefined) {
20222022
if (isJsx) {
20232023
textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { pos: lineStarts[i] + leftMostPosition, end: sourceFile.getLineEndOfPosition(lineStarts[i]) }, isCommenting, isJsx));
2024-
} else if (isCommenting) {
2024+
}
2025+
else if (isCommenting) {
20252026
textChanges.push({
20262027
newText: openComment,
20272028
span: {
20282029
length: 0,
20292030
start: lineStarts[i] + leftMostPosition
20302031
}
20312032
});
2032-
} else if (sourceFile.text.substr(lineStarts[i] + lineTextStart, openComment.length) === openComment) {
2033+
}
2034+
else if (sourceFile.text.substr(lineStarts[i] + lineTextStart, openComment.length) === openComment) {
20332035
textChanges.push({
20342036
newText: "",
20352037
span: {
@@ -2080,8 +2082,9 @@ namespace ts {
20802082
}
20812083

20822084
pos = commentRange.end + 1;
2083-
} else { // If it's not in a comment range, then we need to comment the uncommented portions.
2084-
let newPos = text.substring(pos, textRange.end).search(`(${openMultilineRegex})|(${closeMultilineRegex})`);
2085+
}
2086+
else { // If it's not in a comment range, then we need to comment the uncommented portions.
2087+
const newPos = text.substring(pos, textRange.end).search(`(${openMultilineRegex})|(${closeMultilineRegex})`);
20852088

20862089
isCommenting = insertComment !== undefined
20872090
? insertComment
@@ -2141,16 +2144,17 @@ namespace ts {
21412144
}
21422145
});
21432146
}
2144-
} else {
2147+
}
2148+
else {
21452149
// If is not commenting then remove all comments found.
2146-
for (let i = 0; i < positions.length; i++) {
2147-
const from = positions[i] - closeMultiline.length > 0 ? positions[i] - closeMultiline.length : 0;
2150+
for (const pos of positions) {
2151+
const from = pos - closeMultiline.length > 0 ? pos - closeMultiline.length : 0;
21482152
const offset = text.substr(from, closeMultiline.length) === closeMultiline ? closeMultiline.length : 0;
21492153
textChanges.push({
21502154
newText: "",
21512155
span: {
21522156
length: openMultiline.length,
2153-
start: positions[i] - offset
2157+
start: pos - offset
21542158
}
21552159
});
21562160
}
@@ -2160,21 +2164,22 @@ namespace ts {
21602164
}
21612165

21622166
function commentSelection(fileName: string, textRange: TextRange): TextChange[] {
2163-
return toggleLineComment(fileName, textRange, true);
2167+
return toggleLineComment(fileName, textRange, /*insertComment*/ true);
21642168
}
2169+
21652170
function uncommentSelection(fileName: string, textRange: TextRange): TextChange[] {
21662171
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
21672172
const textChanges: TextChange[] = [];
21682173

21692174
for (let i = textRange.pos; i <= textRange.end; i++) {
2170-
let commentRange = isInComment(sourceFile, i);
2175+
const commentRange = isInComment(sourceFile, i);
21712176
if (commentRange) {
21722177
switch (commentRange.kind) {
21732178
case SyntaxKind.SingleLineCommentTrivia:
2174-
textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, false));
2179+
textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false));
21752180
break;
21762181
case SyntaxKind.MultiLineCommentTrivia:
2177-
textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, false));
2182+
textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false));
21782183
}
21792184

21802185
i = commentRange.end + 1;

src/services/shims.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ namespace ts {
278278
getEmitOutput(fileName: string): string;
279279
getEmitOutputObject(fileName: string): EmitOutput;
280280

281-
toggleLineComment(fileName: string, textChange: ts.TextRange): string;
282-
toggleMultilineComment(fileName: string, textChange: ts.TextRange): string;
283-
commentSelection(fileName: string, textChange: ts.TextRange): string;
284-
uncommentSelection(fileName: string, textChange: ts.TextRange): string;
281+
toggleLineComment(fileName: string, textChange: TextRange): string;
282+
toggleMultilineComment(fileName: string, textChange:TextRange): string;
283+
commentSelection(fileName: string, textChange: TextRange): string;
284+
uncommentSelection(fileName: string, textChange: TextRange): string;
285285
}
286286

287287
export interface ClassifierShim extends Shim {
@@ -1072,28 +1072,28 @@ namespace ts {
10721072
this.logPerformance) as EmitOutput;
10731073
}
10741074

1075-
public toggleLineComment(fileName: string, textRange: ts.TextRange): string {
1075+
public toggleLineComment(fileName: string, textRange: TextRange): string {
10761076
return this.forwardJSONCall(
10771077
`toggleLineComment('${fileName}', '${JSON.stringify(textRange)}')`,
10781078
() => this.languageService.toggleLineComment(fileName, textRange)
10791079
);
10801080
}
10811081

1082-
public toggleMultilineComment(fileName: string, textRange: ts.TextRange): string {
1082+
public toggleMultilineComment(fileName: string, textRange: TextRange): string {
10831083
return this.forwardJSONCall(
10841084
`toggleMultilineComment('${fileName}', '${JSON.stringify(textRange)}')`,
10851085
() => this.languageService.toggleMultilineComment(fileName, textRange)
10861086
);
10871087
}
10881088

1089-
public commentSelection(fileName: string, textRange: ts.TextRange): string {
1089+
public commentSelection(fileName: string, textRange: TextRange): string {
10901090
return this.forwardJSONCall(
10911091
`commentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
10921092
() => this.languageService.commentSelection(fileName, textRange)
10931093
);
10941094
}
10951095

1096-
public uncommentSelection(fileName: string, textRange: ts.TextRange): string {
1096+
public uncommentSelection(fileName: string, textRange: TextRange): string {
10971097
return this.forwardJSONCall(
10981098
`uncommentSelection('${fileName}', '${JSON.stringify(textRange)}')`,
10991099
() => this.languageService.uncommentSelection(fileName, textRange)

src/services/utilities.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,11 @@ namespace ts {
13321332
|| node.kind === SyntaxKind.OpenBraceToken
13331333
|| node.kind === SyntaxKind.SlashToken) {
13341334
node = node.parent;
1335-
} else if (node.kind === SyntaxKind.JsxElement) {
1335+
}
1336+
else if (node.kind === SyntaxKind.JsxElement) {
13361337
return position > node.getStart(sourceFile) || isInsideJsxElementRecursion(node.parent);
1337-
} else {
1338+
}
1339+
else {
13381340
return false;
13391341
}
13401342
}

0 commit comments

Comments
 (0)