Skip to content

Commit

Permalink
Fix: Change error message for implicit file ignore (fixes #12873)
Browse files Browse the repository at this point in the history
  • Loading branch information
snhardin committed Feb 6, 2020
1 parent af95154 commit 79385f8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cli-engine/cli-engine.js
Expand Up @@ -278,7 +278,8 @@ function verifyText({
*/
function createIgnoreResult(filePath, baseDir) {
let message;
const isHidden = /^\./u.test(path.basename(filePath));
const isHidden = filePath.split(path.sep)
.find(directory => /^\./u.test(directory));
const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components");

Expand Down
21 changes: 21 additions & 0 deletions tests/lib/cli-engine/cli-engine.js
Expand Up @@ -1005,6 +1005,27 @@ describe("CLIEngine", () => {
assert.strictEqual(report.results[0].messages[0].message, expectedMsg);
});

// https://github.com/eslint/eslint/issues/12348
it("should not check files within a .hidden folder if they are passed explicitly without the --no-ignore flag", () => {
engine = new CLIEngine({
cwd: getFixturePath("cli-engine"),
useEslintrc: false,
rules: {
quotes: [2, "single"]
}
});

const report = engine.executeOnFiles(["hidden/.hiddenfolder/double-quotes.js"]);
const expectedMsg = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override.";

assert.strictEqual(report.results.length, 1);
assert.strictEqual(report.results[0].errorCount, 0);
assert.strictEqual(report.results[0].warningCount, 1);
assert.strictEqual(report.results[0].fixableErrorCount, 0);
assert.strictEqual(report.results[0].fixableWarningCount, 0);
assert.strictEqual(report.results[0].messages[0].message, expectedMsg);
});

it("should check .hidden files if they are passed explicitly with --no-ignore flag", () => {

engine = new CLIEngine({
Expand Down

0 comments on commit 79385f8

Please sign in to comment.