Skip to content
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

Parsing error: Declaration or statement expected. ESLint(FATAL) #265

Closed
2 tasks done
FDiskas opened this issue Oct 3, 2023 · 5 comments
Closed
2 tasks done

Parsing error: Declaration or statement expected. ESLint(FATAL) #265

FDiskas opened this issue Oct 3, 2023 · 5 comments
Labels
needs repro Need a repository that can reproduce the problem Stale

Comments

@FDiskas
Copy link

FDiskas commented Oct 3, 2023

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.50.0

What version of eslint-plugin-astro are you using?

0.29.1

What did you do?

My goal was to remove white space from the icon and a component. So I used <!-- WHITESPACE --> HTML comment hack.
But in this case, I get a parsing error at a random location
image

---
import { Sprite } from 'astro-icon';
import CategoryNavItem from '@components/menu/CategoryNavItem.astro';
import type { CategoryLinkItem } from 'src/const/links.ts';

interface Props {
  items: CategoryLinkItem[];
  class?: string;
  id?: string | number;
}

const { items, class: className = 'pl-0', id = '' } = Astro.props;
---

<!-- CategoryNav -->
<ul class="list-none" class:list={[className]}>
  {
    items.map((item) => (
      <li class="overflow-hidden truncate">
        {item.children != null ? (
          <label class="text-black dark:text-white">
            <input type="radio" name={`categoryList-${id}`} class="peer hidden" />
            <Sprite
              name="arrow"
              class="w-24 h-24 inline cursor-pointer -rotate-90 peer-checked:rotate-0 peer-checked:text-red"
            /><!--
             --><CategoryNavItem item={item} class="peer-checked:text-red" />
            <Astro.self items={item.children} class="pl-24 hidden basis-full peer-checked:block" id={item.id} />
          </label>
        ) : (
          <CategoryNavItem item={item} class="pl-24 text-black dark:text-white" />
        )}
      </li>
    ))
  }
</ul>

What did you expect to happen?

It should allow me to write the wrong HTML syntax or use an HTML comment hack

What actually happened?

It displays

Parsing error: Declaration or statement expected.ESLint(FATAL)

at the random file location if I use HTML comment

Link to Minimal Reproducible Example

Repository: https://github.com/FDiskas/eslint-plugin-astro-parsing-error

Possible reproduction
https://ota-meshi.github.io/eslint-plugin-astro/playground/#eJyFVctu3DgQ/BWtjkEIIbs3Y3ZuC+QP9jIXimpJXLdILh/2KIb/PUVqRo+JjRwMu6vLzX5Ut95qZTuqn2ohxMU0X6p/iZWdqIq2osDaROE4DdoIGaK31ZfmYgr1JH3Uiul8MVV1Gr9VimUIf1/qSNco/rrypT6/RR2Z3k/N+G2hufN3Yranxi22Ni7F43+2LNVz1Un//FTs11FHutSZXlXN+fRHfvwf762vvpOnjAtxvkWKsyME8rLT9lKvgR2Rr0bddWSANsvbDcuWGH+fmq2U+mvtE1Oon97qUnBjrAgUxRgnFp32pKJ+Qb/+/Hr0l1w/8SeTAnVChQAqg2H9juA89eRFyVWwDh+HubFs+x9cO/KvlOBYf8IINOliKmsApJyJCMnRkk8P6/a2NQUZKEaE9BSTXxCUI8NslHDeTjqQoCupdK8IXiUBdoT3vcxxwuooGeFHD2soKM1JT8LQIH6Qtxtuul+oSPkjTEKima/XrBcPCmZkPtD1DnbUpmEgv9lMkcSL3BD0Qkg/hAOwZD7R1JI/eohRrO4P2DPNexJrJfFIbssdpcnF+WAINaJdKt51cHQ6maew1kbXhzZAel6K1lomafJL8ehZxw6kl8xx9DYN4woljPMYcWDbSn4A9eSsfxyBNi+Sdbc02q2oh50ggWV9g5NqrZ4tmml7CIiUDruZQU4ooNNm+Kwdk75ij0o0KAkSibJdnYZeRZin1vKKWGNVRB2Qo57wm4KSbk0Eu4RmMa8RCvluQN/R5nsi2qQ56k3InhZ50wag9ltadwyL3j+0Kny0TGGUnX0FiH3UqLgTRk67MFiPkCXp5aaqOOogWsK60m57y6HpqN8MDIRKyCmhANxy2nyeJJrc8g4KsifRa4OWzA8o9lPu1+sGW5dBNBahtMHgNn+5eOXChgcQ67ZB+R5CDi1ufrleZDah3J3YHzU+gsdRvuq4MDz9n3DBxKyJu4KkvKHByCX3Rax5rLY/HmlcjB67Gss1Xy9wOJI6yqqVuacFQ24QGTack+ffUHtCGfkukYm/oUINlh+/IjsWzjKC+LmdA77NH35sIATMuzQbOypCnHkfb+lDPr+64O/vPwEdnsRa

Additional comments

Thank you ❤️ for any advice or fix

@ota-meshi
Copy link
Owner

The solution for now is to remove the useless </label>. @astrojs/compiler does not return a lone </label> as an AST, so it cannot parse it well.

@FDiskas
Copy link
Author

FDiskas commented Oct 4, 2023

I have a case where is no useless elements and still got such a problem . example in description

@ota-meshi ota-meshi added the needs repro Need a repository that can reproduce the problem label Oct 5, 2023
Copy link
Contributor

github-actions bot commented Dec 5, 2023

This issue is is stale because it missing information and has been open for 60 days with no activity.

@github-actions github-actions bot added the Stale label Dec 5, 2023
Copy link
Contributor

This issue has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from issues that aren't actionable. Please reach out if you have more information for us! 🙂

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Need a repository that can reproduce the problem Stale
Projects
None yet
Development

No branches or pull requests

2 participants