editorconfig-core-js icon indicating copy to clipboard operation
editorconfig-core-js copied to clipboard

Broken resolution for paths that include `[` characters

Open medikoo opened this issue 4 years ago • 3 comments

I've discovered that .editorconfig settings are not discovered in paths as e.g. /Volumes/[C] 10 Edge/Users/xxx/some-package (on my side it's the path on which I can access Windows disk as exposed by Parallels Desktop)

I assume it's because of [ characters.

How to reproduce

1. Prepare same .editorconfig file in following two folders as e.g.

  • /Users/xxx/some-package
  • /Volumes/[C] 10 Edge/Users/xxx/some-package

2. Install editorconfig npm package in each of the folders

3. Create following test.js script in each of the folders:

const { parseSync } = require("editorconfig");

if (process.cwd() !== __dirname) {
  throw new Error("To expose the issue, working directory must be same as dir of a script")
}

console.log(
  parseSync("test.js", {
    root: __dirname
  })
);

4. Navigate into each of the directory and run node test.js. In first one content of .editorconfig will be resolved, in second one it will not

medikoo avatar Apr 01 '20 01:04 medikoo

I was just debugging the same problem and I found this. I can confirm I have the same problem. I will try to see if there is something we can do.

radum avatar Apr 30 '20 07:04 radum

Tracked it down to minimatch variant we are using in fnmatch.js.

# When testing for this file path fn `if (!fnmatch(filepath, fullGlob)) {` will return false instead of true
/Volumes/[C] Windows 10/work/test/**/*
false

And so the entire module breaks.

radum avatar Apr 30 '20 12:04 radum

Yeah. I don't love that this project has variations to minimatch.

jednano avatar May 18 '20 16:05 jednano