daidodo / format-imports

JavaScript and TypeScript Import/Export Sorter
MIT License
45 stars 2 forks source link

Feature Request: pattern specific config overrides #26

Open I-Enderlord-I opened 1 year ago

I-Enderlord-I commented 1 year ago

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 base classes at the top as a kind of header, but split them into other groups in regular files.

I'd be helpful if one could create multiple group configurations, which are selected based on a regex matching the file path. Possibly by adding an option overrides: { pattern: string, config: string }[] which specifies alternative config files for special patterns.

Since the files in question do not lie in separate folders and the imported functions appear elsewhere as well, it's not possible to use specialized config files in subfolders or more complicated grouping rules. Since I use the VSCode plugin for this, this machanic could be achieved by vscode issue 35350, but that might take some time. The only option right now is to exclude those files and do the sorting manually, but that defeats the purpose of using format-imports.

Basically a duplicate of issue 75 in the plugin repository, but now at the place where config resolution actually happens.