Skip to content

jshint error ranges incorrect #113

Open

Description

@differentmatt
      function fn() {
        return 45;
      }
      var x = = fn();

[ { ofs : 39, row : 3, col : 8 }, { ofs : 40, row : 3, col : 9 } ] expected
[ { ofs : 31, row : 3, col : 0 }, { ofs : 46, row : 3, col : 15 } ] actual

Activity

  1. spacewander commented on Dec 26, 2014

    @spacewander
    Contributor

    Hey, I have played with aether recently.
    And I find out that, if the code in aether/src/problems.coffee#extractTranspileErrorDetails changes from

    startCol = originalLines[line].indexOf error.evidence                 
    endCol = startCol + error.evidence.length
    

    to

    startCol = error.character - 1
    endCol = error.character
    

    This test can pass.

    It looks like that this test is written according to the report of jshint.
    The default reporter of jshint use character attribute to locate error.

    Will anyone tell me what error.evidence is used for?

  2. nwinter commented on Dec 27, 2014

    @nwinter
    Contributor

    Hi @spacewander! I think error.evidence is supposed to be a substring of the code that triggered the error; I see it here:

    https://github.com/jshint/jshint/blob/ffe087c07d601228e95afa701a33a25675142566/src/jshint.js#L372

    It's been a while, though, and maybe that's not as useful, and error.character could be more useful, or at least useful when error.evidence isn't useful? It would be good if JSHint ranges could be more than one column wide so that we can highlight the whole problem.

    Would love to see any pull request on this, especially if it works with error ranges that are more than one character wide.

  3. spacewander commented on Dec 28, 2014

    @spacewander
    Contributor

    So, it is the problem with test case.
    If error.evidence is used to provide an error report, the range should be
    [ { ofs : 31, row : 3, col : 0 }, { ofs : 46, row : 3, col : 15 } ],
    because the evidence begins from col 0 and ends in col 15.

  4. nwinter commented on Dec 28, 2014

    @nwinter
    Contributor

    Ah, that makes sense, then! Do you want to submit a pull request with a fixed version of this test, or should I take care of it?

  5. added a commit that references this issue on Dec 29, 2014
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions