JavaScript syntax highlighting errors: Source Code viewer on codecov.io

Description

JavaScript syntax highlighting errors: Source Code viewer on codecov.io

  1. Backslash in template strings are incorrectly highlighted

    \n in an ES6 template string has a red box rendered around the \
    Example: here (line 151)
    Appears to be upstream pygments/pygments#1679 - fixed in Pygments 2.8.0
  2. Optional chaining operator completely breaks the highlighting / parser

    The ES2020 optional chaining operator ?. has a red box rendered around the ? then further syntax highlighting / parsing completely breaks
    Example: here (line 224)
    Appears to be fixed in latest Pygments - demo does not exhibit issue.
  3. Hash symbol in comment incorrectly highlighted

    # at the start of a line inside a multi-line comment has a red box rendered
    Example: here (line 207)
    Pygments demo does not exhibit issue.
  4. Nested template string incorrectly highlighted

    A nested ES6 template string inside a ${} placeholder itself containing a placeholder is incorrectly parsed and highlighted.
    Example: here (line 324)
    Pygments demo does not exhibit issue.

Suggested fix

  • Bump Pygments on codecov.io to latest version.
  • Test syntax highlighting / parser for conformance with ES2020 / ES2021 e.g. using the ECMAScript Test Suite
    • In particular the new Nullish Coalescing, Optional Chaining and Logical Assignment Operators which alter the language grammar
    • Watch GitHub - tc39/proposals: Tracking ECMAScript Proposals for other Stage 3 proposals that alter the language grammar since they are likely already shipping in production browsers / node.js
1 Like

Hi @docd27 thanks for this suggestion! We are actually in the process of redoing our code viewer which should fix this issue. I’m assuming this isn’t a blocker for you right now?