diff --git a/lib/cli-engine/config-array/override-tester.js b/lib/cli-engine/config-array/override-tester.js index 2aaefac7d1c..6f61e4ff1c7 100644 --- a/lib/cli-engine/config-array/override-tester.js +++ b/lib/cli-engine/config-array/override-tester.js @@ -55,7 +55,17 @@ function toMatcher(patterns) { if (patterns.length === 0) { return null; } - return patterns.map(pattern => new Minimatch(pattern, minimatchOpts)); + return patterns.map(pattern => { + if (/^\.[/\\]/u.test(pattern)) { + return new Minimatch( + pattern.slice(2), + + // `./*.js` should not match with `subdir/foo.js` + { ...minimatchOpts, matchBase: false } + ); + } + return new Minimatch(pattern, minimatchOpts); + }); } /** diff --git a/tests/lib/cli-engine/config-array/override-tester.js b/tests/lib/cli-engine/config-array/override-tester.js index f351cfaa197..554ebb421d7 100644 --- a/tests/lib/cli-engine/config-array/override-tester.js +++ b/tests/lib/cli-engine/config-array/override-tester.js @@ -191,10 +191,10 @@ describe("OverrideTester", () => { match("foo.js", ["*.js"], []); match("foo.js", ["**/*.js"], []); match("bar.js", ["*.js"], ["foo.js"]); + match("foo.js", ["./foo.js"], []); + match("foo.js", ["./*"], []); + match("foo.js", ["./**"], []); - noMatch("foo.js", ["./foo.js"], []); - noMatch("foo.js", ["./*"], []); - noMatch("foo.js", ["./**"], []); noMatch("foo.js", ["*"], ["foo.js"]); noMatch("foo.js", ["*.js"], ["foo.js"]); noMatch("foo.js", ["**/*.js"], ["foo.js"]); @@ -208,11 +208,11 @@ describe("OverrideTester", () => { match("subdir/foo.js", ["subdir/foo.js"], []); match("subdir/foo.js", ["subdir/*"], []); match("subdir/second/foo.js", ["subdir/**"], []); + match("subdir/foo.js", ["./**"], []); + match("subdir/foo.js", ["./subdir/**"], []); + match("subdir/foo.js", ["./subdir/*"], []); noMatch("subdir/foo.js", ["./foo.js"], []); - noMatch("subdir/foo.js", ["./**"], []); - noMatch("subdir/foo.js", ["./subdir/**"], []); - noMatch("subdir/foo.js", ["./subdir/*"], []); noMatch("subdir/foo.js", ["*"], ["subdir/**"]); noMatch("subdir/very/deep/foo.js", ["*.js"], ["subdir/**"]); noMatch("subdir/second/foo.js", ["subdir/*"], []);