I haven’t use VSCode for OH stuff but it looks like it’s treating this as if it were some other type of file that’s not JS. It’s probably guessing that it’s a shell script based on the file extension.
Unfortunately there is no universal way to solve this. You can either tell VS Code that .script files are in fact JS (in the settings somewhere) but then all your .script transformations must be written in JS, or live with the errors.
Please don’t. First, there is no option for that, second, there are other files in the directory which are handled by the plugin as well.
In question of the .script: this is to be expected, as there is already a a file extension .script (used in the directory scripts)
In good old days these files were used for the DSL action callScript(scriptname), which then started the DSL script stored in scripts/scriptname.script. This is also true for the current version of openHAB.
As there is no option to differentiate between the used language in the files (Go to the corner of shame ), I guess it will be hard to integrate this in the plugin.
Maybe some developer may introduce some comment at start of the file (like !# /bin/bash in shell scripts), this would also help to get rid of the explicit call for the specific language.
Maybe there will be a solution by then that will make bending the .script extension unnecessary. I suspect there will be a lot of users unhappy with the SCRIPT solution as it stands.
May be a new point for the wishlist
The script extension was chosen for technical reasons. It wasn’t feasible to use a different extension for the different languages, partially because the SCRIPT needs to be able to identify the files that belong to it regardless of what automation languages are installed.
I doubt this is something that can be surmounted.
You don’t have to do without it. You can turn off the error highlighting for those files, or turn off the syntax checks.
It’s not the case that JS doesn’t work. It’s just that VS Code can’t properly identify syntax errors.