-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: add posibility to pass regular expressions to the 'import-order' rules #1015
Comments
The current purpose of the order rule is to group by kind - what you're asking for would be to group by path. I'm not sure if that's a particularly useful enhancement. |
@ljharb Thanks for your response. |
What if we had the ability to define custom groups using regex? {
"groups": ["pify", "builtin", "external", "parent", "sibling", "index"],
"custom-groups": {
"pify": "^pify$"
}
} This would help me with the following code: const pify = require('pify');
const fs = pify(require('fs')); Currently my only option is to either import 'fs' to an alternate variable before importing 'pify', or allow 'builtin' and 'external' to be combined even though (for my use) pify is the only exception to the builtin requires first rule. I think an option for custom groups would allow both of our issues to be resolved without changing the meaning of values in the groups array. @AndrewShapel and @ljharb do you have thoughts on this? |
@ljharb @coreyfarrell I agree with this idea. In that case, we group imports by kind and definition of these groups will be paths. |
Regex-defined import groups would be very helpful, especially in codebases that use path aliases (such as in Webpack.) I would love to require that all imports from a particular path alias are grouped together, as follows:
|
I also would like to have more granular grouping since we use aliases via the module-resolver babel plugin. 🙏 |
A custom group would be very helpful - currently I'm working in a monorepo that has several packages included. When importing one package into another we want to import by These custom packages are installed using |
Related: #674 |
I'd really like to see this merged. Such a good idea |
+1 |
I'd like to be able to define a |
Hi everyone,
Now we have the default groups, such as
["builtin", "external", "parent", "sibling", "index"]
, but would be better to add possibility to pass regular expressions to these groups definitions. For example, like this:It will improve code readability by adding customization of import groupings.
I just want to get approve from maintainers of this repository. Its not a problem to implement it and create PR by myself.
The text was updated successfully, but these errors were encountered: