Replies: 6 comments 4 replies
-
top level await is still in stage 3. eslint supports only stage 4 proposals. |
Beta Was this translation helpful? Give feedback.
-
to support stage<4 features, please use |
Beta Was this translation helpful? Give feedback.
-
Ok in case anyone stumbles down the rabbit hole of "non-babel stage 3 espree", I believe this is working: in your
Then in this file, inject whatever extensions you want and expose as an eslint parser (e.g. by copying the contents of "use strict";
const acorn = require("acorn");
const stage3 = require("acorn-stage3");
const espree = require("espree/lib/espree");
// To initialize lazily.
const parsers = {
_regular: null,
get regular() {
if (this._regular === null) {
// here
this._regular = acorn.Parser.extend(espree()).extend(stage3);
}
return this._regular;
},
get(options) {
return this.regular;
},
};
function tokenize(code, options) {
const Parser = parsers.get(options);
// Ensure to collect tokens.
if (!options || options.tokens !== true) {
options = Object.assign({}, options, {tokens: true}); // eslint-disable-line no-param-reassign
}
return new Parser(options, code).tokenize();
}
function parse(code, options) {
const Parser = parsers.get(options);
return new Parser(options, code).parse();
}
exports.parseForESLint = function (code, options) {
return {
ast: parse(code, options),
services: null,
scopeManager: null,
visitorKeys: null,
};
}; |
Beta Was this translation helpful? Give feedback.
-
top level await is Stage 4 now IMHO #13178 should be opened up again. |
Beta Was this translation helpful? Give feedback.
-
It's been a year. Is this project relevant going forward or have everyone moved on to something else? |
Beta Was this translation helpful? Give feedback.
-
TLA has been supported in eslint v8(ecmaVersion:2022). |
Beta Was this translation helpful? Give feedback.
-
Can someone re-open this issue? #13178
Top-level await is supported in Node v15 but I'm getting this error when using them:
As an aside, is there a way to disable parsing errors?
Beta Was this translation helpful? Give feedback.
All reactions