forked from FOSS/BangleApps
Merge pull request #3653 from bobrippling/fix/sanity-check-acorn
sanitycheck: parse ecma2020 constructs (`??`)master
commit
478a43fcff
|
@ -10,18 +10,22 @@ apploader.init({
|
|||
DEVICEID : "BANGLEJS2"
|
||||
});*/
|
||||
|
||||
var jsparse = (() => {
|
||||
var acorn;
|
||||
try {
|
||||
acorn = require("acorn");
|
||||
} catch (e) {
|
||||
console.log("=====================================================");
|
||||
console.log(" ACORN NOT FOUND");
|
||||
console.log(" ---------------");
|
||||
console.log("");
|
||||
console.log(" This means we won't sanity-check uploaded JSON");
|
||||
console.log("=====================================================");
|
||||
return str => {throw new Error("no acorn")};
|
||||
}
|
||||
|
||||
var acorn;
|
||||
try {
|
||||
acorn = require("acorn");
|
||||
} catch (e) {
|
||||
console.log("=====================================================");
|
||||
console.log(" ACORN NOT FOUND");
|
||||
console.log(" ---------------");
|
||||
console.log("");
|
||||
console.log(" This means we won't sanity-check uploaded JSON");
|
||||
console.log("=====================================================");
|
||||
}
|
||||
return str => acorn.parse(str, { ecmaVersion: 2020 });
|
||||
})();
|
||||
|
||||
var BASEDIR = __dirname+"/../";
|
||||
var APPSDIR_RELATIVE = "apps/";
|
||||
|
@ -399,7 +403,7 @@ apps.forEach((app,appIdx) => {
|
|||
if (file.supports && !Array.isArray(file.supports)) ERROR(`App ${app.id} file ${file.name} supports field is not an array`, {file:metadataFile});
|
||||
if (file.evaluate) {
|
||||
try {
|
||||
acorn.parse("("+fileContents+")");
|
||||
jsparse("("+fileContents+")");
|
||||
} catch(e) {
|
||||
console.log("=====================================================");
|
||||
console.log(" PARSE OF "+appDir+file.url+" failed.");
|
||||
|
@ -415,7 +419,7 @@ apps.forEach((app,appIdx) => {
|
|||
// TODO: actual lint?
|
||||
var ast;
|
||||
try {
|
||||
ast = acorn.parse(fileContents);
|
||||
ast = jsparse(fileContents);
|
||||
} catch(e) {
|
||||
console.log("=====================================================");
|
||||
console.log(" PARSE OF "+appDir+file.url+" failed.");
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"version": "0.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn": "^7.2.0"
|
||||
"acorn": "^8.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
|
@ -444,9 +444,10 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "7.4.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
|
||||
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz",
|
||||
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
|
@ -1309,18 +1310,6 @@
|
|||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/espree/node_modules/acorn": {
|
||||
"version": "8.11.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
||||
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/esquery": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz",
|
||||
|
@ -3777,9 +3766,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
"version": "7.4.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
|
||||
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A=="
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz",
|
||||
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA=="
|
||||
},
|
||||
"acorn-jsx": {
|
||||
"version": "5.3.2",
|
||||
|
@ -4424,14 +4413,6 @@
|
|||
"acorn": "^8.9.0",
|
||||
"acorn-jsx": "^5.3.2",
|
||||
"eslint-visitor-keys": "^3.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": {
|
||||
"version": "8.11.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
||||
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"esquery": {
|
||||
|
|
|
@ -27,6 +27,6 @@
|
|||
"update-local-apps": "apps/*/metadata.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": "^7.2.0"
|
||||
"acorn": "^8.0.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue