Issue a MuJS warning on unused dependencies
This commit is contained in:
parent
a8812bdbf0
commit
93d9df1c4c
2 changed files with 18 additions and 0 deletions
|
@ -275,6 +275,16 @@ export class Transformer {
|
|||
}
|
||||
}
|
||||
|
||||
// Also warn about dependency packages that weren't actually used.
|
||||
if (this.pkg.dependencies) {
|
||||
for (let dep of Object.keys(this.pkg.dependencies)) {
|
||||
if (!this.currentPackageDependencies.has(dep)) {
|
||||
this.diagnostics.push(this.dctx.newUnusedDependencyWarning(dep));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now create a new package object.
|
||||
return <TransformResult>{
|
||||
diagnostics: this.diagnostics,
|
||||
|
|
|
@ -221,6 +221,14 @@ export class Context {
|
|||
};
|
||||
}
|
||||
|
||||
public newUnusedDependencyWarning(pkg: tokens.PackageToken): Diagnostic {
|
||||
return {
|
||||
category: DiagnosticCategory.Warning,
|
||||
code: 4,
|
||||
message: `Package '${pkg}' was declared as a dependency but not used`,
|
||||
};
|
||||
}
|
||||
|
||||
public newAsyncNotSupportedError(node: ts.Node): Diagnostic {
|
||||
return {
|
||||
category: DiagnosticCategory.Error,
|
||||
|
|
Loading…
Reference in a new issue