-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: use this with HTML in Javascript template literals #196
Comments
@RobertAKARobin Agree! Thanks for the suggestion. I can't think of a way to implement this off the top of my head, but it seems like a useful feature. |
It would be awesome for Lit webcomponents linting. I didn't find any project doing this for eslint. |
I'm working on this 👍 |
Hi @RobertAKARobin, @jpradelle I'm happy to announce that this feature has been implemented and deployed in 0.29.0.
npm install -D @html-eslint/eslint-plugin@0.29.0 @html-eslint/parser@0.29.0
import eslintHTML from "@html-eslint/eslint-plugin";
import eslintHTMLParser from "@html-eslint/parser";
export default [
{
"plugins": {
"@html-eslint": eslintHTML
},
"rules": {
// Specifies the @html-eslint rules to apply to Template Literal.
"@html-eslint/no-inline-styles": 1,
"@html-eslint/indent": 1,
}
},
{
"files": ["**/*.html"],
"languageOptions": {
parser: eslintHTMLParser,
},
"plugins": {
"@html-eslint": eslintHTML,
},
"rules": {
// Specifies the @html-eslint rule to apply to HTML files.
"@html-eslint/no-inline-styles": 1
}
},
]
// TaggedTemplateExpression
html`
<div style="${style}">
^^^^^^^^^^^^^^^// Unexpected usage of inline style
</div>`;
// TemplateLiteral
const code = /* html */`
<div style="${style}">
^^^^^^^^^^^^^^^// Unexpected usage of inline style
</div>`
{
"plugins": {
"@html-eslint": eslintHTML
},
settings: {
html: {
templateLiterals: {
// default options
tags: ["^html$"],
comments: ["^\\s*html\\s*$"],
}
}
},
} |
Awesome, thanks a lot ! Works great for a lot of rules. But I have an issue with indent rule: #241 |
The
/*html*/
/html
template literal syntax is used by several libraries, like Lit:It would be nice if html-eslint could be run on Javascript template literals like this.
See also https://github.com/pushqrdx/vscode-inline-html
The text was updated successfully, but these errors were encountered: