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

indent issue with tagged template literals #12122

Closed
msvab opened this issue Aug 19, 2019 · 12 comments
Closed

indent issue with tagged template literals #12122

msvab opened this issue Aug 19, 2019 · 12 comments
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 help wanted The team would welcome a contribution from the community for this issue indent Relates to the `indent` rule

Comments

@msvab
Copy link

msvab commented Aug 19, 2019

Tell us about your environment

  • ESLint Version: 6.2.0
  • Node Version: 10.16.3
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
{
  "env": {
    "es6": true,
    "jest/globals": true
  },
  "plugins": ["jest"],
  "rules": {
    "indent": [
      "error", 2, {
      "SwitchCase": 1,
      "VariableDeclarator": 1,
      "outerIIFEBody": 1,
      "FunctionDeclaration": {
        "parameters": 1,
        "body": 1
      },
      "FunctionExpression": {
        "parameters": 1,
        "body": 1
      },
      "CallExpression": {
        "arguments": 1
      },
      "ArrayExpression": 1,
      "ObjectExpression": 1,
      "ImportDeclaration": 1,
      "flatTernaryExpressions": false,
      "ignoredNodes": [
        "JSXElement", "JSXElement > *", "JSXAttribute", "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", "JSXSpreadAttribute", "JSXExpressionContainer", "JSXOpeningElement", "JSXClosingElement", "JSXText", "JSXEmptyExpression", "JSXSpreadChild"
      ],
      "ignoreComments": false
    }]
  }
}

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

describe('Indentation Bug', () => {

  test.each`
    a    | b
    ${1} | ${1}
  `('$a == $b', ({ a, b }) => {
    expect(a).toBe(b); // error  Expected indentation of 2 spaces but found 4  indent
  }); // error  Expected indentation of 0 spaces but found 2  indent
});
eslint .

What did you expect to happen?
I would expect the code indentation to be valid.

What actually happened? Please include the actual, raw output from ESLint.
Following eslint errors are displayed:

8:1  error  Expected indentation of 2 spaces but found 4  indent
9:1  error  Expected indentation of 0 spaces but found 2  indent

I've created a small repo where you can easily reproduce the issue.
https://github.com/msvab/eslint-tagged-literal-indent-bug

Are you willing to submit a pull request to fix this bug?
I can try, but I have zero knowledge on eslint internals.

@msvab msvab added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Aug 19, 2019
@kaicataldo
Copy link
Member

For clarity's sake, can you add comments in the example that show us exactly which lines the errors are being reported on?

@kaicataldo kaicataldo added evaluating The team will evaluate this issue to decide whether it 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 Aug 19, 2019
@msvab
Copy link
Author

msvab commented Aug 20, 2019

For clarity's sake, can you add comments in the example that show us exactly which lines the errors are being reported on?

Done.

@platinumazure
Copy link
Member

This is interesting. In this case, regardless of the template literal's end position, it seems we should be enforcing 4 spaces and 2 spaces on those lines simply due to being inside the describe arrow function.

@not-an-aardvark @kaicataldo Is there any reason this shouldn't be considered a bug?

@kaicataldo
Copy link
Member

This looks like a bug to me.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 28, 2019
@kaicataldo
Copy link
Member

I've also been able to verify this using our demo.

@kaicataldo kaicataldo added help wanted The team would welcome a contribution from the community for this issue Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ labels Sep 29, 2019
@bochap
Copy link

bochap commented Oct 2, 2019

It might take some time to get familiar with inner workings Eslint but I am interested in taking this up.

@kaicataldo
Copy link
Member

@seetD Fantastic! Feel free to comment here or visit our chat if you run into any issues or want to talk through anything.

@bochap
Copy link

bochap commented Oct 14, 2019

Sorry I started looking into the issue but something crop up that I had to attend. Once I get that competed I will come back to this. I thought it will be good to drop a note here in case someone else wants to pick this up before that.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Nov 18, 2019
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that accepted issues failing to be implemented after 90 days tend to
never be implemented, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@kaicataldo kaicataldo removed the auto closed The bot closed this issue label Nov 19, 2019
@kaicataldo kaicataldo self-assigned this Nov 19, 2019
@kaicataldo
Copy link
Member

Reopening and assigning to myself so it doesn't get auto closed again.

@DotCoyote
Copy link

It's still closed though ;)
I'd really like to get this fixed too, as I have to disable the indent rule on test-files otherwise...

@kaicataldo kaicataldo reopened this Nov 21, 2019
@kaicataldo
Copy link
Member

Whoops, sorry. Reopened now!

@kaicataldo kaicataldo removed the Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ label Nov 25, 2019
montmanu pushed a commit to montmanu/eslint that referenced this issue Mar 4, 2020
…slint#12596)

* Fix: check tag in tagged template literal in indent (fixes eslint#12122)

* refactor, add test cases

* rename variable name, delete comment

* change test case

* change offsetToken to token before the node.callee.quasi

* refactor code, add more test cases

* use token for consistency
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 17, 2020
@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 Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 help wanted The team would welcome a contribution from the community for this issue indent Relates to the `indent` rule
Projects
None yet
Development

No branches or pull requests

5 participants