Skip to content

Commit 5902b32

Browse files
committed
no-unused-expressions
1 parent fdfff35 commit 5902b32

8 files changed

Lines changed: 31 additions & 20 deletions

File tree

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"no-trailing-spaces": "error",
108108
"no-undef-init": "error",
109109
"no-unsafe-finally": "error",
110-
"no-unused-expressions": "off",
110+
"no-unused-expressions": "error",
111111
"no-unused-labels": "error",
112112
"no-var": "off",
113113
"object-shorthand": "error",

src/compiler/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2942,7 +2942,7 @@ namespace ts {
29422942
node.declarationMapPath = declarationMapPath;
29432943
node.declarationMapText = declarationMapTextOrBuildInfoPath;
29442944
node.javascriptPath = javascriptPath;
2945-
node.declarationPath = declarationPath,
2945+
node.declarationPath = declarationPath;
29462946
node.buildInfoPath = buildInfoPath;
29472947
node.buildInfo = buildInfo;
29482948
node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;

src/compiler/watch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ namespace ts {
331331
export function createProgramHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system: System, createProgram: CreateProgram<T> | undefined): ProgramHost<T> {
332332
const getDefaultLibLocation = memoize(() => getDirectoryPath(normalizePath(system.getExecutingFilePath())));
333333
let host: DirectoryStructureHost = system;
334-
host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!)
334+
// TODO: `host` is unused!
335+
// eslint-disable-next-line no-unused-expressions
336+
host;
335337
return {
336338
useCaseSensitiveFileNames: () => system.useCaseSensitiveFileNames,
337339
getNewLine: () => system.newLine,

src/services/refactors/generateGetAccessorAndSetAccessor.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,17 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
214214
}
215215

216216
function insertAccessor(changeTracker: textChanges.ChangeTracker, file: SourceFile, accessor: AccessorDeclaration, declaration: AcceptedDeclaration, container: ContainerDeclaration) {
217-
isParameterPropertyDeclaration(declaration)
218-
? changeTracker.insertNodeAtClassStart(file, <ClassLikeDeclaration>container, accessor)
219-
: isPropertyAssignment(declaration)
220-
? changeTracker.insertNodeAfterComma(file, declaration, accessor)
221-
: changeTracker.insertNodeAfter(file, declaration, accessor);
217+
if (isParameterPropertyDeclaration(declaration)) {
218+
changeTracker.insertNodeAtClassStart(file, <ClassLikeDeclaration>container, accessor);
219+
}
220+
else {
221+
if (isPropertyAssignment(declaration)) {
222+
changeTracker.insertNodeAfterComma(file, declaration, accessor);
223+
}
224+
else {
225+
changeTracker.insertNodeAfter(file, declaration, accessor);
226+
}
227+
}
222228
}
223229

224230
function updateReadonlyPropertyInitializerStatementConstructor(changeTracker: textChanges.ChangeTracker, file: SourceFile, constructor: ConstructorDeclaration, fieldName: string, originalName: string) {

src/testRunner/parallel/worker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ namespace Harness.Parallel.Worker {
125125
}
126126

127127
function addTest(title: string | Mocha.Func | Mocha.AsyncFunc, fn: Mocha.Func | Mocha.AsyncFunc | undefined): Mocha.Test {
128-
if (typeof title === "function") fn = title, title = fn.name;
128+
if (typeof title === "function") {
129+
fn = title;
130+
title = fn.name;
131+
}
129132
const test = new Test(title, suites[0].pending ? undefined : fn);
130133
suites[0].addTest(test);
131134
return test;
@@ -297,4 +300,4 @@ namespace Harness.Parallel.Worker {
297300

298301
process.on("message", processHostMessage);
299302
}
300-
}
303+
}

src/testRunner/unittests/services/languageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function Component(x: Config): any;`
4040
},
4141
});
4242
const definitions = languageService.getDefinitionAtPosition("foo.ts", 160); // 160 is the latter `vueTemplateHtml` position
43-
expect(definitions).to.exist; // tslint:disable-line no-unused-expression
43+
expect(definitions).to.exist; // eslint-disable-line no-unused-expressions
4444
});
4545
});
4646
}

src/testRunner/unittests/services/preProcessFile.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
4444
ambientExternalModules: undefined,
4545
isLibFile: false
4646
});
47-
}),
47+
});
4848

4949
it("Do not return reference path because of invalid triple-slash syntax", () => {
5050
test("///<reference path\"refFile1.ts\" />" + "\n" + "///<reference path =\"refFile2.ts\">" + "\n" + "///<referencepath=\"refFile3.ts\" />" + "\n" + "///<reference pat= \"refFile4d.ts\" />",
@@ -58,7 +58,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
5858
ambientExternalModules: undefined,
5959
isLibFile: false
6060
});
61-
}),
61+
});
6262

6363
it("Do not return reference path of non-imports", () => {
6464
test("Quill.import('delta');",
@@ -72,7 +72,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
7272
ambientExternalModules: undefined,
7373
isLibFile: false
7474
});
75-
}),
75+
});
7676

7777
it("Do not return reference path of nested non-imports", () => {
7878
test("a.b.import('c');",
@@ -86,7 +86,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
8686
ambientExternalModules: undefined,
8787
isLibFile: false
8888
});
89-
}),
89+
});
9090

9191
it("Correctly return imported files", () => {
9292
test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");",
@@ -101,7 +101,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
101101
ambientExternalModules: undefined,
102102
isLibFile: false
103103
});
104-
}),
104+
});
105105

106106
it("Do not return imported files if readImportFiles argument is false", () => {
107107
test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");",
@@ -115,7 +115,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
115115
ambientExternalModules: undefined,
116116
isLibFile: false
117117
});
118-
}),
118+
});
119119

120120
it("Do not return import path because of invalid import syntax", () => {
121121
test("import i1 require(\"r1.ts\"); import = require(\"r2.ts\") import i3= require(\"r3.ts\"); import i5",
@@ -129,7 +129,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
129129
ambientExternalModules: undefined,
130130
isLibFile: false
131131
});
132-
}),
132+
});
133133

134134
it("Correctly return referenced files and import files", () => {
135135
test("///<reference path=\"refFile1.ts\" />" + "\n" + "///<reference path =\"refFile2.ts\"/>" + "\n" + "import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\");",
@@ -143,7 +143,7 @@ describe("unittests:: services:: PreProcessFile:", () => {
143143
ambientExternalModules: undefined,
144144
isLibFile: false
145145
});
146-
}),
146+
});
147147

148148
it("Correctly return referenced files and import files even with some invalid syntax", () => {
149149
test("///<reference path=\"refFile1.ts\" />" + "\n" + "///<reference path \"refFile2.ts\"/>" + "\n" + "import i1 = require(\"r1.ts\"); import = require(\"r2.ts\"); import i2 = require(\"r3.ts\");",

src/testRunner/unittests/tsserver/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ namespace ts.server {
337337

338338
session.send = Session.prototype.send;
339339
assert(session.send);
340-
expect(session.send(msg)).to.not.exist; // tslint:disable-line no-unused-expression
340+
expect(session.send(msg)).to.not.exist; // eslint-disable-line no-unused-expressions
341341
expect(lastWrittenToHost).to.equal(resultMsg);
342342
});
343343
});

0 commit comments

Comments
 (0)