Use same alphabetize props as ESLint sort-imports
See original GitHub issueESLint’s native sort-imports
does the sorting I want, but doesn’t care about the grouping of imports. On the other hand, import/order
gives me the ordering I want, but not the powerful alphabetization sort from sort-imports
.
For sort-imports
, this is the config I use:
{
'sort-imports': [
'warn',
{
ignoreCase: true,
memberSyntaxSortOrder: [
'single',
'all',
'multiple',
'none',
],
},
],
}
I’d like to do something similar with import/order
:
{
alphabetize: {
caseInsensitive: true,
memberSyntaxSortOrder: [
'single',
'all',
'multiple',
'none',
],
order: 'asc',
},
}
I would like this functionality because I’m grouping them differently than the default:
{
groups: [
[
'builtin',
'external',
],
[
'index',
'parent',
'sibling',
],
],
}
Here’s an example I’d expect to see:
import PropTypes from 'prop-types'
import React from 'react'
import useMediaQuery from './useMediaQuery'
import useMediaQueryState from './useMediaQueryState'
import { * as actions } from './actions'
import { breakpointsList } from './breakpoints'
import './styles.css'
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:20 (6 by maintainers)
Top Results From Across the Web
Use same alphabetize props as ESLint sort-imports #1670
It does alphabetize, but the ordering is based on the from string (from what I can tell), not the characters of the variables...
Read more >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 >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 >Using eslint, prettier and sort-imports vscode extensions for ...
when you see props property destructure, those are not formatted perfectly. this is when prettier plays in! Use Prettier to format better.
Read more >eslint-plugin-simple-import-sort - npm
Easy autofixable import sorting. Latest version: 8.0.0, last published: 2 months ago. Start using eslint-plugin-simple-import-sort in your ...
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’d also like to have the imports inside the group sorted.
I have the following setup with “sort-imports” and “import/order” and they seem to be working well together: