Comments (8)
Actually my use case is the simplest one possible. My packages contain an index.ts
which re-exports named packages.
Examples:
- https://gitlab.com/appsemble/appsemble/-/blob/master/packages/node-utils/src/index.ts
- https://gitlab.com/appsemble/appsemble/-/blob/master/packages/preact-components/src/index.ts
- https://gitlab.com/appsemble/appsemble/-/blob/master/packages/react-components/src/index.ts
- https://gitlab.com/appsemble/appsemble/-/blob/master/packages/utils/src/index.ts
- https://gitlab.com/appsemble/appsemble/-/blob/master/packages/web-utils/src/index.ts
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.
Technically those are exports, but I agree that they feel like imports.
from eslint-plugin-simple-import-sort.
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.
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.
Hi all, I've created a POC PR for this. Let me know what you think.
from eslint-plugin-simple-import-sort.
@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.
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.
Released in v6.0.0.
from eslint-plugin-simple-import-sort.
Related Issues (20)
- Question: relative side-effect imports are placed before relative imports HOT 2
- Question: how to approach the workaround for padding-line-between-statements? HOT 2
- Please update your docs HOT 2
- Named imports with `as` aren't sure where to go HOT 2
- Using without new lines between groups HOT 2
- Error with aliased imports and eslint-plugin-import HOT 1
- Support for namespace imports HOT 8
- Prepare for ESLint 9: Deprecated methods
- sorted import specifiers missing space HOT 2
- how to make side effect always be top HOT 2
- I thought library imports were supposed to come before relative imports? HOT 4
- Error: Run autofix to sort these imports! HOT 7
- Duplicate imports are not being removed HOT 1
- Conflict between eslint-plugin-simple-import-sort and esbenp.prettier-vscode HOT 2
- TypeError: parentNode.body is not iterable in v11 HOT 6
- Import in group despite not being matched by regex expression HOT 2
- What is the difference vs eslint-plugin-import HOT 1
- Add TypeScript types HOT 7
- Explore configuration with real regex instead of strings
- Why add empty line bettween two react imports HOT 3
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-simple-import-sort.