Editor API to disable JSHint
In an effort to better support TypeScript/JSX and ES modules, we have built PlayBuild a chrome extension that ships with an in-editor compiler that can handle TypeScript.
Although the Monaco editor ships with an inbuilt linter it has been disabled in PlayCanvas in favor of JSHint which does not work with TypeScript. This means that although any TypeScript code used in the editor can be successfully compiled, it won't be recognized by JSHint which defeats much of the purpose of using TypeScript.
If JSHint could be disabled, it would be trivial to use Moncaco's inbuilt linter which could also perorm semantic validation and code completion for TypeScript files.
Feature Request
An editor API to disable JSHint from running in the PlayCanvas code editor. This would allow 3rd party extensions such as PlayBuild to optionally override JSHint and use the inbuilt Monaco Editor TypeScript linter.
I think this might be because the script file that gets created is actually a .js under the hood so the Code Editor is opening it up as a JS file rather than TS 🤔
How are you creating the TS files via your extension?
The scripts are just created by the user in the editor and interpreted as TS files which all works fine.
The editor however passes any user code to JSHint using this /code-editor-v2/monaco-panel/jshint.js. Because JSHint doesn't understand TS it will flag errors and highlight them in the Monaco editor. If this linter could be disabled then the Monaco editor would just naturally lint both JS and TS.
Can you share an example project for us to take a look at please? Wondering if we can just disable the linter for non .js files.
If you take a look at this project and open the Point.js class. Note that you do not need the PlayBuild extension installed.
Open the Point class and it will highlight a number of errors in the file because it treats it as javascript...

You can manually set the language of the file by running monaco.editor.setModelLanguage(editor.call('editor:focusedView'), 'typescript'); in the dev tools which will change the Monaco language and remove any errors. However if you make a valid code change to the file it will call JSHint which will does not understand the TS type syntax and flag errors

Ideally there would be an API that could change the language of the file in Monaco that would also disable JSHint
If there was an editor api method editor.call('editor:linting', false) that would disable jshint, that would be great.
I kind of what to see if this is because you can't create .ts files as code editable files in the Editor yet.
It feels like the proper fix here would be to allow creation of .ts files so that the code editor can treat as Typescript and not Javascript.
Not sure what you mean by 'can't create editable files'.
I think JSHint actually overrides any linting done in Monaco, so updating the Monaco language won't actually change existing behaviour. But as JSHint doesn't parse TS files anyway, it would need to be disabled/removed if TypeScript ever became officially supported.
Also just to clarify, this feature request is simply to provide an Editor API to disable JSHint. It wouldn't change how the editor currently behaves
Not sure what you mean by 'can't create editable files'.
I don't think it's possible to create a Script Asset file (that can be edited in the Code Editor) that ends in .ts. The asset name may be .ts but under the hood I think it's .js hence asking your for an example project.
Also just to clarify, this feature request is simply to provide an Editor API to disable JSHint. It wouldn't change how the editor currently behaves
Long term we will be adding a TS workflow in the Editor so I'm just thinking of a solution that would work for the situation now and when we start adding TS support.
That said, we could add a Code Editor option to enable/disable JS Hint like we do for wordwrap etc
Yep that makes sense. I think the file suffix is somewhat independent as it's all just loaded into the editor as plain text.
I think if TS will be officially supported in the long term, then you'll need a mechanism to conditionally disable jshint on certain files, so providing an API for this would be useful in the longe run