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

Can I mark a file/node to be ignored? #187

Closed
jameshfisher opened this issue Nov 11, 2020 · 6 comments
Closed

Can I mark a file/node to be ignored? #187

jameshfisher opened this issue Nov 11, 2020 · 6 comments

Comments

@jameshfisher
Copy link

Here's an example page that causes an error, Parse error in inline JavaScript in test_case.html\nUnknown node type ChainExpression.

<!doctype html>
<html lang="en">
  <body>
    <script>
      foo = bar?.baz;
    </script>
  </body>
</html>

The error here is, I believe, because hyperlink doesn't know about optional chaining. That's OK: I can't expect it to understand every bleeding-edge JS experiment.

But I do expect the freedom to use bleeding-edge browser features without this causing all CI to fail. I would like to be able to mark a file/node/section as "trust me, I know what I'm doing, don't test this", e.g. like this

<!doctype html>
<html lang="en">
  <body>
    <script data-hyperlink-ignore>
      foo = bar?.baz;
    </script>
  </body>
</html>

Is this possible today? If so, could I see an example? Thanks!

@jameshfisher
Copy link
Author

(A similar thing happened here Munter/netlify-plugin-checklinks#286)

papandreou added a commit to assetgraph/assetgraph that referenced this issue Nov 11, 2020
papandreou added a commit to assetgraph/assetgraph that referenced this issue Nov 11, 2020
@papandreou
Copy link
Collaborator

Optional chaining is supported by the newest version of acorn, which assetgraph has adopted on master, but it hadn't been released yet. I've just backported it to 6.x and released 6.3.0.

If you update to the just released hyperlink 4.6.0, it should work 🤗

@Munter
Copy link
Owner

Munter commented Nov 12, 2020

In the selective ignore pattern, it would be possible to create some patterns, for example in HTML, which hyperlink could exclude. I just don't like the idea much. I can't think of a convention that would be generally applicable across all the asset types that we support, and I'm not a big fan of spreading a lot of build tool specifics into your code either.

And even if we came up with a convention for ignoring parts of your dependency graph, how can the tool then give you any guarantees anymore?

I think assetgraph (tool behind hyperlink) should always support code that can run in modern browsers. Of course than hinges on there being updated releases of the specific parsers we are depending on, and us having the time to upgrade them :)

@jameshfisher
Copy link
Author

jameshfisher commented Nov 12, 2020

Awesome work, I'll try it out again :-)

What I was getting at, I suppose, is:

  • My blog often uses experimental web stuff, because that's what I blog about, and in general I'd expect build tools etc to be behind latest Chrome (obviously it's awesome if this is not the case ... call me a pessimist)
  • I don't think of hyperlink as giving me any guarantees as such ... more of a useful heuristic tool. Like I guess it can't guarantee that fetch('https://goo' + 'gle.com') is "correct"
  • Lots of testing/correctness tools have escape hatches, like //@ts-ignore, or @ignore

@papandreou
Copy link
Collaborator

// @hyperlink-ignore / <!-- hyperlink-ignore --> could be an interesting idea 😍

@jameshfisher
Copy link
Author

Tried it out, [email protected] works like a charm, 1229 tests passed 💖

I've removed all my old {% post_url %} and {% link %} checks from Jekyll days.

Thanks again for an awesome tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants