Skip to content

Commit 38652d4

Browse files
committed
no-var
1 parent 882dfd2 commit 38652d4

10 files changed

Lines changed: 56 additions & 54 deletions

File tree

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"no-unsafe-finally": "error",
110110
"no-unused-expressions": "error",
111111
"no-unused-labels": "error",
112-
"no-var": "off",
112+
"no-var": "error",
113113
"object-shorthand": "error",
114114
"one-var": "off",
115115
"prefer-const": "error",
@@ -127,7 +127,8 @@
127127
"overrides": [{
128128
"files": ["src/lib/*.d.ts"],
129129
"rules": {
130-
"@typescript-eslint/interface-name-prefix": "off"
130+
"@typescript-eslint/interface-name-prefix": "off",
131+
"no-var": "off"
131132
}
132133
}]
133134
}

scripts/authors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ namespace Commands {
167167
listAuthors.description = "List known and unknown authors for a given spec, e.g. 'node authors.js listAuthors origin/release-2.6..origin/release-2.7'";
168168
}
169169

170-
var args = process.argv.slice(2);
170+
const args = process.argv.slice(2);
171171
if (args.length < 1) {
172172
console.log("Usage: node authors.js [command]");
173173
console.log("List of commands: ");
174174
Object.keys(Commands).forEach(k => console.log(` ${k}: ${(Commands as any)[k].description}`));
175175
}
176176
else {
177-
var cmd: Function = (Commands as any)[args[0]];
177+
const cmd: Function = (Commands as any)[args[0]];
178178
if (cmd === undefined) {
179179
console.log("Unknown command " + args[1]);
180180
}

scripts/bisect-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import cp = require("child_process");
66
import fs = require("fs");
77

88
// Slice off 'node bisect-test.js' from the command line args
9-
var args = process.argv.slice(2);
9+
const args = process.argv.slice(2);
1010

1111
function tsc(tscArgs: string, onExit: (exitCode: number) => void) {
12-
var tsc = cp.exec("node built/local/tsc.js " + tscArgs,() => void 0);
12+
const tsc = cp.exec("node built/local/tsc.js " + tscArgs,() => void 0);
1313
tsc.on("close", tscExitCode => {
1414
onExit(tscExitCode);
1515
});
1616
}
1717

1818
// TODO: Rewrite bisect script to handle the post-jake/gulp swap period
19-
var jake = cp.exec("jake clean local", () => void 0);
19+
const jake = cp.exec("jake clean local", () => void 0);
2020
jake.on("close", jakeExitCode => {
2121
if (jakeExitCode === 0) {
2222
// See what we're being asked to do
@@ -35,7 +35,7 @@ jake.on("close", jakeExitCode => {
3535
else if (args[1] === "emits" || args[1] === "!emits") {
3636
tsc(args[0], tscExitCode => {
3737
fs.readFile(args[2], "utf-8", (err, data) => {
38-
var doesContains = data.indexOf(args[3]) >= 0;
38+
const doesContains = data.indexOf(args[3]) >= 0;
3939
if (doesContains === (args[1] === "emits")) {
4040
console.log("Good");
4141
process.exit(0); // Good

scripts/buildProtocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class DeclarationsWalker {
2020
}
2121

2222
static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string {
23+
const walker = new DeclarationsWalker(typeChecker, protocolFile);
2324
let text = "declare namespace ts.server.protocol {\n";
24-
var walker = new DeclarationsWalker(typeChecker, protocolFile);
2525
walker.visitTypeNodes(protocolFile);
2626
text = walker.text
2727
? `declare namespace ts.server.protocol {\n${walker.text}}`

scripts/errorCheck.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
declare var require: any;
21
const fs = require("fs");
32
const async = require("async");
43
const glob = require("glob");

scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Map<T> {
77
[key: string]: T;
88
}
99

10-
declare var process: {
10+
declare let process: {
1111
argv: string[];
1212
env: Map<string>;
1313
exit(exitCode?: number): void;

scripts/word2md.ts

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ namespace Word {
130130
}
131131
}
132132

133-
var sys = (function () {
134-
var fileStream = new ActiveXObject("ADODB.Stream");
135-
fileStream.Type = 2 /*text*/;
136-
var binaryStream = new ActiveXObject("ADODB.Stream");
137-
binaryStream.Type = 1 /*binary*/;
138-
var args: string[] = [];
139-
for (var i = 0; i < WScript.Arguments.length; i++) {
133+
const sys = (function () {
134+
const fileStream = new ActiveXObject("ADODB.Stream");
135+
fileStream.Type = 2 /* text */;
136+
const binaryStream = new ActiveXObject("ADODB.Stream");
137+
binaryStream.Type = 1 /* binary */;
138+
const args: string[] = [];
139+
for (let i = 0; i < WScript.Arguments.length; i++) {
140140
args[i] = WScript.Arguments.Item(i);
141141
}
142142
return {
@@ -176,17 +176,17 @@ interface FindReplaceOptions {
176176

177177
function convertDocumentToMarkdown(doc: Word.Document): string {
178178

179-
var result = "";
180-
var lastStyle: string;
181-
var lastInTable: boolean;
182-
var tableColumnCount: number;
183-
var tableCellIndex: number;
184-
var columnAlignment: number[] = [];
179+
const columnAlignment: number[] = [];
180+
let tableColumnCount: number;
181+
let tableCellIndex: number;
182+
let lastInTable: boolean;
183+
let lastStyle: string;
184+
let result = "";
185185

186186
function setProperties(target: any, properties: any) {
187-
for (var name in properties) {
187+
for (const name in properties) {
188188
if (properties.hasOwnProperty(name)) {
189-
var value = properties[name];
189+
const value = properties[name];
190190
if (typeof value === "object") {
191191
setProperties(target[name], value);
192192
}
@@ -198,10 +198,10 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
198198
}
199199

200200
function findReplace(findText: string, findOptions: FindReplaceOptions, replaceText: string, replaceOptions: FindReplaceOptions) {
201-
var find = doc.range().find;
201+
const find = doc.range().find;
202202
find.clearFormatting();
203203
setProperties(find, findOptions);
204-
var replace = find.replacement;
204+
const replace = find.replacement;
205205
replace.clearFormatting();
206206
setProperties(replace, replaceOptions);
207207
find.execute(findText,
@@ -219,12 +219,12 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
219219
}
220220

221221
function fixHyperlinks() {
222-
var count = doc.hyperlinks.count;
223-
for (var i = 0; i < count; i++) {
224-
var hyperlink = doc.hyperlinks.item(i + 1);
225-
var address = hyperlink.address;
222+
const count = doc.hyperlinks.count;
223+
for (let i = 0; i < count; i++) {
224+
const hyperlink = doc.hyperlinks.item(i + 1);
225+
const address = hyperlink.address;
226226
if (address && address.length > 0) {
227-
var textToDisplay = hyperlink.textToDisplay;
227+
const textToDisplay = hyperlink.textToDisplay;
228228
hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")";
229229
}
230230
}
@@ -235,7 +235,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
235235
}
236236

237237
function writeTableHeader() {
238-
for (var i = 0; i < tableColumnCount - 1; i++) {
238+
for (let i = 0; i < tableColumnCount - 1; i++) {
239239
switch (columnAlignment[i]) {
240240
case 1:
241241
write("|:---:");
@@ -251,7 +251,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
251251
}
252252

253253
function trimEndFormattingMarks(text: string) {
254-
var i = text.length;
254+
let i = text.length;
255255
while (i > 0 && text.charCodeAt(i - 1) < 0x20) i--;
256256
return text.substr(0, i);
257257
}
@@ -271,12 +271,13 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
271271

272272
function writeParagraph(p: Word.Paragraph) {
273273

274-
var range = p.range;
275-
var text = range.text;
276-
var style = p.style.nameLocal;
277-
var inTable = range.tables.count > 0;
278-
var level = 1;
279-
var sectionBreak = text.indexOf("\x0C") >= 0;
274+
const range = p.range;
275+
const inTable = range.tables.count > 0;
276+
const sectionBreak = range.text.indexOf("\x0C") >= 0;
277+
278+
let level = 1;
279+
let style = p.style.nameLocal;
280+
let text = range.text;
280281

281282
text = trimEndFormattingMarks(text);
282283
if (text === "/") {
@@ -285,7 +286,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
285286
// hidden text and, if so, emit that instead. The hidden text is assumed to
286287
// contain an appropriate markdown image link.
287288
range.textRetrievalMode.includeHiddenText = true;
288-
var fullText = range.text;
289+
const fullText = range.text;
289290
range.textRetrievalMode.includeHiddenText = false;
290291
if (text !== fullText) {
291292
text = "&emsp;&emsp;" + fullText.substr(1);
@@ -307,7 +308,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
307308

308309
case "Heading":
309310
case "Appendix":
310-
var section = range.listFormat.listString;
311+
const section = range.listFormat.listString;
311312
write("####".substr(0, level) + ' <a name="' + section + '"/>' + section + " " + text + "\n\n");
312313
break;
313314

@@ -358,7 +359,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
358359
break;
359360

360361
case "TOC":
361-
var strings = text.split("\t");
362+
const strings = text.split("\t");
362363
write(" ".substr(0, level * 2 - 2) + "* [" + strings[0] + " " + strings[1] + "](#" + strings[0] + ")\n");
363364
break;
364365
}
@@ -371,11 +372,11 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
371372
}
372373

373374
function writeDocument() {
374-
var title = doc.builtInDocumentProperties.item(1) + "";
375+
const title = doc.builtInDocumentProperties.item(1) + "";
375376
if (title.length) {
376377
write("# " + title + "\n\n");
377378
}
378-
for (var p = doc.paragraphs.first; p; p = p.next()) {
379+
for (let p = doc.paragraphs.first; p; p = p.next()) {
379380
writeParagraph(p);
380381
}
381382
writeBlockEnd();
@@ -412,8 +413,8 @@ function main(args: string[]) {
412413
sys.write("Syntax: word2md <inputfile> <outputfile>\n");
413414
return;
414415
}
415-
var app: Word.Application = sys.createObject("Word.Application");
416-
var doc = app.documents.open(args[0]);
416+
const app: Word.Application = sys.createObject("Word.Application");
417+
const doc = app.documents.open(args[0]);
417418
sys.writeFile(args[1], convertDocumentToMarkdown(doc));
418419
doc.close(/* saveChanges */ false);
419420
app.quit();

src/harness/evaluator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace evaluator {
2-
declare var Symbol: SymbolConstructor;
2+
declare let Symbol: SymbolConstructor;
33

44
const sourceFile = vpath.combine(vfs.srcFolder, "source.ts");
55

src/harness/harness.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Block scoped definitions work poorly for global variables, temporarily enable var
2-
/* tslint:disable:no-var-keyword */
2+
/* eslint-disable no-var */
33

44
// this will work in the browser via browserify
5-
var _chai: typeof chai = require("chai");
6-
var assert: typeof _chai.assert = _chai.assert;
5+
const _chai: typeof chai = require("chai");
6+
const assert: typeof _chai.assert = _chai.assert;
77
{
88
// chai's builtin `assert.isFalse` is featureful but slow - we don't use those features,
99
// so we'll just overwrite it as an alterative to migrating a bunch of code off of chai
@@ -32,6 +32,7 @@ var global: NodeJS.Global = Function("return this").call(undefined); // eslint-d
3232

3333
declare var window: {};
3434
declare var XMLHttpRequest: new() => XMLHttpRequest;
35+
3536
interface XMLHttpRequest {
3637
readonly readyState: number;
3738
readonly responseText: string;
@@ -44,7 +45,7 @@ interface XMLHttpRequest {
4445
getResponseHeader(header: string): string | null;
4546
overrideMimeType(mime: string): void;
4647
}
47-
/* tslint:enable:no-var-keyword prefer-const */
48+
/* eslint-enable no-var */
4849

4950
namespace Utils {
5051
export function encodeString(s: string): string {

src/services/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface PromiseConstructor {
66
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
77
}
88
/* @internal */
9-
declare var Promise: PromiseConstructor;
9+
declare let Promise: PromiseConstructor;
1010

1111
// These utilities are common to multiple language service features.
1212
/* @internal */

0 commit comments

Comments
 (0)