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

"Expected NaN spaces" indent error with multiline string and arguments: 'off' #9083

Closed
alangpierce opened this issue Aug 7, 2017 · 2 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 indent Relates to the `indent` rule rule Relates to ESLint's core rules

Comments

@alangpierce
Copy link
Contributor

Tell us about your environment

  • ESLint Version: 4.4.0
  • Node Version: 6.10.3
  • npm Version: 3.10.10

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

Please show your full configuration:

Configuration
module.exports = {
  env: {
    es6: true,
  },
  rules: {
    indent: ['error', 2, {
      CallExpression: {
        arguments: 'off',
      },
    }],
  },
};

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

This is a reduced test case showing the issue:

a(`b
c`, function() {
  d;
});

What did you expect to happen?

Ideally no error, but if there is an error, it should be sensible.

What actually happened? Please include the actual, raw output from ESLint.
eslint gives this error:

3:1  error  Expected indentation of NaN spaces but found 2  indent

Running eslint --fix treats NaN as 0 and removes all indentation from all affected lines.

Changing the multiline string to a single-line string fixes the issue, and removing arguments: 'off' in the config also fixes the issue.

Context:
This type of code came up when converting multiline strings from CoffeeScript (example), and it appears a number of times in my codebase. A workaround is to rewrite the multiline strings as single-line strings, but certainly would be nice for this to be fixed within eslint.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 7, 2017
@platinumazure platinumazure 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 7, 2017
@platinumazure
Copy link
Member

This certainly does seem like a bug.

@not-an-aardvark Maybe you might have some insight into this one?

@alangpierce
Copy link
Contributor Author

alangpierce commented Aug 7, 2017

Another example with the same config:

a(
  new B({
    c,
  })
);

Gives this error:

  3:1  error  Expected indentation of NaN spaces but found 4  indent
  4:1  error  Expected indentation of NaN spaces but found 2  indent

Edit: another case, even simpler:

a(b
  , c);

Error:

  2:1  error  Expected indentation of NaN spaces but found 2  indent

@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 Aug 7, 2017
@not-an-aardvark not-an-aardvark self-assigned this Aug 7, 2017
not-an-aardvark added a commit that referenced this issue Aug 7, 2017
This fixes an issue where the `indent` rule would sometimes expect "NaN spaces" of indentation when an `"off"` option was used.
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 Feb 6, 2018
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 indent Relates to the `indent` rule rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

4 participants