Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Allow the user to suppress the warning from typescript-estree if they are using an unsupported
* version of TypeScript
*/
const warnOnUnsupportedTypeScriptVersion = validateBoolean(
options.warnOnUnsupportedTypeScriptVersion,
true,
);
if (!warnOnUnsupportedTypeScriptVersion) {
parserOptions.loggerFn = false;
}
const { ast, services } = parseAndGenerateServices(code, parserOptions);
ast.sourceType = options.sourceType;
simpleTraverse(ast, {
enter(node) {
switch (node.type) {
// Function#body cannot be null in ESTree spec.
case 'FunctionExpression':
if (!node.body) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
node.type = `TSEmptyBody${node.type}` as any;
}
break;
// no default
}
},
});
const scopeManager = analyzeScope(ast, options);
return { ast, services, scopeManager, visitorKeys };