-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Band-Aid fix for the bootleg eslint #1092
Conversation
not sure why 'latest' is not working, but this fixes the annoying errors related to es5 being default
Ah, I found out why.... in the eslint file at var DEFAULT_ECMA_VERSION = 5;
var STATE = Symbol("espree's internal state");
var ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
var tokTypes = Object.assign({}, acorn.tokTypes, jsx.tokTypes);
/**
* Normalize ECMAScript version from the initial config
* @param {number} ecmaVersion ECMAScript version from the initial config
* @returns {number} normalized ECMAScript version
*/
function normalizeEcmaVersion(ecmaVersion) {
if (typeof ecmaVersion === "number") {
var version = ecmaVersion;
// Calculate ECMAScript edition number from official year version starting with
// ES2015, which corresponds with ES6 (or a difference of 2009).
if (version >= 2015) {
version -= 2009;
}
switch (version) {
case 3:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
return version;
default:
throw new Error("Invalid ecmaVersion.");
}
} else {
return DEFAULT_ECMA_VERSION;
}
} |
Hi, can you elaborate on what you mean with "annoying errors related to es5 being default for parsing." – just for my understanding what the issues are :-) thanks |
On all the JS frontend/backend (easy to see during widget development) eslint parses the code and gives "error Parsing error: The keyword 'const' is reserved" and therefore it is displayed as a code mistake. This also stops the further parsing of the rest of the code. This is because (as per https://www.w3schools.com/js/js_versions.asp) For this project we use node JS 22 which technically is ES15, but unfortunately, this implementation of ESLint is old and therefore can only go up to 10. But 10 is better than 5! The proper fix would be to use the ESLint npm package, but I guess that is difficult because in this case, eslint is running client side |
This error was reported in the previous repo as well. |
thanks for the clarification!
this was brought up previously, I've now created a separate task to track this: #1094 |
Ah nice. Is someone working on it already? If not I can try for a sec |
no, I don't think anyone is working on this, so if you are up for it, feel free and give it a shot |
Any idea of why I still get the parser error even after adding this modification? I also get the parser error for class also being reserved if I change const to var. here is the code
|
Which one specifically do you get? |
I suspect you are actually getting a parsing error that says 'Unexpected token api' This is because for some reason trillium is not able to pass the api object to eslint... I have looked into it a little bit, but not figured out a solution yet |
I will |
not sure why 'latest' is not working, but this fixes the annoying errors related to es5 being default for parsing.
Anything more recent than 2019 does not work unfortunately.