`consistent-destructuring` improvements
See original GitHub issueIt could be good to add an option for ignoring redefined properties of sources:
// I don't see a reason to use destructuring for `edge`
const { chrome, ie, safari } = module;
// ...
if (!module.edge && ie) {
module.edge = '12';
}
// ...
if (!module.edge) {
// ...
}
It could be good to add an option to ignore some sources or properties:
const { getPrototypeOf } = Object;
// ...
// `Object.prototype` here looks better than just `prototype`
if (getPrototypeOf(object) === Object.prototype) {
// ...
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:9 (5 by maintainers)
Top Results From Across the Web
2909-destructuring-assignment - The Rust RFC Book
Destructuring assignment increases the consistency of the language, in which assignment is typically expected to behave similarly to variable declarations.
Read more >C++17 upgrades you should be using in your code - O'Reilly
C++17 upgrades you should be using in your code. Structured bindings, new library types, and containers add efficiency and readability to your ...
Read more >Rust for web devs: Destructuring - Paul Butler
Destructuring Assignment in JavaScript ... fundamentally make the language more capable, but it's a nice quality-of-life improvement.
Read more >Announcing TypeScript 4.6 RC - Microsoft Developer Blogs
Allowing Code in Constructors Before super(); Control Flow Analysis for Destructured Discriminated Unions; Improved Recursion Depth Checks ...
Read more >@babel/plugin-transform-destructuring - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think examples provided here can be rewritten in a better way that does conform to the latest (31.0.0) unicorn rules:
@zloirock’s from https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1005#issue-783525204:
@brettz9’s from https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1005#issuecomment-758325847
This already passes unicorn rules, but you could rewrite it to use even more destructuring with IMO even better readability:
I don’t get exactly which improvements are proposed here. I think this needs more clear examples with comments like “This line is reported (and/or autofixed) but I think it should not be reported” or “This line is not reported but I think it should be reported (and/or autofixed)” each in a separate issue. Even better, if you feel like it, write a failing test for maximum clarity.
I might just add that I think there are essentially three approaches that are favored, none of which is necessarily superior, but the current rule only allows one of them.
By my own preference, I mean the following: