Skip to content

Commit

Permalink
fix(linting): speed up linting, fix output
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfspiritM committed Aug 13, 2019
1 parent 66f4381 commit bd913cd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
14 changes: 0 additions & 14 deletions src/CompilerHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,6 @@ export class CompilerHost
// do nothing
}

public resolveModuleNames(
moduleNames: string[],
containingFile: string,
reusedNames?: string[],
redirectedReference?: ts.ResolvedProjectReference
): (ts.ResolvedModule | undefined)[] {
return this.tsHost.resolveModuleNames!(
moduleNames,
containingFile,
reusedNames,
redirectedReference
);
}

public watchDirectory(
path: string,
callback: ts.DirectoryWatcherCallback,
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ for (let num = 0; num < division; num++) {
workers.push(
childProcess.fork(path.resolve(__dirname, './service.js'), [], {
execArgv: ['--max-old-space-size=' + process.env.MEMORY_LIMIT],
env: { ...process.env, WORK_NUMBER: num },
env: { ...process.env, WORK_NUMBER: num.toString() },
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
})
);
Expand Down
17 changes: 5 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ForkTsCheckerWebpackPlugin {

this.useTypescriptIncrementalApi =
options.useTypescriptIncrementalApi === undefined
? semver.gte(this.typescriptVersion, '3.0.0') && !this.vue
? semver.gte(this.typescriptVersion, '3.0.0')
: options.useTypescriptIncrementalApi;

this.measureTime = options.measureCompilationTime === true;
Expand All @@ -246,15 +246,11 @@ class ForkTsCheckerWebpackPlugin {
private validateVersions() {
if (semver.lt(this.typescriptVersion, '2.1.0')) {
throw new Error(
`Cannot use current typescript version of ${
this.typescriptVersion
}, the minimum required version is 2.1.0`
`Cannot use current typescript version of ${this.typescriptVersion}, the minimum required version is 2.1.0`
);
} else if (this.tslintVersion && semver.lt(this.tslintVersion, '4.0.0')) {
throw new Error(
`Cannot use current tslint version of ${
this.tslintVersion
}, the minimum required version is 4.0.0`
`Cannot use current tslint version of ${this.tslintVersion}, the minimum required version is 4.0.0`
);
}
}
Expand Down Expand Up @@ -542,7 +538,7 @@ class ForkTsCheckerWebpackPlugin {
this.doneCallback();
} else {
if (this.compiler) {
forkTsCheckerHooks.waiting.call(this.tslint !== false);
forkTsCheckerHooks.waiting.call(!!this.tslint);
}
if (!this.silent && this.logger) {
this.logger.info(
Expand All @@ -567,10 +563,7 @@ class ForkTsCheckerWebpackPlugin {
this.doneCallback();
} else {
if (this.compiler) {
this.compiler.applyPlugins(
legacyHookMap.waiting,
this.tslint !== false
);
this.compiler.applyPlugins(legacyHookMap.waiting, !!this.tslint);
}
if (!this.silent && this.logger) {
this.logger.info(
Expand Down
13 changes: 13 additions & 0 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ async function run(cancellationToken: CancellationToken) {
diagnostics = await checker.getDiagnostics(cancellationToken);
if (checker.hasLinter()) {
lints = checker.getLints(cancellationToken);
lints = lints.map(lint => {
if (lint.file) {
const unwrappedFileName = unwrapFileName(lint.file);

if (unwrappedFileName !== lint.file) {
return new NormalizedMessage({
...lint.toJSON(),
file: unwrappedFileName
});
}
}
return lint;
});
}

diagnostics = diagnostics.map(diagnostic => {
Expand Down

0 comments on commit bd913cd

Please sign in to comment.