renke / import-sort

Sort ES2015 (aka ES6) imports. Both JavaScript and TypeScript are supported.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"import-sort-cli" doesn't match files/directories starting with "+" ending up with "No files found for the given patterns" error

vladimiry opened this issue · comments

The core issue is in micromatch matching, used by globby internally, see playground here https://codesandbox.io/s/10p9160v7l

So a possible solution is to escaping "+" character, probably not only the plus one. Ie escaping each pattern before calling globby.sync here.

Similar issue if feeding files with [ or ] in their names. Pretty common nowadays with the likes of Next.js using patterns in file names.

❯ ./node_modules/.bin/import-sort --write '/path/src/pages/posts/[slug].js'
No files found for the given patterns: /path/src/pages/posts/[slug].js, !**/node_modules/**, !./node_modules/**

@nfantone hi, did you find a solution by chance?

@Yedrup Yeah - I had opened #127 for this, but went unnoticed. I also posted a workaround in there.