Giter VIP home page Giter VIP logo

Comments (8)

remcohaszing avatar remcohaszing commented on May 21, 2024 1

Actually my use case is the simplest one possible. My packages contain an index.ts which re-exports named packages.

Examples:

Also I have moved away from this plugin, because the import/order ESLint rule can do pretty much the same now, works with require, and doesn’t require me to install a separate package. I may want to use this plugin again if re-exports are supported though.

from eslint-plugin-simple-import-sort.

lydell avatar lydell commented on May 21, 2024

Technically those are exports, but I agree that they feel like imports.

from eslint-plugin-simple-import-sort.

SpainTrain avatar SpainTrain commented on May 21, 2024

Does the maybe tag indicate willingness to accept a PR?

When using this plugin, one begins to expect any statement using from syntax to sort by the value after from. We've been tripped up by this a few times. I think consistent use of a particular syntax (to find an item in a list of statements using that syntax) is more relevant than the different semantics between import and export. Thoughts?

(Great plugin BTW!)

from eslint-plugin-simple-import-sort.

lydell avatar lydell commented on May 21, 2024

Does the maybe tag indicate willingness to accept a PR?

Yes!

But keep in mind that it might not be merged. Even if I started working on this myself I might end up throwing it away depending on what I learned along the way.

The reason I haven't done this is because I very rarely use export ... from myself and as such haven’t felt like doing the hard work of figuring out exactly how this should work. I’ve spent days just thinking about how imports should work in all cases.

So feel free to start experimenting with a pull request if you want. I think it would be good to show a proof of concept early on to avoid perfecting something in vain.

But I fear that you’ll make a really nice pull request and I’ll get stuck reviewing it because I’d be too lazy to really wrap my head around it all and verify that we’ve covered all use cases and edge cases.

(Great plugin BTW!)

Thanks! 😄

from eslint-plugin-simple-import-sort.

JCrepin avatar JCrepin commented on May 21, 2024

Hi all, I've created a POC PR for this. Let me know what you think.

#43

from eslint-plugin-simple-import-sort.

lydell avatar lydell commented on May 21, 2024

@remcohaszing I’m finally circling back to this. The reason I never merged #53 was because I didn’t feel 100% satisfied with how the grouping and blank lines worked for exports.

A new idea I have is to ignore the groups option for exports and never try to group them automatically. Instead, for exports you’ll group them manually by using comments.

export * from "some-package"
export * from "./utils"
export * from "./Node"
export * from "./Edge"

⬇️ sort

export * from "./Edge"
export * from "./Node"
export * from "./utils"
export * from "some-package"

⬇️ edit

 export * from "./Edge"
 export * from "./Node"
+export * from "some-package"
+// Utils
 export * from "./utils"
+export * from "./graph-utils"
-export * from "some-package"

⬇️ sort

export * from "./Edge"
export * from "./Node"
export * from "some-package"

// Utils
export * from "./graph-utils"
export * from "./utils"

⬇️ edit and sort

// Everything from some-package is exposed because blah blah
export * from "some-package"

// Components
export * from "./Edge"
export * from "./Node"

// Utils
export * from "./graph-utils"
export * from "./utils"

The idea is:

You choose what is grouped via comments. The groups themselves don’t change order. But inside each group everything is sorted alphabetically.

  • What do you think about the “group via comments” idea?
  • Can you try #53 on your projects and see what it looks like?
  • Can you share some good examples of re-exports you want sorted from your projects?

from eslint-plugin-simple-import-sort.

remcohaszing avatar remcohaszing commented on May 21, 2024

I do think the “group via comments” idea is neat. I don’t need it for my projects (so far), but I do see its value for other projects.

from eslint-plugin-simple-import-sort.

lydell avatar lydell commented on May 21, 2024

Released in v6.0.0.

from eslint-plugin-simple-import-sort.

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.