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.

Can't specify object keys that aren't camel case, even when quoted

See original GitHub issue

It appears I’m going to have to create pragmas to ignore some rules.

With the following object:

const obj = {some_key: 1234}; // 'some_key' is required by the consuming library

XO dies with

Identifier some_key is not in camel case.  camelcase

However, when quoting it (thinking maybe it would ease the error), it errored out with:

Unnecessarily quoted property some_key found.  quote-props

It appears there’s no proper way in XO to do this without ignoring some lines (which is ugly).

What XO should do is detect when errors arise in quote-props would cause other errors if unquoted and ignore such cases, though I would imagine this would require some hefty plugin code.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
j-f1commented, Dec 4, 2017

camelcase has an option to ignore object keys. i.e.

/* eslint camelcase: ["error", {properties: "never"}] */

// invalid
const foo_bar = 'baz'

// valid:
const bar = {
  foo_bar: fooBar
}
3reactions
sindresorhuscommented, Jun 6, 2017

The problem is that ESLint rules have no knowledge of each other and the ESLint team doesn’t seem interested in solving such problem. We could maybe work around it in XO by checking the results and handle conflicts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does Firefox console only quote some object keys?
You can't use .notation on a string and you can't have white space. I am sure this is why camelCase is an important...
Read more >
Is it bad practice to use hyphens in JSON keys?
People usually use camelCase for JSON because it's always good practice to follow the naming conventions of the programming environment and it's standard ......
Read more >
CamelCase vs underscores: Scientific showdown - whatheco.de
In my experience, more better coders use underscore. Camel case seems to have cropped-up from Java, mainly. By the way: I type Dvorak....
Read more >
camelcase-keys
Convert object keys to camel case. Latest version: 8.0.2, ... Start using camelcase-keys in your project by running `npm i camelcase-keys`.
Read more >
Groovy Language Documentation
The reserved keywords can't in general be used for variable, ... of a property name are lowercase and for multi-word properties that camel...
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