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
Closed

indentation is wrong in template literal expression #1176

CedricRaison opened this issue Aug 10, 2018 · 6 comments

Comments

@CedricRaison
Copy link

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

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 () {
    }
  })
}

[email protected] 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
Copy link
Author

Bug still exists with standard v12

@stale
Copy link

stale bot 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 as completed 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
Copy link
Member

feross commented Aug 12, 2019

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

@sonicdoe
Copy link
Contributor

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

@feross
Copy link
Member

feross 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.

@feross feross closed this as completed Aug 12, 2019
@feross feross added this to the standard v14 milestone Aug 12, 2019
feross added a commit that referenced this issue Aug 12, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2021
suchitg8 pushed a commit to suchitg8/standard that referenced this issue Apr 9, 2022
kaiwang0119 added a commit to kaiwang0119/standard that referenced this issue Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

4 participants