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.

destructuring-assignment is too greedy. Should only apply within components.

See original GitHub issue

I enabled this rule and immediately ran into issues within files that aren’t React related, nor do they look like a component. For example:

I had to rename these to properties instead of props: https://github.com/milesj/shapeshifter/commit/52e33fed6c5386f80ffffa3a270e6d6fd9997b05#diff-392ca8d88bc7e496ea34c73c8cc8258c

Had to disable this line because it thought context was React related: https://github.com/milesj/boost/blob/master/tests/Routine.test.js#L825

And all of these errors when pulled into another project. None of which is React.

/Users/Miles/Sites/beemo/packages/core/src/Beemo.ts
  188:23  error  Must use destructuring context assignment  react/destructuring-assignment
  221:73  error  Must use destructuring context assignment  react/destructuring-assignment
  244:41  error  Must use destructuring context assignment  react/destructuring-assignment

/Users/Miles/Sites/beemo/packages/core/src/CleanupRoutine.ts
  25:7  error  Must use destructuring context assignment  react/destructuring-assignment

/Users/Miles/Sites/beemo/packages/core/src/configure/CreateConfigRoutine.ts
   49:34  error  Must use destructuring context assignment  react/destructuring-assignment
   55:5   error  Must use destructuring context assignment  react/destructuring-assignment
  124:21  error  Must use destructuring context assignment  react/destructuring-assignment
  124:46  error  Must use destructuring context assignment  react/destructuring-assignment

/Users/Miles/Sites/beemo/packages/core/src/driver/RunCommandRoutine.ts
   43:26  error  Must use destructuring context assignment  react/destructuring-assignment
   73:5   error  Must use destructuring context assignment  react/destructuring-assignment
  214:24  error  Must use destructuring context assignment  react/destructuring-assignment
  215:25  error  Must use destructuring context assignment  react/destructuring-assignment
  241:11  error  Must use destructuring context assignment  react/destructuring-assignment
  268:20  error  Must use destructuring context assignment  react/destructuring-assignment
  269:47  error  Must use destructuring context assignment  react/destructuring-assignment

/Users/Miles/Sites/beemo/packages/core/src/ExecuteScriptRoutine.ts
  25:32  error  Must use destructuring context assignment  react/destructuring-assignment

/Users/Miles/Sites/beemo/packages/core/src/SyncDotfilesRoutine.ts
  36:32  error  Must use destructuring context assignment  react/destructuring-assignment

I see that you’re checking for a component, but perhaps TS is conflicting.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bradennapiercommented, Jun 22, 2018

Every single file in my project is now errors - no react imported or used anywhere close. Seems you guys just look for any variable calls “props” or “context” and expect you’re in a react component…

export default (context: $Context) => ({
  extensions: ['.js', '.jsx', '.json'],
  modules: [
    /**
     * Resolve imports throughout the application in this order.
     * This allows us to import various parts of the application
     * easier for better organization.
     *
     * Modules always resolve top-down.
     */
    context.dirs.view(),
    path.join(context.dirs.src(), 'libraries'),
    'shared',
    'node_modules',
  ],
});

image

react/destructuring-assignment

1reaction
milesjcommented, May 25, 2018

I’ll try and double check JS only files, will be a bit tough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

destructuring-assignment is too greedy. Should only apply ...
I enabled this rule and immediately ran into issues within files that aren't React related, nor do they look like a component.
Read more >
Destructuring of Props in ReactJS - GeeksforGeeks
Destructuring is a characteristic of JavaScript, It is used to take out sections of data from an array or objects, We can assign...
Read more >
Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >
Destructuring Assignment In JavaScript - W3docs
This chapter is dedicated to exploring the destructuring assignment - a unique syntax that helps to unpack objects or arrays into a group...
Read more >
ReactJS Tutorial - 12 - Destructuring props and state - YouTube
ReactJS Tutorial - 13 - Event Handling · Why Is Array/Object Destructuring So Useful And How To Use It · React Hooks Tutorial...
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