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

Ending line with   breaks indent linting rules #9878

Assignees
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 indent Relates to the `indent` rule rule Relates to ESLint's core rules

Comments

@ccicchitelli
Copy link

ccicchitelli commented Jan 23, 2018

Tell us about your environment

  • **ESLint Version:**4.6.1
  • **Node Version:**6.11.3
  • **npm Version:**3.10.10

What parser (default, Babel-ESLint, etc.) are you using?
eslint, babel-eslint
Please show your full configuration:

Configuration
{
  "extends": [
    "airbnb"
  ],
  "plugins": [
    "react",
    "import"
  ],
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "jest": true
  },
  "settings": {
    "import/resolver": "webpack"
  },
  "rules": {
    "jsx-a11y/label-has-for": [ 2, {
      "components": [ "Label" ],
      "required": {
        "some": [ "nesting", "id" ]
      },
      "allowChildren": false
    }],
    "arrow-body-style": 1,
    "arrow-parens": 0,
    "indent": [2, 2],
    "linebreak-style": [2, "unix"],
    "no-tabs": 2,
    "no-unused-expressions": 0,
    "semi": [2, "never"],
    "import/extensions": 0,
    "import/no-extraneous-dependencies": 0,
    "import/no-unresolved": 0,
    "import/prefer-default-export": 1,
    "jsx-a11y/href-no-hash": 2,
    "react/forbid-prop-types":   [2, { "forbid": ["any"] } ],
    "react/jsx-filename-extension": [2, { "extensions": [".js"] }],
    "react/jsx-indent": [2, 2]
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

            <small>By choosing to continue, you acknowledge you have reviewed our&nbsp;
              <a>information disclosure</a>.
            </small>
eslint [folder]

What did you expect to happen?
The code above should pass indent linting rules.

What actually happened? Please include the actual, raw output from ESLint.
It generated the following error:

  62:1  error  Expected indentation of 12 spaces but found 14  indent

Removing two spaces generates the same error, inverted:

[eslint] Expected indentation of 14 space characters but found 12. 

However, moving the non-breaking space to the same line as the anchor tag, with 14 spaces, does not generate an error. It appears the line ending with the non-breaking space is breaking linting on the next line, at least partially (no other errors are generated).

This works:

            <small>By choosing to continue, you acknowledge you have reviewed our
              &nbsp;<a>information disclosure</a>.
            </small>
@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jan 23, 2018
@not-an-aardvark
Copy link
Member

Hi, thanks for the report. I noticed you put "all" as your ESLint version, but I assume you haven't actually tried this on every ESLint version. Could you be more specific about what version you're using?

@ccicchitelli ccicchitelli changed the title Ending line with &nbsp; breaks spacing linting rules Ending line with &nbsp; breaks indent linting rules Jan 23, 2018
@ccicchitelli
Copy link
Author

Sorry, I meant to update that before submitting. What that was meant to indicate is that it's apparently present in all recent versions. I've tested 4.6.1 and the latest.

@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion indent Relates to the `indent` rule and removed triage An ESLint team member will look at this issue soon labels Jan 23, 2018
@Florian-R
Copy link

Florian-R commented Feb 12, 2018

FWIW, I noticed that while trying to upgrade from 4.15.0 to 4.16.0. Same behavior on 4.17.0.

Not sure if this is related, but this also fail since 4.16.0 :

const Foo = () => {
    return (
        <div>Some text
            <span>yolo</span> //error  Expected indentation of 8 spaces but found 12   indent
        </div>
    )
}

Not the prettiest code but I don't think this line should be flagged as badly indented.

@apost
Copy link

apost commented Feb 15, 2018

I have the same problem. For now I find this stylistic compromise acceptable for my style guide:

        <small>
          By choosing to continue, you acknowledge you have reviewed our &nbsp;
          <a>information disclosure</a>.
        </small>

not-an-aardvark added a commit that referenced this issue Mar 3, 2018
This fixes a bug in the `indent` rule where a line comparison with the end of a token would use the end location of any trailing whitespace in the token, rather than the location of the last non-whitespace character in the token. This behavior went against user intuition for tokens with trailing whitespace.
@not-an-aardvark not-an-aardvark self-assigned this Mar 3, 2018
This was referenced Mar 22, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 3, 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 Sep 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.