lit-analyzer icon indicating copy to clipboard operation
lit-analyzer copied to clipboard

Support for ignore / disable comments

Open matthias-ccri opened this issue 4 years ago • 3 comments

Similarly to eslint, it would be nice to have "ignore" comments, and even "ignore next line" and "disable"/"enable".

I see there is support for @ts-ignore (ref: https://github.com/runem/lit-analyzer/issues/1), which covers a lot of use cases, but not all. It also would be good to document how to use ts-ignore in both the TS and html forms.

I noticed that a ts-ignore comment does not disable the no-missing-element-type-definition rule, as below:

@customElement('foo-fighter')
// @ts-ignore
export class FooFighter extends LitElement {
//           ~~~~~~~~~~
//           'foo-fighter' has not been registered on HTMLElementTagNameMap
//           lit-plugin(no-missing-element-type-definition)(2311)

matthias-ccri avatar Jan 26 '21 19:01 matthias-ccri

It would be great be able to ignore within the css. @ts-ignore is working for me in html and js, but not within css. Specially: I'm getting error "no-invalid-css" for "text-wrap", which is valid for Chrome and Firefox.

It would also be nice if lit-analyzer didn't consider properties invalid-css when they are wrapped in a supports at-rule.

@supports (text-wrap: balance) {
  h1 {
    text-wrap: balance;
  }
}

ardnejar avatar Dec 05 '23 19:12 ardnejar

The biggest problem with using @ts-ignore as currently implemented is that it ignores every rule in the entire tree, when all you probably need is one or two rules on one element:

return html`
<!-- @ts-ignore Disables all checks on parent and all children -->
<my-parent>
  <my-child .string=${100}>
    <my-grandchild ?boolean=${new Set()}></my-grandchild>
  </my-child>
</my-parent>
`;

The errors in descendants get ignored too. It would be nice to pass some directions in the comment to control what is ignored. For example:

return html`
<!-- @ts-ignore parent-only, lit-plugin/no-missing-import -->
<my-parent>
  <my-child .string=${100}>
    <my-grandchild ?boolean=${new Set()}></my-grandchild>
  </my-child>
</my-parent>
`;

Is this not possible as an extension of the current implementation?

steverep avatar Jan 11 '24 19:01 steverep

Hello! First off, thanks a bunch for this repo. It's incredibly handy

I am also hitting the issue described above. Is this something y'all would be open to a contribution for? Is there something else we should be doing instead? Any pointers on how this may be solved?

ynotdraw avatar Feb 07 '24 02:02 ynotdraw