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

indentation is wrong in template literal expression #1176

Closed
CedricRaison opened this issue Aug 10, 2018 · 6 comments

Comments

@CedricRaison
Copy link

commented Aug 10, 2018

What version of standard? 11.0.1

What operating system, Node.js, and npm version? Ubuntu 18.04 node 8.9 npm 5.5.1

What did you expect to happen?
Template literal expressions does not indent correctly.
example with styleguide.js from choo website.

If you run standard --fix styleguide.js, template literal expression indentation is totally wrong at line 16 and in every template literal expression.

I past the code to the try it out section of the standard website and it work well, so I assume the website use an old version of the standard library that don't contain the bug.

@chrisdickinson

This comment has been minimized.

Copy link

commented Aug 26, 2018

I noticed this as well. Example code that works as expected:

function example () {
  const router = reverse`
    GET /example greet
  `({
    greet () {
    }
  })
}

But once I add a parameter to the template string, like so:

function example () {
  const router = reverse`
    GET /example/${id} greet
  `({
    greet () {
    }
  })
}

standard@11.0.1 suggests that it should instead format it without the indention in the object literal:

function example () {
  const router = reverse`
    GET /example/${id} greet
  `({
  greet () {
  }
})
}

which seems wrong. (This might be a bug in eslint!) An example of the error reported follows:

  /path/to/file:37:1: Expected indentation of 2 spaces but found 4. (indent)
  /path/to/file:38:1: Expected indentation of 2 spaces but found 4. (indent)
  /path/to/file:39:1: Expected indentation of 0 spaces but found 2. (indent)
@CedricRaison

This comment has been minimized.

Copy link
Author

commented Aug 29, 2018

Bug still exists with standard v12

@stale

This comment has been minimized.

Copy link

commented Nov 27, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Nov 27, 2018

@stale stale bot closed this Dec 4, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Mar 4, 2019

@standard standard unlocked this conversation Aug 12, 2019

@feross feross reopened this Aug 12, 2019

@stale stale bot removed the stale label Aug 12, 2019

@feross

This comment has been minimized.

Copy link
Member

commented Aug 12, 2019

This appears to be a bug in ESLint. Has anyone filed an issue on ESLint for this yet?

@sonicdoe

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2019

I think eslint/eslint#10932 describes the same bug.

@feross

This comment has been minimized.

Copy link
Member

commented Aug 12, 2019

Okay, until ESLint fixes this, let's just disable indentation checking on children of template literals.

I'm going to add this exception to the indent rule: "ignoredNodes": ["TemplateLiteral > *"]

This will be released in standard v14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.