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.

camelcase with optional chaining

See original GitHub issue

I’m really not sure if this is a bug fix or rule change, but when using optional chaining on an object’s keys, I would expect camelcase to not apply. For example, we can’t control the data we are given from apis so if they use something that’s not camelcase, then it is what it is. So accessing data?.some_data should not throw an error.

Node version: v12.16.0 npm version: v6.13.4 lint version: ^6.8.0 babel-eslint version: ^10.1.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
mdjermanoviccommented, Jun 11, 2020

@lucksp

‘babel/camelcase’: [2, { properties: ‘never’, ignoreDestructuring: true }],

I think you should also disable the core camelcase rule:

camelcase: "off"
3reactions
k-funkcommented, Apr 4, 2020

In the interim, assuming that you’re using babel, you can use https://github.com/babel/eslint-plugin-babel with the same args for “babel/camelcase” as you would for “camelcase”:

// these options are just an example, based on eslint-config-airbnb-base's config

"babel/camelcase": ['error', { properties: 'never', ignoreDestructuring: false }],
Read more comments on GitHub >

github_iconTop Results From Across the Web

Make camelcase and optional chaining play nicely (!22177) · Merge ...
Make camelcase eslint rule work correctly for objects using optional chaining. Previously we had to do this: // eslint-disable-next-line camelcase ...
Read more >
Optional chaining operator support in VSCode - Stack Overflow
VS Code 1.41 supports optional chaining in both JavaScript and TypeScript files. This support includes syntax highlighting and IntelliSense.
Read more >
Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object accessed or function called is ......
Read more >
How Does Optional Chaining Work in JavaScript? | by Johnny ...
Optional chaining is a feature in JavaScript which lets us access child properties of an object, even if the parent object doesn't exist....
Read more >
camelcase | typescript-eslint
... no-namespace · no-non-null-asserted-nullish-coalescing · no-non-null-asserted-optional-chain · no-non-null-assertion · no-redundant-type-constituents ...
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