autofixing object-shorthand when some properties are keywords leads to parse error
See original GitHub issueWhat version of ESLint are you using?
3.1.1
What parser (default, Babel-ESLint, etc.) are you using?
default es6
Please show your full configuration:
/* eslint object-shorthand: "error" */
What did you do? Please include the actual source code causing the issue.
var a = {
b() {
return {
arguments: arguments,
};
}
};
What did you expect to happen?
either to convert when fixing to { arguments }
and not give a parser error or to leave as-is
What actually happened? Please include the actual, raw output from ESLint.
it was autofixed and then the next run gave this error
error Parsing error: 'arguments' can not be used as shorthand property
this comes from acorn here: https://github.com/ternjs/acorn/blob/5e5e4301444d4471b62c9079d7c049afd9598ac0/src/expression.js#L520
I’m not sure if its completely correct that all keywords like arguments should give syntax errors - it doesn’t error in chrome, but that doesn’t mean anything. So it could be an upstream acorn bug. But it does look like this
is invalid as a shorthand property definitely and I can’t see code in the eslint rule that checks for any keywords.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
@platinumazure Yes, that’s what I meant. I didn’t see why we were keeping this issue open.
I sent a PR: https://github.com/ternjs/acorn/pull/444