Skip to content

Bug: wrong indent in else-if #17316

Closed
@otomad

Description

Environment

Node version: v19.0.1
npm version: v8.19.2
Local ESLint version: v8.43.0
Global ESLint version: Not found
Operating System: win32 10.0.22621

What parser are you using?

Default (Espree)

What did you do?

Configuration
"rules": {
	"curly": ["error", "multi"],
	"indent": ["error", "tab"],
}
const foo = true, bar = true, doSomething = () => { };

if (foo)
	if (bar) doSomething();
	else doSomething();
else
	if (bar) doSomething();
	else doSomething();

What did you expect to happen?

The demo code is correct and does not require to fix.

What actually happened?

The else part indents marked as error.

if (foo)
	if (bar) doSomething();
	else doSomething();
else
﹏﹏﹏﹏ if (bar) doSomething();
﹏﹏﹏﹏ else doSomething();

Problem content:

Expected indentation of 0 tabs but found 1. eslint(indent)

After fix all auto-fixable problems

if (foo)
	if (bar) doSomething();
	else doSomething();
else
if (bar) doSomething();
else doSomething();

Link to Minimal Reproducible Example

https://stackblitz.com/edit/js-efzdhw?file=index.js&view=editor

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyindentRelates to the `indent` rulerepro:yesIssues with a reproducible example

Type

No type

Projects

  • Status

    Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions