diff --git a/lib/eslint/eslint-helpers.js b/lib/eslint/eslint-helpers.js index bf08ec00feb..ff3695dc644 100644 --- a/lib/eslint/eslint-helpers.js +++ b/lib/eslint/eslint-helpers.js @@ -591,13 +591,9 @@ function isErrorMessage(message) { */ function createIgnoreResult(filePath, baseDir) { let message; - const isHidden = filePath.split(path.sep) - .find(segment => /^\./u.test(segment)); const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules"); - if (isHidden) { - message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!'\") to override."; - } else if (isInNodeModules) { + if (isInNodeModules) { message = "File ignored by default because it is located under the node_modules directory. Use ignore pattern \"!**/node_modules/\" to override."; } else { message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."; diff --git a/tests/lib/eslint/flat-eslint.js b/tests/lib/eslint/flat-eslint.js index aec6ba43791..00a906b0fb7 100644 --- a/tests/lib/eslint/flat-eslint.js +++ b/tests/lib/eslint/flat-eslint.js @@ -1340,6 +1340,26 @@ describe("FlatESLint", () => { assert.strictEqual(results[0].suppressedMessages.length, 0); }); + it("should return a warning about matching ignore patterns when an explicitly given dotfile is ignored", async () => { + eslint = new FlatESLint({ + overrideConfigFile: "eslint.config_with_ignores.js", + cwd: getFixturePath() + }); + const filePath = getFixturePath("dot-files/.a.js"); + const results = await eslint.lintFiles([filePath]); + + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].filePath, filePath); + assert.strictEqual(results[0].messages[0].severity, 1); + assert.strictEqual(results[0].messages[0].message, "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."); + assert.strictEqual(results[0].errorCount, 0); + assert.strictEqual(results[0].warningCount, 1); + assert.strictEqual(results[0].fatalErrorCount, 0); + assert.strictEqual(results[0].fixableErrorCount, 0); + assert.strictEqual(results[0].fixableWarningCount, 0); + assert.strictEqual(results[0].suppressedMessages.length, 0); + }); + it("should return two messages when given a file in excluded files list while ignore is off", async () => { eslint = new FlatESLint({ cwd: getFixturePath(),