question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autofixing object-shorthand when some properties are keywords leads to parse error

See original GitHub issue

What 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:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelficarracommented, Aug 5, 2016

@platinumazure Yes, that’s what I meant. I didn’t see why we were keeping this issue open.

1reaction
mysticateacommented, Aug 5, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint object-shorthand error with variable passed in
An excerpt from eslint regarding the issue: Require Object Literal Shorthand Syntax (object-shorthand) - Rule Details.
Read more >
Add autofix for object-shorthand 'consistent' option · Issue #7605
Please include the actual, raw output from ESLint. 2:9 error Unexpected mix of shorthand and non-shorthand properties object-shorthand.
Read more >
object-shorthand - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
node_modules/eslint/CHANGELOG.md · master - GitLab
cbf3585 Update: skip keyword check for fns in space-before-blocks (fixes ... b165aa5 Fix: yoda rule autofix produces syntax errors with ...
Read more >
demo-outil-edition - node_modules - eslint - CHANGELOG.md
dd1e9f4 Fix: revert changes to key-spacing due to regression ... 5509cdf Fix: fails the test case if autofix made syntax error (fixes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found