Clarification of `sort-imports` rule with destructuring imports
See original GitHub issueESLint version 2.1.0
.
I think any destructuring import should be grouped together when using sort-imports
rule.
Right now, this is valid with default options:
import { Router, browserHistory as history } from 'react-router'
import React from 'react'
import { render } from 'react-dom'
import routes from './routes'
Where as, it is easier to read if everything that started with a {
were grouped together, like so:
import { Router, browserHistory as history } from 'react-router'
import { render } from 'react-dom'
import React from 'react'
import routes from './routes'
While technically, it is a single import, I find it looks out of place. So, I am not sure if this would be considered a bug, or a feature request?
Sorry about the title, not sure how to describe this well. Feel free to adjust the title.
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
sort-imports - ESLint - Pluggable JavaScript Linter
This rule checks all import declarations and verifies that all imports are first sorted by the used member syntax and then alphabetically by...
Read more >Definition for rule 'simple-import-sort/sort' was not found ...
It may be that you're using v6. It looks like v6 doesn't have a simple-import-sort/sort rule, see usage in the README.
Read more >Shorter syntax for Node.js module import - Code Buckets
I've found myself writing a lot of import module statements during React development that ... ES6 Destructuring – good detailed explanation.
Read more >Sorting your imports with ESLint - DEV Community
The "react" import should always come first; Package imports should come next, sorted by alphabetical order; The named imports should be sorted ...
Read more >Destructuring and parameter handling in ECMAScript 6 - 2ality
Recall the rule for default values: If the part has no match in the source, destructuring continues with the default value […]. The...
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 Free
Top 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
I went ahead and implemented this in my own plugin as I was uncertain if it would get merged into core. I just wanted to share the diff, which isn’t too bad. I am not sure if this could be done with an option or not, but would be cool to see this in core.
Line 19
Lines 38-41
Line 153
You can see my full implementation over here: https://github.com/wyze/eslint-plugin-wyze
Curious on your thoughts and feedback.
No team members stepped forward to champion this change, so closing.