eslint: "Unexpected token :" for JSON-LD (ld+json).

If I place a JSON-LD script element in an HTML file, ESLint throws an error of “Unexpected token :”.

Google doc: https://developers.google.com/search/docs/guides/intro-structured-data

    <script type="application/ld+json">
        {
            "@context": "http://schema.org",
            "@type": "Organization",
            "url": "http://www.example.com",
            "name": "Unlimited Ball Bearings Corp.",
            "contactPoint": {
                "@type": "ContactPoint",
                "telephone": "+1-401-555-1212",
                "contactType": "Customer service"
            }
        }
    </script>

Disabling ESLint in Sublime Text menubar’s “Toggle” command removes the error.

Adding /* eslint-disable unexpected-token */ doesn’t remove the error.

Should this be reported here or at SublimeLinter-eslint?

Can this be prevented, please?

  • ESLint 4.17.0
  • SublimeLinter 3.10.10
  • Sublime Text 3.0
  • macOS 10.13.3 High Sierra

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

Hi @jaepage, thanks for the issue. It looks like there’s not enough information for us to know how to help you.

If you’re reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

Requesting a rule change? Please see Proposing a Rule Change for instructions.

If it’s something else, please just provide as much additional information as possible. Thanks!