Open marcolubian opened 1 year ago
Hi. Could you try out whether ace-linters would be better for you?
Hi. Could you try out whether ace-linters would be better for you?
It seems that the javascript lint case available in their example https://mkslanc.github.io/ace-linters/default_services.html is affected by the same issue. It allows the top level await only if the script is expected to be a module and suggests to add a export {}
clause to force it as a module, but it's not my case.
@marcolubian Hi! If you need just to ignore that error, you could use ace-linters with
languageProvider.setGlobalOptions("typescript", {
errorCodesToIgnore: [
"1375"
]
});
@marcolubian Hi! If you need just to ignore that error, you could use ace-linters with
languageProvider.setGlobalOptions("typescript", { errorCodesToIgnore: [ "1375" ] });
Can this only be used with typescript? Are there any examples for javascript?
@marcolubian Hi! If you need just to ignore that error, you could use ace-linters with
languageProvider.setGlobalOptions("typescript", { errorCodesToIgnore: [ "1375" ] });
Can this only be used with typescript? Are there any examples for javascript?
It's just service name - it supports typescript, tsx, javascript and jsx
Hi. Could you try out whether ace-linters would be better for you?
It seems that the javascript lint case available in their example https://mkslanc.github.io/ace-linters/default_services.html is affected by the same issue. It allows the top level await only if the script is expected to be a module and suggests to add a
export {}
clause to force it as a module, but it's not my case.
Is your problem solved?
I've read the javascript-service.js and found that the current version of ace-linters does not support 'errorCodesToIgnore' and 'errorMessagesToIgnore'. Maybe I'm wrong.The best approach is to set a Reg by 'errorMessagesToTreatAsInfo'. Here is my code, which might help people who encounter this problem in the future.
const worker = new Worker(new URL('./webworker.ts', import.meta.url), { type: 'module' });
const languageProvider = LanguageProvider.create(worker);
languageProvider.setGlobalOptions('javascript', {
errorMessagesToTreatAsInfo: [/Unexpected token this/, /Missing ";" before statement/],
});
languageProvider.registerEditor(editor.value);
However, this will affect the 'enableBasicAutocompletion' feature of Ace. Maybe I'm wrong again. I gave up finally.
@y4n6 I updated typescript service to support errorMessagesToIgnore
, also problem here was that by default for js files both eslint
and typescript
services are working in conjunction, so you saw error from eslint, which is not supporting esNext.
So here fully workable example with typescript service
And also, if you still want to use eslint, I fixed bug with non-ignored message in this service, so you could use it like that
Describe the feature
I need a way to setup the ace editor in javascript mode in order to consider its content in a top-level async context.
Note: The feature request is related to #4505
Use Case
My current limitation is that if I write this inside the editor in
javascript
mode:I have no problem, but if I do any await inside the editor itself, it goes in error:
Proposed Solution
For what I've seen, the best would be to have an option that allows to consider the script as if it was written inside an async function. For example, changing the
this.onUpdate
method of filewith something like this:
I understand that this can't be done generically, because I imagine that in other contexts someone would like to have the
await
commands highlighted as errors. Maybe this could be conditioned by an option (the async wrapping could be done with a parameter), I was imagining something liketopLevelAsync
or something like that...Other Information
No response
Acknowledgements
ACE version used
Ace builds 1.30.0