False positive expected indentation NaN when disabling ObjectExpressions
See original GitHub issue- ESLint Version: 4.1.1
- Node Version: 8.1.3
- npm Version: 5.3.0 What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
In a package.json:
"eslintConfig": {
"extends": "eslint:recommended",
"env": {
"node": true,
"mocha": true,
"es6": true
},
"rules": {
"indent": [
"error",
2,
{
"ObjectExpression": "off"
}
]
}
}
What did you do? Please include the actual source code causing the issue.
The above config attempts to disable ESLint indent checks in objects specifically, keeping them for everything else.
function thing(string) {
const result = where({
or: [{
field1: 'value1'
}, {
field2: 'value2', field3: 'value3'
}, {
field4: 'value4'
}]
});
}
What did you expect to happen?
There should be no error messages regarding indentation in the where
call.
What actually happened? Please include the actual, raw output from ESLint.
5:1 error Expected indentation of NaN spaces but found 4 indent
7:1 error Expected indentation of NaN spaces but found 4 indent
9:1 error Expected indentation of NaN spaces but found 4 indent
Notably, 4 is the “correct” indentation level without any special rule configuration, so something’s going on with toggling ObjectExpression
s “off”. Disabling the if
in the ignoreToken
function of lib/rules/indent.js turns the NaN into an actual number, but it’s the wrong one and also causes a ton of other false positives so it’s not just that.
I tried disabling ArrayExpression
s and CallExpression
s as well, to no avail; this is specifically an issue with ObjectExpression
s.
Possibly related:
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
This is working as intended based on https://github.com/eslint/eslint/issues/9194#issuecomment-326638820. To disable checking for this in ESLint 4.5.0+, you should be able to use the
ignoredNodes: ["ObjectExpression"]
option.Yes – hence trying to disable
ObjectExpression
/ArrayExpression
, so I can get indent checks elsewhere but ignore them inside complex objects.