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

accepted archived due to age bug indent rule


Copy link

@ccicchitelli 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:

  "extends": [
  "plugins": [
  "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>.
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>.
@eslint-deprecated eslint-deprecated bot added the triage label Jan 23, 2018
Copy link

@not-an-aardvark not-an-aardvark commented Jan 23, 2018

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
Copy link

@ccicchitelli ccicchitelli commented Jan 23, 2018

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 rule accepted indent and removed triage labels Jan 23, 2018
Copy link

@Florian-R 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

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

Copy link

@apost apost commented Feb 15, 2018

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

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

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
@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 label Sep 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.