mirror of https://github.com/espruino/BangleApps
sanitycheck: parse ecma2020 constructs (`??`)
parent
d3dc3b469f
commit
a8f1aa97e5
|
@ -10,18 +10,24 @@ apploader.init({
|
|||
DEVICEID : "BANGLEJS2"
|
||||
});*/
|
||||
|
||||
var jsparse = (() => {
|
||||
var acorn, stage3;
|
||||
try {
|
||||
acorn = require("acorn");
|
||||
stage3 = require("acorn-stage3");
|
||||
} 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("=====================================================");
|
||||
}
|
||||
var parser = acorn.Parser.extend(stage3)
|
||||
return str => parser.parse(str, { ecmaVersion: 2020 });
|
||||
})();
|
||||
|
||||
var BASEDIR = __dirname+"/../";
|
||||
var APPSDIR_RELATIVE = "apps/";
|
||||
|
@ -399,7 +405,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 +421,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,8 @@
|
|||
"version": "0.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn": "^7.2.0"
|
||||
"acorn": "^7.2.0",
|
||||
"acorn-stage3": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
|
@ -454,6 +455,21 @@
|
|||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-class-fields": {
|
||||
"version": "0.3.7",
|
||||
"resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-0.3.7.tgz",
|
||||
"integrity": "sha512-jdUWSFce0fuADUljmExz4TWpPkxmRW/ZCPRqeeUzbGf0vFUcpQYbyq52l75qGd0oSwwtAepeL6hgb/naRgvcKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn-private-class-elements": "^0.2.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.8.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"acorn": "^6 || ^7 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-jsx": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
||||
|
@ -463,6 +479,65 @@
|
|||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-private-class-elements": {
|
||||
"version": "0.2.7",
|
||||
"resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-0.2.7.tgz",
|
||||
"integrity": "sha512-+GZH2wOKNZOBI4OOPmzpo4cs6mW297sn6fgIk1dUI08jGjhAaEwvC39mN2gJAg2lmAQJ1rBkFqKWonL3Zz6PVA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=4.8.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.1.0 || ^7 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-private-methods": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn-private-methods/-/acorn-private-methods-0.3.3.tgz",
|
||||
"integrity": "sha512-46oeEol3YFvLSah5m9hGMlNpxDBCEkdceJgf01AjqKYTK9r6HexKs2rgSbLK81pYjZZMonhftuUReGMlbbv05w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn-private-class-elements": "^0.2.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.8.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"acorn": "^6 || ^7 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-stage3": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-stage3/-/acorn-stage3-4.0.0.tgz",
|
||||
"integrity": "sha512-BR+LaADtA6GTB5prkNqWmlmCLYmkyW0whvSxdHhbupTaro2qBJ95fJDEiRLPUmiACGHPaYyeH9xmNJWdGfXRQw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn-class-fields": "^0.3.7",
|
||||
"acorn-private-methods": "^0.3.3",
|
||||
"acorn-static-class-features": "^0.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.8.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"acorn": "^7.4 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-static-class-features": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "https://registry.npmjs.org/acorn-static-class-features/-/acorn-static-class-features-0.2.4.tgz",
|
||||
"integrity": "sha512-5X4mpYq5J3pdndLmIB0+WtFd/mKWnNYpuTlTzj32wUu/PMmEGOiayQ5UrqgwdBNiaZBtDDh5kddpP7Yg2QaQYA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"acorn-private-class-elements": "^0.2.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.8.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.1.0 || ^7 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "6.12.6",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||
|
@ -3781,6 +3856,14 @@
|
|||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
|
||||
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A=="
|
||||
},
|
||||
"acorn-class-fields": {
|
||||
"version": "0.3.7",
|
||||
"resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-0.3.7.tgz",
|
||||
"integrity": "sha512-jdUWSFce0fuADUljmExz4TWpPkxmRW/ZCPRqeeUzbGf0vFUcpQYbyq52l75qGd0oSwwtAepeL6hgb/naRgvcKQ==",
|
||||
"requires": {
|
||||
"acorn-private-class-elements": "^0.2.7"
|
||||
}
|
||||
},
|
||||
"acorn-jsx": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
||||
|
@ -3788,6 +3871,38 @@
|
|||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"acorn-private-class-elements": {
|
||||
"version": "0.2.7",
|
||||
"resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-0.2.7.tgz",
|
||||
"integrity": "sha512-+GZH2wOKNZOBI4OOPmzpo4cs6mW297sn6fgIk1dUI08jGjhAaEwvC39mN2gJAg2lmAQJ1rBkFqKWonL3Zz6PVA==",
|
||||
"requires": {}
|
||||
},
|
||||
"acorn-private-methods": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn-private-methods/-/acorn-private-methods-0.3.3.tgz",
|
||||
"integrity": "sha512-46oeEol3YFvLSah5m9hGMlNpxDBCEkdceJgf01AjqKYTK9r6HexKs2rgSbLK81pYjZZMonhftuUReGMlbbv05w==",
|
||||
"requires": {
|
||||
"acorn-private-class-elements": "^0.2.7"
|
||||
}
|
||||
},
|
||||
"acorn-stage3": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-stage3/-/acorn-stage3-4.0.0.tgz",
|
||||
"integrity": "sha512-BR+LaADtA6GTB5prkNqWmlmCLYmkyW0whvSxdHhbupTaro2qBJ95fJDEiRLPUmiACGHPaYyeH9xmNJWdGfXRQw==",
|
||||
"requires": {
|
||||
"acorn-class-fields": "^0.3.7",
|
||||
"acorn-private-methods": "^0.3.3",
|
||||
"acorn-static-class-features": "^0.2.4"
|
||||
}
|
||||
},
|
||||
"acorn-static-class-features": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "https://registry.npmjs.org/acorn-static-class-features/-/acorn-static-class-features-0.2.4.tgz",
|
||||
"integrity": "sha512-5X4mpYq5J3pdndLmIB0+WtFd/mKWnNYpuTlTzj32wUu/PMmEGOiayQ5UrqgwdBNiaZBtDDh5kddpP7Yg2QaQYA==",
|
||||
"requires": {
|
||||
"acorn-private-class-elements": "^0.2.7"
|
||||
}
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.12.6",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"update-local-apps": "apps/*/metadata.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": "^7.2.0"
|
||||
"acorn": "^7.2.0",
|
||||
"acorn-stage3": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue