Skip to content

Indent rule problem with object and array literals #3236

@targos

Description

@targos

Version 1.0.0

Rule:

indent: [2, 2, {"SwitchCase": 1, "VariableDeclarator": 2}]

Code:

var testCases =
    [{ crl: 'ca2-crl',
      clients:
       [
        { name: 'agent1', shouldReject: true, shouldAuth: false },
        { name: 'agent2', shouldReject: true, shouldAuth: false }
       ]
    }
    ];

var abc =
     {
       x: 2,
        y: 4
     };

Result:

test1.js
   5:9  error  Expected indentation of 9 characters but found 8  indent
   6:9  error  Expected indentation of 9 characters but found 8  indent
  14:9  error  Expected indentation of 7 characters but found 8  indent

The rule accepts any indentation for the object or array literal if it starts on a new line. Then it uses this indentation as a reference for the next errors, so we see an expected odd indentation (9, 7) when the rule is set to 2.

Cross-reference: nodejs/node#2286

Metadata

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 incorrectlyruleRelates to ESLint's core rules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions