-
Notifications
You must be signed in to change notification settings - Fork 22
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
Limit rules to templates tagged with lit-html's html tag #17
Comments
Maybe this should only apply to a subset of the rules. Many of them can apply to both polymer and lit (such as invalid-html, etc). It is probably best we make the lit-specific ones check that they are imported from lit, if possible. So:
Probably these are lit-only. |
There are other base classes which use lit html, so its a bit tricky. |
The other base classes will still use |
Ah, right. Yeah, though can you follow the export chain to lit-html? In our case our base class re-exports the html tag from lit-html. LitElement does that too. |
ESLint is meant to operate on a per-file basis, we should be avoiding trying to traverse ASTs of other files (as it means you couldn't So while this could be achieved, it may have to be "best effort":
|
That makes sense. I would revert the default personally :) |
Some of these rules apply to more than just lit-html, any module which processes HTML in JS templates. I understand that |
Might make sense to have a setting for excluding/including certain modules where |
eslint supports overriding rules for specific file globs, maybe this module could make it easier to use that functionality, support something like: {
"extends": ["plugin:lit/recommended"],
"env": {"browser": true},
"overrides": [
{
"files": ["html/polymer-component-1.js", "html/legacy/**/*.js"],
"extends": ["plugin:lit/recommended-polymer"]
}
]
} Where the https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns |
Just wanted to point out that this issue can adversely affect actual lit templates as well. Not considering the import { html as myTag } from "lit";
// Not linted
const myTemplate = myTag`<>`; |
yep it may be that we just need to be more explicit about where originally we wanted to avoid that so people could import |
Why not just let users configure how they want? settings: {
"lit/modules": {
lit: ["html", "svg", "css"],
"@polymer/polymer/lib/utils/html-tag": ["html"],
},
}, |
we could, eslint-plugin-wc does similar for whitelisted base classes allowing it to be strict against an import path would be good. but a start would be just allowing control of the const names |
I guess that would help, but then it's too easy IMO to create a template that doesn't get linted by using a name that's not in the settings. Specifying the module identifiers and the actual tag names imported from them is much more fixed and thus less prone to error. |
I'm introducing Lit Element into my Polymer 3 project. I won't be able to convert all elements to Lit from the get go and so have a mix of Polymer 3 and Lit Elements.
The issue is that the rules will scan based on finding a template literal expression started with a
html
tag, however that is also how Polymer 3 functions (example.A fix for this would be to add a check that the html tag that is used was imported from the lit-html package (lit-element re-exports html from lit-html).
The text was updated successfully, but these errors were encountered: