Giter Club home page Giter Club logo

Comments (4)

willhoney7 avatar willhoney7 commented on July 27, 2024 1

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.

nowycondro avatar nowycondro commented on July 27, 2024

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.

mateushnsoares avatar mateushnsoares commented on July 27, 2024

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];
...

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.

ssharifdev avatar ssharifdev commented on July 27, 2024

any update on this @Tibfib ?

from eslint-plugin-import-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.