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

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.

About this issue

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

Most upvoted comments

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
}

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.