Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function parseVueSourceFile(fileContent: string): SourceCode | ParsingError {
let exceptionToReport: ParseException | null = null;
for (const config of [PARSER_CONFIG_MODULE, PARSER_CONFIG_SCRIPT]) {
try {
const result = VueJS.parseForESLint(fileContent, config);
return new SourceCode(fileContent, result.ast as any);
} catch (exception) {
exceptionToReport = exception;
}
}
// if we reach this point, we are sure that "exceptionToReport" is defined
return {
line: exceptionToReport!.lineNumber,
message: exceptionToReport!.message,
code: ParseExceptionCode.Parsing,
};
}