Skip to content

Commit

Permalink
Enable preferConst in TS project
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Dec 10, 2020
1 parent 1633404 commit 71fad5a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
**/extensions/**/build/**
**/extensions/markdown-language-features/media/**
**/extensions/typescript-basics/test/colorize-fixtures/**
**/extensions/typescript-language-features/dist/**
5 changes: 5 additions & 0 deletions extensions/typescript-language-features/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"prefer-const": "error"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<

let includesPackageJsonImport = false;
const items: MyCompletionItem[] = [];
for (let entry of entries) {
for (const entry of entries) {
if (!shouldExcludeCompletionEntry(entry, completionConfiguration)) {
items.push(new MyCompletionItem(position, document, entry, completionContext, metadata));
includesPackageJsonImport = !!entry.isPackageJsonImport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class DocumentSemanticTokensProvider implements vscode.DocumentSemanticTokensPro
return null;
}

let versionBeforeRequest = document.version;
const versionBeforeRequest = document.version;

const response = await (this.client as ExperimentalProtocol.IExtendedTypeScriptServiceClient).execute('encodedSemanticClassifications-full', requestArg, token, {
cancelOnResourceChange: document.uri
Expand Down Expand Up @@ -137,7 +137,7 @@ class DocumentSemanticTokensProvider implements vscode.DocumentSemanticTokensPro
function waitForDocumentChangesToEnd(document: vscode.TextDocument) {
let version = document.version;
return new Promise<void>((s) => {
let iv = setInterval(_ => {
const iv = setInterval(_ => {
if (document.version === version) {
clearInterval(iv);
s();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ProtocolBuffer {
if (this.buffer.length - this.index >= toAppend.length) {
toAppend.copy(this.buffer, this.index, 0, toAppend.length);
} else {
let newSize = (Math.ceil((this.index + toAppend.length) / defaultSize) + 1) * defaultSize;
const newSize = (Math.ceil((this.index + toAppend.length) / defaultSize) + 1) * defaultSize;
if (this.index === 0) {
this.buffer = Buffer.allocUnsafe(newSize);
toAppend.copy(this.buffer, 0, 0, toAppend.length);
Expand All @@ -61,14 +61,14 @@ class ProtocolBuffer {
return result;
}
current += contentLengthSize;
let start = current;
const start = current;
while (current < this.index && this.buffer[current] !== backslashR) {
current++;
}
if (current + 3 >= this.index || this.buffer[current + 1] !== backslashN || this.buffer[current + 2] !== backslashR || this.buffer[current + 3] !== backslashN) {
return result;
}
let data = this.buffer.toString('utf8', start, current);
const data = this.buffer.toString('utf8', start, current);
result = parseInt(data);
this.buffer = this.buffer.slice(current + 4);
this.index = this.index - (current + 4);
Expand All @@ -79,7 +79,7 @@ class ProtocolBuffer {
if (this.index < length) {
return null;
}
let result = this.buffer.toString('utf8', 0, length);
const result = this.buffer.toString('utf8', 0, length);
let sourceStart = length;
while (sourceStart < this.index && (this.buffer[sourceStart] === backslashR || this.buffer[sourceStart] === backslashN)) {
sourceStart++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this.info(`Using tsserver from: ${version.path}`);

const apiVersion = version.apiVersion || API.defaultVersion;
let mytoken = ++this.token;
const mytoken = ++this.token;
const handle = this.typescriptServerSpawner.spawn(version, this.capabilities, this.configuration, this.pluginManager, this.cancellerFactory, {
onFatalError: (command, err) => this.fatalError(command, err),
});
Expand Down

0 comments on commit 71fad5a

Please sign in to comment.