Vscode-eslint: Add support for linting inside <script> tags of html files.

Created on 22 Jan 2016  路  15Comments  路  Source: microsoft/vscode-eslint

Atoms eslinter plugin recently got this, its very handy for Polymer development.

feature-request

Most helpful comment

Can't wait to get this in. Been doing a lot of .vue files and been missing linting inside my script tags.

All 15 comments

Agree, cool to have. But it requires some support in VSCode core to pass the JS part of a HTML file.

Can you not get a copy of the entire html file and just send it to the eslint with the html plugin configured?

https://github.com/BenoitZugmeyer/eslint-plugin-html

Basically you'd just need to execute linting on .html files as well as .js files and pass the whole contents of the file to eslint while configuring the html plugin. That should give you extraction of script tags without any need for support in VS Code?

right, eslint can use plugin to lint non .js files, what we need is to pass .html files to eslint.

Do you have an update on this? Is there a plan to fix? It looks like adding the HTML file type gets you 90% there.

This requires a different initialization behavior for the eslint plugin. Currently it is only activated on JS files. To support this we need to activate on 'any' files type and then let the user specify via an option which languages to validate.

This would be really awesome when cleaning up inline javascript projects.

I am working on supporting this kind of dynamic behavior in the language server protocol. As soon as this is out we can look into adopting this to lint all kind of files eslint supports.

Not sure if user has to specify languages to validate as eslint plugins register supported extensions when loaded: https://github.com/BenoitZugmeyer/eslint-plugin-html/blob/master/src/index.js#L6

Now, if vscode got several ways to validate one file format, maybe you can combine the output of all validators, because eslint could validate script tags, while other plugins may validate the HTML.

Can't wait to see this coming in your fantastic code editor!

+1 about this!

I have the eslint-plugin-html installed but doesn't work in the VSCode.

Can't wait to get this in. Been doing a lot of .vue files and been missing linting inside my script tags.

I have this working but since it is a bigger change I am looking for volunteers to test this. See comment https://github.com/Microsoft/vscode-eslint/issues/42#issuecomment-264828064 on how to install it and get it working for different file types.

Closing as dup of #42.

This is available in the 1.2.1 version of the extension

Thanks @dbaeumer!

For those that helped me testing please uninstall and reinstall the eslint plugin since the plugin will not update itlsef anymore if directly installed from a vsix. For the details see Microsoft/vscode#17290.

I apologize for the inconvenience this causes.

Was this page helpful?
0 / 5 - 0 ratings