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

Update: Make indent report lines with mixed spaces/tabs (fixes #4274) #7076

Merged
merged 1 commit into from Sep 14, 2016

Conversation

not-an-aardvark
Copy link
Member

What issue does this pull request address?
#4274

What changes did you make? (Give an overview)

This updates the indent rule to parse both tabs and spaces as indent characters, regardless of which character lines are supposed to have. For example, if a line is supposed to be indented with two spaces, and it starts with two spaces followed by a tab, the line will get reported because the tab isn't supposed to be there. (Previously, the line would not get reported because the tab wasn't considered an indentation character in "spaces mode".)

Since it now has the ability to detect both spaces and tabs, the rule can also give more detailed error messages, e.g. Expected indentation of 8 spaces but found 4 spaces and 2 tabs.

This PR also updates the getNodeIndent function to only check indentation up to the first non-whitespace character on the node's line, rather than up to the node itself. This makes the logic a bit simpler; for example, lines that start with commas are no longer a special case. This also avoids the issues referenced here where multiline comments could get mangled by the autofixer.

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

This PR makes a few significant changes to the autofix logic. For example, all of the indentation on a reported line is now always replaced by the fixer. We should verify that this change doesn't introduce any regressions.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@nzakas
Copy link
Member

nzakas commented Sep 13, 2016

@gyandeeps @platinumazure can you take a look at this?

@nzakas
Copy link
Member

nzakas commented Sep 13, 2016

LGTM, and really like the simplification. Would just like another set of eyes (or two) on this before merging.

@platinumazure
Copy link
Member

LGTM, nice work @not-an-aardvark! Thanks for taking this on, this has been a sore spot for a while!

@gyandeeps
Copy link
Member

LGTM, waiting for others to review.

@nzakas nzakas merged commit 8b3fc32 into eslint:master Sep 14, 2016
@not-an-aardvark not-an-aardvark deleted the issue4274 branch September 14, 2016 18:08
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants