From 5b5343bb7a9ed207486093627fbd5cd50dc31c83 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Tue, 6 Jul 2021 17:54:42 +0200 Subject: [PATCH] Replace buntis with typescript-estree The buntis git repo has been deleted by upstream, so we shouldn't rely on it. --- package.json | 7 ++++--- src/typescript-extract.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5920904..494e945 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,11 @@ "author": "Polyconseil", "license": "MIT", "devDependencies": { - "@types/jest": "^26.0.14", + "@types/jest": "^26.0.14" "codecov": "^3.8.0", "eslint": "^7.10.0", - "jest": "^26.5.2" + "jest": "^26.5.2", + "typescript": "^4.2.0" }, "engines": { "node": ">=8" @@ -36,7 +37,7 @@ "acorn": "^7.4.0", "acorn-stage3": "^4.0.0", "acorn-walk": "^8.0.0", - "buntis": "0.2.1", + "@typescript-eslint/typescript-estree": "^4.0.0", "cheerio": "^1.0.0-rc.3", "estree-walker": "^2.0.1", "flow-remove-types": "^2.135.0", diff --git a/src/typescript-extract.js b/src/typescript-extract.js index f3dda93..e6263ef 100644 --- a/src/typescript-extract.js +++ b/src/typescript-extract.js @@ -1,5 +1,5 @@ const {walk} = require('estree-walker'); -const {parseTSScript} = require('buntis'); +const {parse} = require('@typescript-eslint/typescript-estree'); const extractUtils = require('./extract-utils.js'); const {DEFAULT_VUE_GETTEXT_FUNCTIONS} = require('./constants.js'); @@ -41,8 +41,9 @@ function getTranslationObject(node, gettextFunctionName, filename) { } function getGettextEntriesFromTypeScript(script, filename) { - let translationEntries = []; - walk(parseTSScript(script, {loc: true, next: true}), { + const translationEntries = []; + const ast = parse(script, { loc: true, range: true }); + walk(ast, { enter: function(node) { if (node.type && node.type === 'CallExpression' && node.callee) { if (DEFAULT_VUE_GETTEXT_FUNCTIONS_KEYS.includes(node.callee.name)) {