Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Add noEmit to compilerOptions (#2823)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff authored and adidahiya committed May 24, 2017
1 parent d39070d commit 8b0ef1e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Linter {
readFile: (file) => fs.readFileSync(file, "utf8"),
useCaseSensitiveFileNames: true,
};
const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, path.resolve(projectDirectory));
const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, path.resolve(projectDirectory), {noEmit: true});
const host = ts.createCompilerHost(parsed.options, true);
const program = ts.createProgram(parsed.fileNames, parsed.options, host);

Expand Down
7 changes: 6 additions & 1 deletion src/rules/noUnusedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,12 @@ function getUnusedCheckedProgram(program: ts.Program, checkParameters: boolean):
}

function makeUnusedCheckedProgram(program: ts.Program, checkParameters: boolean): ts.Program {
const options = { ...program.getCompilerOptions(), noUnusedLocals: true, ...(checkParameters ? { noUnusedParameters: true } : null) };
const options = {
...program.getCompilerOptions(),
noEmit: true,
noUnusedLocals: true,
...(checkParameters ? { noUnusedParameters: true } : null),
};
const sourceFilesByName = new Map<string, ts.SourceFile>(
program.getSourceFiles().map<[string, ts.SourceFile]>((s) => [getCanonicalFileName(s.fileName), s]));

Expand Down
10 changes: 10 additions & 0 deletions test/executable/executableTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,16 @@ describe("Executable", function(this: Mocha.ISuiteCallbackContext) {
done();
});
});

it("can handles 'allowJs' correctly", (done) => {
execCli(
[ "-p", "test/files/tsconfig-allow-js/tsconfig.json"],
(err) => {
assert.isNotNull(err, "process should exit with error");
assert.strictEqual(err.code, 2, "error code should be 2");
done();
});
});
});

describe("--type-check", () => {
Expand Down
1 change: 1 addition & 0 deletions test/files/tsconfig-allow-js/testfile.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
6 changes: 6 additions & 0 deletions test/files/tsconfig-allow-js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"allowJs": true,
"noEmit": false
}
}
8 changes: 8 additions & 0 deletions test/files/tsconfig-allow-js/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"jsRules": {
"eofline": true,
"semicolon": [
true, "always"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ if (get<true | false | undefined>()) {}
if (get<true | false | undefined | void>()) {}

if (get<true>()) {}
~~~~~~~~~~~ [err % ("'if' condition", 'is always truthy')]
if (get<true | true>()) {}
~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'is always truthy')]
if (get<false | undefined>()) {}
~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'is always falsy')]
if (get<undefined>()) {}
Expand Down

0 comments on commit 8b0ef1e

Please sign in to comment.