Skip to content
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

Pattern specific configuration #75

Open
I-Enderlord-I opened this issue Apr 30, 2022 · 2 comments
Open

Pattern specific configuration #75

I-Enderlord-I opened this issue Apr 30, 2022 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@I-Enderlord-I
Copy link

I-Enderlord-I commented Apr 30, 2022

In some of my projects there are special files (recognisable by their names) that always import certain base classes. I'd like to always have those at the top as a kind of header, but split into other groups in regular files.

I'd be helpful if one could create multiple configurations in the import-sorter.json file, which are selected based on regex matching of the file path. Possibly by optionally wrapping the configuration in a top-level array and adding an include option similar to the current exclude.

The alternative would be to change the tsImportSorter.configuration.configurationFileName setting in VSCode depending on those patterns, but microsoft/vscode#35350 might take some time.

@daidodo daidodo added enhancement New feature or request question Further information is requested labels May 2, 2022
@daidodo
Copy link
Owner

daidodo commented May 2, 2022

@I-Enderlord-I, thanks for the feedback!

Custom config based on source file paths are not supported ATM. But I can think of a few workarounds:

  • If your special files are under their own directory, you can add local import-sorter.json or package.json. The config inside will override parent/general config.
  • If above is not possible, you can add exclude or excludeGlob patterns to those special files and manually maintain them.
  • Or, if there are any noticeable differences to the import statements by Grouping Rules in special and regular files, you can use them in groupRules.

Please tell me if any of the above would help!

@I-Enderlord-I
Copy link
Author

None of those are helpful in this specific context.

  • No, those files are not in separate directories, that's why I spoke of recognition by name pattern, not folder.
  • Not maintaining them manually is one of the biggest reasons to do it automatically, because those files specifically tend to have a huge amount of imports.
  • As mentioned before, no, those import appear elsewhere and should not be grouped separately there.

@daidodo daidodo added help wanted Extra attention is needed and removed question Further information is requested labels Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants