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

Unintended indent for multiline template string argument combined with another multiline argument #9061

Closed
markatom opened this issue Aug 2, 2017 · 8 comments · Fixed by Urigo/tortilla#62, mono-js/mono-notifications#5, mono-js/mono-push#5 or terrajs/lib-starter#5 · May be fixed by ali8889/emerald-wallet#4
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

@markatom
Copy link

markatom commented Aug 2, 2017

Tell us about your environment

  • ESLint Version: 4.3.0
  • Node Version: 8.1.3
  • npm Version: 5.0.3

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

I tried both default and babel-eslint. They're giving me same result.

Please show your full configuration:

Configuration
{
    "env": {
        "es6": true,
        "node": true
    },
    "extends": [
        "eslint:recommended"
    ],
    "rules": {
        "indent": ["error", 4]
    }
}

What did you do? Please include the actual source code causing the issue.

const f = (first, second) => {
    return second;
};

// works for multiline template strings
f(`
    multiline
    template
    string
`, `
    multiline
    template
    string
`);

// works for multiline objects
f({
    foo: 'foo',
    bar: 'bar',
}, {
    foo: 'foo',
    bar: 'bar',
});

// doesn't work for multiline template string and multiline object
f(`
    multiline
    template
    string
`, {
    foo: 'foo',
    bar: 'bar',
});

What did you expect to happen?

I expected all of the three examples will pass.

What actually happened? Please include the actual, raw output from ESLint.

  31:1  error  Expected indentation of 8 spaces but found 4  indent
  32:1  error  Expected indentation of 8 spaces but found 4  indent
  33:1  error  Expected indentation of 4 spaces but found 0  indent

I believe the eslint fix is incorrect

 const f = (first, second) => {
     return second;
 };
 
 // works for multiline template strings
 f(`
     multiline
     template
     string
 `, `
     multiline
     template
     string
 `);

 // works for multiline objects
 f({
     foo: 'foo',
     bar: 'bar',
 }, {
     foo: 'foo',
     bar: 'bar',
 });

 // doesn't work for multiline template string and multiline object
 f(`
     multiline
     template
     string
 `, {
-    foo: 'foo',
-    bar: 'bar',
-});
+        foo: 'foo',
+        bar: 'bar',
+    });

Could you please confirm this is an unintended behaviour? Thank you.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 2, 2017
@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion indent Relates to the `indent` rule rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Aug 2, 2017
@not-an-aardvark
Copy link
Member

We actually have a test asserting the current behavior, so I think this is working as intended. I don't recall if there was a specific reason why I added that test, though. I think I agree that your proposed behavior makes more sense.

@markatom
Copy link
Author

markatom commented Aug 3, 2017

Thank you for a quick response. Can I expect the behaviour will be changed then?

@markatom
Copy link
Author

Any updates on this issue?

@platinumazure
Copy link
Member

@not-an-aardvark Where are we at on this issue?

@not-an-aardvark not-an-aardvark 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 Dec 26, 2017
@not-an-aardvark
Copy link
Member

Marked as accepted.

@gurpreetatwal
Copy link

@not-an-aardvark anything we can do to help get this moving forward?

@not-an-aardvark
Copy link
Member

You could submit a PR.

@gurpreetatwal
Copy link

@not-an-aardvark thank you! I tried working on it, but was still trying to understand how eslint works haha

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 10, 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 Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.