Repository: eslint/eslint (JavaScript)

Issue:
overrides don't recognize dotfiles
**Tell us about your environment**

* **ESLint Version:** 5.10.0
* **Node Version:** 11.1.0
* **npm Version:** 6.5.0

**What parser (default, Babel-ESLint, etc.) are you using?**

- N/A

**Please show your full configuration:**

```yml
root: true

overrides:
  - files: "*.ts"
    parser: typescript-eslint-parser
```

**What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.**

<!-- Paste the command you used to run ESLint: -->
```bash
eslint --print-config .test.ts
```

**What did you expect to happen?**

It prints:

```json
{
  "globals": {},
  "env": {},
  "rules": {},
  "parserOptions": {},
  "root": true,
  "files": "*.ts",
  "parser": "typescript-eslint-parser"
}
```

**What actually happened? Please include the actual, raw output from ESLint.**

It printed:

```json
{
  "globals": {},
  "env": {},
  "rules": {},
  "parserOptions": {},
  "root": true
}
```


**Are you willing to submit a pull request to fix this bug?**

I'm sorry, I don't have enough time for now.


Discussion:
~is files expected to be an array? I believe eslint should output a warning, rather than ignoring it sliently.~

oops, I confirmed the `files` also accept a single string. sorry for misleading. (@kaicataldo --.)

it actually works, as you are using `--print-config .test.ts`, and it output the config.

the `files` is only used in glob matching, I guess it was deleted after that (as in the OP, the `files` missing).


~~As @Aladdin-ADD mentioned, it looks like the `files` key is currently expected to be an array (see https://github.com/eslint/eslint/blob/5d451c510c15abc41b5bb14b4955a7db96aeb100/lib/config.js and https://github.com/eslint/eslint/blob/caeb223c4f7b0b6fe35e5348ae0df4c6446b5bed/lib/config/config-ops.js). It also looks like the JSDoc for `configOps.pathMatchesGlobs` is incorrect.~~

~~I think we should fix `configOps.pathMatchesGlobs` to allow for a single string instead of an array (since it looks like that was the intention), but I also think we should be validating the `files` key of objects in the `overrides` array so that it doesn’t silently fail when misconfigured. I’m willing to do the work if we decide to do this. It’s been a while since I looked at the configuration code and I’d like to familiarize myself again.~~

Edit: Looking at this one more time, I’m actually not so sure that’s what’s happening here. I’ll look again am when I can test it at a computer. I should probably not be doing this on my phone...
I had written that the code block in "What did you expect to happen?" section is the result of `eslint --print-config test.ts` (note the dot at the beggining of the filename doesn't exist). So, this means, I expected the following two commands to generate the same config.

```
eslint --print-config test.ts
eslint --print-config .test.ts
```



Patch:
diff --git a/lib/config/config-ops.js b/lib/config/config-ops.js
index 6c298d36473c..726c33e1ef98 100644
--- a/lib/config/config-ops.js
+++ b/lib/config/config-ops.js
@@ -366,7 +366,7 @@ module.exports = {
             }
         });
 
-        const opts = { matchBase: true };
+        const opts = { dot: true, matchBase: true };
 
         return patternList.some(pattern => minimatch(filePath, pattern, opts)) &&
             !excludedPatternList.some(excludedPattern => minimatch(filePath, excludedPattern, opts));


Test patch:
diff --git a/tests/fixtures/cli-engine/overrides-with-dot/.eslintrc.yml b/tests/fixtures/cli-engine/overrides-with-dot/.eslintrc.yml
new file mode 100644
index 000000000000..5acdae3fd5c6
--- /dev/null
+++ b/tests/fixtures/cli-engine/overrides-with-dot/.eslintrc.yml
@@ -0,0 +1,6 @@
+root: true
+
+overrides:
+  - files: "*.js"
+    rules:
+      no-unused-vars: error
diff --git a/tests/fixtures/cli-engine/overrides-with-dot/.test-target.js b/tests/fixtures/cli-engine/overrides-with-dot/.test-target.js
new file mode 100644
index 000000000000..ac09549ac7a5
--- /dev/null
+++ b/tests/fixtures/cli-engine/overrides-with-dot/.test-target.js
@@ -0,0 +1,1 @@
+var a = 0
diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js
index 9a57e86dfd1a..026d15ee1714 100644
--- a/tests/lib/cli-engine.js
+++ b/tests/lib/cli-engine.js
@@ -2861,6 +2861,23 @@ describe("CLIEngine", () => {
                 }, "No files matching 'non-exist.js' were found.");
             });
         });
+
+        describe("overrides", () => {
+            beforeEach(() => {
+                engine = new CLIEngine({
+                    cwd: getFixturePath("cli-engine/overrides-with-dot"),
+                    ignore: false
+                });
+            });
+
+            it("should recognize dotfiles", () => {
+                const ret = engine.executeOnFiles([".test-target.js"]);
+
+                assert.strictEqual(ret.results.length, 1);
+                assert.strictEqual(ret.results[0].messages.length, 1);
+                assert.strictEqual(ret.results[0].messages[0].ruleId, "no-unused-vars");
+            });
+        });
     });
 
     describe("getConfigForFile", () => {