Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async validate({asset, config, options}) {
let ts = await options.packageManager.require('typescript', asset.filePath);
// This should never happen...
if (!config) return;
let {baseDir, configHash, tsconfig} = config;
if (tsconfig && !langServiceCache[configHash]) {
let parsedCommandLine = ts.parseJsonConfigFileContent(
tsconfig,
ts.sys,
baseDir,
);
langServiceCache[configHash] = ts.createLanguageService(
new LanguageServiceHost(options.inputFS, ts, parsedCommandLine),
ts.createDocumentRegistry(),
);
}
if (!langServiceCache[configHash]) return;
const diagnostics = langServiceCache[configHash].getSemanticDiagnostics(
asset.filePath,
);
let validatorResult = {
warnings: [],
errors: [],
};
if (diagnostics.length > 0) {