Skip to content

[Feature request] ESLint plugin #183

Closed

Description

@Fordi

For the most part this just works, but functions within tagged markup get weird indent assertions, e.g.,

        ${collection.map((item) => {
          const { prop1, prop2 } = workWith(item);  // eslint: expected indentation of 4 but found 10 (indent)
          return html`  // eslint: expected indentation of 4 but found 10 (indent)
            <${Widget} prop1=${prop1} prop2=${prop2} />
          `;
        })} // eslint: expected indentation of 2 but found 8 (indent)

So I'd request an eslint plugin where you could specify the name of the template function, and make the linter comprehend it, or directions to the resources I'd need to implement one.

Activity

  1. Fordi commented on Oct 22, 2020

    @Fordi
    Author

    I found eslint-plugin-lit, which works, albeit by disabling lit/binding-positions (👍 ) and lit/no-invalid-html (😢 ). It doesn't fix the indent comprehension, though. If anyone has any further tips, I'd love to hear 'em.

  2. reopened this on Oct 22, 2020
  3. developit commented on Feb 5, 2021

    @developit
    Owner

    Starting from the Lit plugin is a great idea - I'd begun hacking on something, but quickly realized it was going to take a lot more work than I had time to prototype:
    https://gist.github.com/developit/61d009284458ad4d757991e1756b7f41

  4. ruffin-- commented on Apr 4, 2022

    @ruffin--

    It looks like spread attributes are also a show-stopping issue with eslint.

    TIL:

    Spread props: <div ...${props}> instead of <div {...props}>

  5. GGabrielDev commented on Jan 1, 2023

    @GGabrielDev

    This is kinda old, I know, but there's no progress with this? Would be nice to integrate EsLint to my project knowing that it will work out nicely with HTM.

    Sadly, I'm still not savvy enough to write my own EsLint plugin :(

  6. mtsknn commented on Oct 9, 2024

    @mtsknn

    @Fordi Did you manage to find an ESLint plugin for HTM, given that you closed this issue?

  7. Fordi commented on Oct 11, 2024

    @Fordi
    Author

    No. But the lit plugin with some configuration to allow for htm's wider syntax support has been "good enough" for the last few years. Mostly, I closed it (and a lot of other outstanding issues that don't look like they're getting fixed any time soon) because I use my GitHub issues at my new job to track active work, and this issue is kinda just polluting that.

  8. mtsknn commented on Oct 11, 2024

    @mtsknn

    But the lit plugin with some configuration to allow for htm's wider syntax support has been "good enough" for the last few years.

    That's good to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions