Skip to content

Commit 7076e3c

Browse files
committed
Fix most tslint errors in the harness
1 parent 649e40b commit 7076e3c

File tree

8 files changed

+39
-37
lines changed

8 files changed

+39
-37
lines changed

src/harness/compilerRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CompilerBaselineRunner extends RunnerBase {
4444
// Everything declared here should be cleared out in the "after" callback.
4545
var justName: string;
4646
var content: string;
47-
var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }
47+
var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; };
4848

4949
var units: Harness.TestCaseParser.TestUnitData[];
5050
var tcSettings: Harness.TestCaseParser.CompilerSetting[];

src/harness/fourslash.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
@@ -135,7 +135,7 @@ module FourSlash {
135135
var fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference];
136136
var globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration,
137137
metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,
138-
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]
138+
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot];
139139

140140
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
141141
var settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 };
@@ -192,7 +192,7 @@ module FourSlash {
192192

193193
export class TestCancellationToken implements ts.HostCancellationToken {
194194
// 0 - cancelled
195-
// >0 - not cancelled
195+
// >0 - not cancelled
196196
// <0 - not cancelled and value denotes number of isCancellationRequested after which token become cancelled
197197
private static NotCanceled: number = -1;
198198
private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCanceled;
@@ -271,7 +271,7 @@ module FourSlash {
271271
private taoInvalidReason: string = null;
272272

273273
private inputFiles: ts.Map<string> = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references
274-
274+
275275
// Add input file which has matched file name with the given reference-file path.
276276
// This is necessary when resolveReference flag is specified
277277
private addMatchedInputFile(referenceFilePath: string) {
@@ -426,7 +426,7 @@ module FourSlash {
426426
this.activeFile = fileToOpen;
427427
var fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1);
428428
this.scenarioActions.push('<OpenFile FileName="" SrcFileId="' + fileName + '" FileId="' + fileName + '" />');
429-
429+
430430
// Let the host know that this file is now open
431431
this.languageServiceAdapterHost.openFile(fileToOpen.fileName);
432432
}
@@ -755,7 +755,7 @@ module FourSlash {
755755
error += "Expected documentation: " + expectedDocumentation + " to equal: " + ts.displayPartsToString(details.documentation) + ".";
756756
}
757757
if (expectedKind) {
758-
error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "."
758+
error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + ".";
759759
}
760760
this.raiseError(error);
761761
}
@@ -1151,6 +1151,7 @@ module FourSlash {
11511151
var length: number;
11521152
var prefixString = " >";
11531153

1154+
var pos = 0;
11541155
var addSpanInfoString = () => {
11551156
if (previousSpanInfo) {
11561157
resultString += currentLine;
@@ -1163,7 +1164,7 @@ module FourSlash {
11631164
}
11641165
};
11651166

1166-
for (var pos = 0; pos < this.activeFile.content.length; pos++) {
1167+
for (pos < this.activeFile.content.length; pos++) {
11671168
if (pos === 0 || pos === fileLineMap[nextLine]) {
11681169
nextLine++;
11691170
addSpanInfoString();
@@ -1347,7 +1348,7 @@ module FourSlash {
13471348
var offset = this.currentCaretPosition;
13481349
var ch = "";
13491350

1350-
var checkCadence = (count >> 2) + 1
1351+
var checkCadence = (count >> 2) + 1;
13511352

13521353
for (var i = 0; i < count; i++) {
13531354
// Make the edit
@@ -1363,7 +1364,7 @@ module FourSlash {
13631364
var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions);
13641365
if (edits.length) {
13651366
offset += this.applyEdits(this.activeFile.fileName, edits, true);
1366-
//this.checkPostEditInvariants();
1367+
// this.checkPostEditInvariants();
13671368
}
13681369
}
13691370
}
@@ -1388,7 +1389,7 @@ module FourSlash {
13881389

13891390
var offset = this.currentCaretPosition;
13901391
var ch = "";
1391-
var checkCadence = (count >> 2) + 1
1392+
var checkCadence = (count >> 2) + 1;
13921393

13931394
for (var i = 0; i < count; i++) {
13941395
offset--;
@@ -1503,8 +1504,8 @@ module FourSlash {
15031504
}
15041505

15051506
private checkPostEditInvariants() {
1506-
if (this.testType !== FourSlashTestType.Native) {
1507-
// getSourcefile() results can not be serialized. Only perform these verifications
1507+
if (this.testType !== FourSlashTestType.Native) {
1508+
// getSourcefile() results can not be serialized. Only perform these verifications
15081509
// if running against a native LS object.
15091510
return;
15101511
}
@@ -1883,7 +1884,7 @@ module FourSlash {
18831884
assert.equal(
18841885
expected.join(","),
18851886
actual.fileNameList.map( file => {
1886-
return file.replace(this.basePath + "/", "")
1887+
return file.replace(this.basePath + "/", "");
18871888
}).join(",")
18881889
);
18891890
}
@@ -2156,7 +2157,7 @@ module FourSlash {
21562157

21572158
// Get the text of the entire line the caret is currently at
21582159
private getCurrentLineContent() {
2159-
var text = this.getFileContent(this.activeFile.fileName)
2160+
var text = this.getFileContent(this.activeFile.fileName);
21602161

21612162
var pos = this.currentCaretPosition;
21622163
var startPos = pos, endPos = pos;
@@ -2286,7 +2287,7 @@ module FourSlash {
22862287
}
22872288

22882289
public setCancelled(numberOfCalls: number): void {
2289-
this.cancellationToken.setCancelled(numberOfCalls)
2290+
this.cancellationToken.setCancelled(numberOfCalls);
22902291
}
22912292

22922293
public resetCancelled(): void {

src/harness/fourslashRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class FourSlashRunner extends RunnerBase {
4646
if (testIndex >= 0) fn = fn.substr(testIndex);
4747

4848
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
49-
it(this.testSuiteName + ' test ' + justName + ' runs correctly',() => {
49+
it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => {
5050
FourSlash.runFourSlashTest(this.basePath, this.testType, fn);
5151
});
5252
}

src/harness/projectsRunner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class ProjectRunner extends RunnerBase {
124124
return ts.sys.resolvePath(testCase.projectRoot);
125125
}
126126

127-
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: ()=> string[],
127+
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[],
128128
getSourceFileText: (fileName: string) => string,
129129
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
130130

@@ -302,7 +302,7 @@ class ProjectRunner extends RunnerBase {
302302
}
303303
});
304304

305-
return compileProjectFiles(compilerResult.moduleKind,getInputFiles, getSourceFileText, writeFile);
305+
return compileProjectFiles(compilerResult.moduleKind, getInputFiles, getSourceFileText, writeFile);
306306

307307
function findOutpuDtsFile(fileName: string) {
308308
return ts.forEach(compilerResult.outputFiles, outputFile => outputFile.emittedFileName === fileName ? outputFile : undefined);
@@ -333,6 +333,8 @@ class ProjectRunner extends RunnerBase {
333333
describe('Projects tests', () => {
334334
describe(name, () => {
335335
function verifyCompilerResults(moduleKind: ts.ModuleKind) {
336+
var compilerResult: BatchCompileProjectTestCaseResult;
337+
336338
function getCompilerResolutionInfo() {
337339
var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
338340
scenario: testCase.scenario,
@@ -357,8 +359,6 @@ class ProjectRunner extends RunnerBase {
357359
return resolutionInfo;
358360
}
359361

360-
var compilerResult: BatchCompileProjectTestCaseResult;
361-
362362
it(name + ": " + moduleNameToString(moduleKind) , () => {
363363
// Compile using node
364364
compilerResult = batchCompilerProjectTestCase(moduleKind);

src/harness/runner.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
@@ -20,6 +20,9 @@
2020
/// <reference path='rwcRunner.ts' />
2121
/// <reference path='harness.ts' />
2222

23+
var runners: RunnerBase[] = [];
24+
var iterations: number = 1;
25+
2326
function runTests(runners: RunnerBase[]) {
2427
for (var i = iterations; i > 0; i--) {
2528
for (var j = 0; j < runners.length; j++) {
@@ -28,9 +31,6 @@ function runTests(runners: RunnerBase[]) {
2831
}
2932
}
3033

31-
var runners: RunnerBase[] = [];
32-
var iterations: number = 1;
33-
3434
// users can define tests to run in mytest.config that will override cmd line args, otherwise use cmd line args (test.config), otherwise no options
3535
var mytestconfig = 'mytest.config';
3636
var testconfig = 'test.config';
@@ -99,7 +99,7 @@ if (runners.length === 0) {
9999
runners.push(new FourSlashRunner(FourSlashTestType.Native));
100100
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
101101
runners.push(new FourSlashRunner(FourSlashTestType.Server));
102-
//runners.push(new GeneratedFourslashRunner());
102+
// runners.push(new GeneratedFourslashRunner());
103103
}
104104

105105
ts.sys.newLine = '\r\n';

src/harness/sourceMapRecorder.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
@@ -143,7 +143,7 @@ module Harness.SourceMapRecoder {
143143
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
144144
}
145145

146-
// 2. Relative sourceIndex
146+
// 2. Relative sourceIndex
147147
decodeOfEncodedMapping.sourceIndex += base64VLQFormatDecode();
148148
// Incorrect sourceIndex dont support this map
149149
if (createErrorIfCondition(decodeOfEncodedMapping.sourceIndex < 0, "Invalid sourceIndex found")) {
@@ -165,7 +165,7 @@ module Harness.SourceMapRecoder {
165165
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
166166
}
167167

168-
// 4. Relative sourceColumn 0 based
168+
// 4. Relative sourceColumn 0 based
169169
decodeOfEncodedMapping.sourceColumn += base64VLQFormatDecode();
170170
// Incorrect sourceColumn dont support this map
171171
if (createErrorIfCondition(decodeOfEncodedMapping.sourceColumn < 1, "Invalid sourceLine found")) {
@@ -278,7 +278,7 @@ module Harness.SourceMapRecoder {
278278
}
279279

280280
if (spansOnSingleLine.length && spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine) {
281-
// On different line from the one that we have been recording till now,
281+
// On different line from the one that we have been recording till now,
282282
writeRecordedSpans();
283283
spansOnSingleLine = [{ sourceMapSpan: sourceMapSpan, decodeErrors: decodedErrors }];
284284
}
@@ -329,6 +329,8 @@ module Harness.SourceMapRecoder {
329329
}
330330

331331
function writeRecordedSpans() {
332+
var markerIds: string[] = [];
333+
332334
function getMarkerId(markerIndex: number) {
333335
var markerId = "";
334336
if (spanMarkerContinues) {
@@ -416,7 +418,6 @@ module Harness.SourceMapRecoder {
416418
writeJsFileLines(currentJsLine);
417419

418420
// Emit markers
419-
var markerIds: string[] = [];
420421
iterateSpans(writeSourceMapMarker);
421422

422423
var jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code);
@@ -455,7 +456,7 @@ module Harness.SourceMapRecoder {
455456
SourceMapSpanWriter.recordSourceMapSpan(decodedSourceMapping);
456457
}
457458
}
458-
SourceMapSpanWriter.close();// If the last spans werent emitted, emit them
459+
SourceMapSpanWriter.close(); // If the last spans werent emitted, emit them
459460
}
460461
sourceMapRecoder.Close();
461462
return sourceMapRecoder.lines.join('\r\n');

src/harness/test262Runner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Test262BaselineRunner extends RunnerBase {
6363

6464
it('has the expected emitted code', () => {
6565
Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => {
66-
var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath);
66+
var files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath);
6767
return Harness.Compiler.collateOutputs(files);
6868
}, false, Test262BaselineRunner.baselineOptions);
6969
});
@@ -84,8 +84,8 @@ class Test262BaselineRunner extends RunnerBase {
8484
Utils.assertInvariants(sourceFile, /*parent:*/ undefined);
8585
});
8686

87-
it('has the expected AST',() => {
88-
Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt',() => {
87+
it('has the expected AST', () => {
88+
Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt', () => {
8989
var sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
9090
return Utils.sourceFileToJSON(sourceFile);
9191
}, false, Test262BaselineRunner.baselineOptions);
@@ -105,4 +105,4 @@ class Test262BaselineRunner extends RunnerBase {
105105
this.tests.forEach(test => this.runTest(test));
106106
}
107107
}
108-
}
108+
}

src/harness/typeWriter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TypeWriterWalker {
1313
private checker: ts.TypeChecker;
1414

1515
constructor(private program: ts.Program, fullTypeCheck: boolean) {
16-
// Consider getting both the diagnostics checker and the non-diagnostics checker to verify
16+
// Consider getting both the diagnostics checker and the non-diagnostics checker to verify
1717
// they are consistent.
1818
this.checker = fullTypeCheck
1919
? program.getDiagnosticsProducingTypeChecker()

0 commit comments

Comments
 (0)