How to use the @typescript-eslint/typescript-estree.simpleTraverse function in @typescript-eslint/typescript-estree

To help you get started, we’ve selected a few @typescript-eslint/typescript-estree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github typescript-eslint / typescript-eslint / packages / parser / src / parser.ts View on Github external
/**
   * 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 };

@typescript-eslint/typescript-estree

A parser that converts TypeScript source code into an ESTree compatible form

MIT
Latest version published 6 days ago

Package Health Score

95 / 100
Full package analysis