Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/src/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ export namespace ESLint {
if (result.length === 0) {
return result;
}
return result[result.length - 1] === path.sep
return result.endsWith(path.sep)
? result.substring(0, result.length - 1)
: result;
}
Expand Down Expand Up @@ -1335,8 +1335,8 @@ export namespace ESLint {
if (typeof err.message === 'string' || err.message instanceof String) {
result = <string>err.message;
result = result.replace(/\r?\n/g, ' ');
if (/^CLI: /.test(result)) {
result = result.substr(5);
if (result.startsWith('CLI: ')) {
result = result.slice(5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more. Why do you use slice instead of substring. I makes it easier to see that you are manipulating a string.

}
} else {
result = `An unknown error occurred while validating document: ${document.uri}`;
Expand Down
2 changes: 1 addition & 1 deletion server/src/eslintServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ async function computeAllFixes(identifier: VersionedTextDocumentIdentifier, mode
start: textDocument.positionAt(diff.originalStart),
end: textDocument.positionAt(diff.originalStart + diff.originalLength)
},
newText: fixedContent.substr(diff.modifiedStart, diff.modifiedLength)
newText: fixedContent.slice(diff.modifiedStart, diff.modifiedStart + diff.modifiedLength)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

});
}
}
Expand Down