mirror of
https://github.com/Turfjs/turf.git
synced 2025-12-08 20:26:16 +00:00
* Upgrade rollup to fix @turf/turf build issue * prettier issues * Fix broken test Co-authored-by: Matt Fedderly <mfedderly@palantir.com>
27 lines
632 B
JavaScript
27 lines
632 B
JavaScript
export default function validES5() {
|
|
return {
|
|
name: "valid-es5",
|
|
renderChunk(code) {
|
|
removeComments(code)
|
|
.match(/[\w\=\>]+/g)
|
|
.forEach((word) => {
|
|
switch (word) {
|
|
case "const":
|
|
case "let":
|
|
case "=>":
|
|
throw new Error(word + " is not valid ES5 syntax");
|
|
}
|
|
});
|
|
return code;
|
|
},
|
|
};
|
|
}
|
|
|
|
function removeComments(code) {
|
|
// Remove comments block comments
|
|
code = code.replace(/\/\*\*[\w\s*\.@{}|<>,=()[\];\/\-'`":]+\*\//g, "");
|
|
// Remove inline comments
|
|
code = code.replace(/\/\/.+\n/g, "\n");
|
|
return code;
|
|
}
|