Comments (4)
Hi!
So, currently, ordering within a subgroup is not enforced. In your example, /aaa/
, /bbb/
, and /ccc/
are merged into a single group.
Since you do not have the alphabetize
setting, the rule will allow you to do any order of imports within that subgroup. If you set alphabetize: { order: 'asc', ignoreCase: true }
, you will get your desired order... However that only works because your desired order in this example is alphabetical order.
It sounds like you think the order of the items in a subgroup should be enforced? Hmm, I can see the value in that... I personally prefer to sort alphabetically for all groups. I'm on the fence. Any additional arguments for/against it?
from eslint-plugin-import-helpers.
In the beginning I though the behavior of Regex
should be the same other group (e.g, parent, siblings, etc). It took me quite sometime to realise it doesn't respect the order for Regex
.
In my case, alphabetically sort doesn't solve the problem
groups: [
'module',
[
'/name/',
'/relatively_short_folder_name/',
'/a_extremely_long_folder_name_that_is_hard_to_read/'
]
],
In other case, it might be sort by string length 🤷♂ and lead me to think is there any possibility to allow custom sort function as an item under groups
.
function sort(a, b) {
// sort the import whatever you want
}
...
groups: ['module', sort];
...
from eslint-plugin-import-helpers.
In the beginning I though the behavior of
Regex
should be the same other group (e.g, parent, siblings, etc). It took me quite sometime to realise it doesn't respect the order forRegex
.In my case, alphabetically sort doesn't solve the problem
groups: [ 'module', [ '/name/', '/relatively_short_folder_name/', '/a_extremely_long_folder_name_that_is_hard_to_read/' ] ],
In other case, it might be sort by string length 🤷♂ and lead me to think is there any possibility to allow custom sort function as an item under
groups
.function sort(a, b) { // sort the import whatever you want } ... groups: ['module', sort]; ...
Good idea but sometimes is not necessary. I suppose that beyond it this rule should support an Object like this:
"groups": [
{
"group": [
"some_same_values_here"
],
"order": "asc|desc|asc-by-type|desc-by-type" // default is alphabetize.order
}
]
from eslint-plugin-import-helpers.
any update on this @Tibfib ?
from eslint-plugin-import-helpers.
Related Issues (20)
- Importing from parent behaving unexpectedly HOT 5
- Line count dependent `newlinesBetween` HOT 1
- Thank you!
- It's doens't works with Prettier HOT 5
- It doesnt work with (import '../styles/mystyle.scss'); HOT 3
- Support for ESLint v7? HOT 4
- Support for 'type' imports HOT 8
- Failing test (see link to code)
- Different groups for node_modules and internal modules HOT 2
- Relative import mistaken as modules HOT 1
- [QUESTION] - Why make this order 👇 ? HOT 3
- does it support "^7.12.1" ? HOT 2
- How can I set order for import './index.styl' HOT 4
- Support the latest version of ESLint (v8) HOT 1
- How to separate modules that are only `import` HOT 2
- Allow Functions Before Imports
- bug: node@14 requirement added as a minor HOT 2
- Type sorting does not work correctly
- Sort import with styles does not work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-import-helpers.