How to use the @typescript-eslint/typescript-estree.parse 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 brodybits / prettierx / src / language-js / parser-typescript.js View on Github external
function tryParseTypeScript(text, jsx) {
  const parser = require("@typescript-eslint/typescript-estree");
  return parser.parse(text, {
    loc: true,
    range: true,
    tokens: true,
    comment: true,
    useJSXTextNode: true,
    jsx
  });
}
github typescript-eslint / typescript-eslint / packages / benchmark / parsers.js View on Github external
function runTSESTree(directory, files) {
  for (const file of files) {
    const result = tsEstree.parse(
      fs.readFileSync(path.join(__dirname, file), 'utf8'),
      {
        comment: true,
        tokens: true
      }
    );
    if (result.type !== 'Program') {
      throw new Error('something went wrong');
    }
  }
}
github Halliwood / ts2lua / index.js View on Github external
function collectClass(filePath) {
    var fileContent = fs.readFileSync(filePath, 'utf-8');
    var parsed = parser.parse(fileContent);
    astMap[filePath] = parsed;
    tc.collect(parsed);
}
function doTranslateFile(filePath) {
github Halliwood / ts2lua / index.js View on Github external
function translate(tsCode, option) {
    processOption(option);
    var parsed = parser.parse(tsCode);
    tc.collect(parsed);
    lm.setClassMap(tc.classMap, tc.moduleMap, tc.enumMap);
    var luaCode = lm.toLuaBySource(parsed);
    collectUnknowRegex();
    return luaCode;
}
exports.translate = translate;
github doyensec / electronegativity / src / parser / parser.js View on Github external
parseTypescriptEstree(content) {
    let data = typescriptEstreeParser.parse(content, {
      loc: true,
      range: true,
      tokens: true,
      errorOnUnknownASTType: true,
      useJSXTextNode: true,
      ecmaFeatures: {
        jsx: true,
        modules: true
      }
    });

    data.astParser = this.esLintESTreeAst;
    data.Scope = {}; //new Scope(data);
    data.Scope.resolveVarValue = (astNode) => astNode.arguments[0];
    data.Scope.updateFunctionScope = () => {};
    return data;

@typescript-eslint/typescript-estree

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

BSD-2-Clause
Latest version published 6 days ago

Package Health Score

98 / 100
Full package analysis