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

Fix: astUtils.getNextLocation returns invalid location after CRLF #13275

Merged
merged 1 commit into from May 23, 2020

Conversation

mdjermanovic
Copy link
Member

Prerequisites checklist

  • I have read the contributing guidelines.
  • The team has reached consensus on the changes proposed in this pull request. If not, I understand that the evaluation process will begin with this pull request and won't be merged until the team has reached consensus.

What is the purpose of this pull request? (put an "X" next to an item)

[X] Bug fix

Tell us about your environment

  • ESLint Version: v7.0.0
  • Node Version: v12.14.0
  • npm Version: v6.13.4

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
      ecmaVersion: 2015
  }
}

What did you do? Please include the actual source code causing the issue.

CRLF after foo and bar

/*eslint semi: error*/

foo
bar

What did you expect to happen?

Two errors with the following locations (1-based lines and 1-based columns):

  • foo: "line":3,"column":4, "endLine":4,"endColumn":1
  • bar: "line":4,"column":4, "endLine":5,"endColumn":1

What actually happened? Please include the actual, raw output from ESLint.

Two errors with the following locations (1-based lines and 1-based columns):

  • foo: "line":3,"column":4, "endLine":3,"endColumn":5
  • bar: "line":4,"column":4, "endLine":4,"endColumn":5

endColumn: 5 would be a position between CR and LF.

VS Code treats this as if no endColumn was given, and underlines word before the start column:

image

Atom explicitly reports invalid position:

image

What changes did you make? (Give an overview)

Fixed astUtils.getNextLocation to return the start of the next line instead of an invalid location between CR and LF.

This affects the following rules at the moment:

  • semi
  • comma-dangle

Is there anything you'd like reviewers to focus on?

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels May 9, 2020
@mdjermanovic
Copy link
Member Author

It seems that we had two require-await tests with invalid syntax, which is now caught by the just-released acorn v7.2.0.

@kaicataldo
Copy link
Member

Do you mind rebasing now that we've merge the fix for those tests?

@mdjermanovic
Copy link
Member Author

It seems that closing & reopening works as well in this scenario.

I believe it's because reopening a PR creates a new test merge commit.

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels May 15, 2020
@kaicataldo kaicataldo merged commit a93083a into master May 23, 2020
@kaicataldo kaicataldo deleted the getnextlocation-crlf branch May 23, 2020 00:35
@kaicataldo
Copy link
Member

Thanks for contributing!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 20, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants