diff --git a/markdownlint.js b/markdownlint.js index c025abe84..8374ebc86 100755 --- a/markdownlint.js +++ b/markdownlint.js @@ -91,7 +91,10 @@ function prepareFileList(files, fileExtensions, previousResults) { nodir: true }; let extensionGlobPart = '*.'; - if (fileExtensions.length === 1) { + if (!fileExtensions) { + // Match everything + extensionGlobPart = ''; + } else if (fileExtensions.length === 1) { // Glob seems not to match patterns like 'foo.{js}' extensionGlobPart += fileExtensions[0]; } else { @@ -267,7 +270,7 @@ if (existsSync(ignorePath)) { } const files = prepareFileList(program.args, ['md', 'markdown']).filter(value => ignoreFilter(value)); -const ignores = prepareFileList(options.ignore, ['md', 'markdown'], files); +const ignores = prepareFileList(options.ignore, null, files); const customRules = loadCustomRules(options.rules); const diff = files.filter(file => !ignores.some(ignore => ignore.absolute === file.absolute)).map(paths => paths.original); diff --git a/package-lock.json b/package-lock.json index 57e22b02b..1508f2950 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "markdownlint": "~0.33.0", "minimatch": "~9.0.3", "run-con": "~1.3.2", - "toml": "^3.0.0" + "toml": "~3.0.0" }, "bin": { "markdownlint": "markdownlint.js" diff --git a/test/subdir-incorrect/UPPER.MD b/test/subdir-incorrect/UPPER.MD new file mode 100644 index 000000000..551b1b3f2 --- /dev/null +++ b/test/subdir-incorrect/UPPER.MD @@ -0,0 +1,26 @@ +## header 2 +# header + +```fence +$ code +``` + +text + +```fence +$ code +``` + +text + +```fence +$ code +``` + +text + +```fence +$ code +``` + +text diff --git a/test/test.js b/test/test.js index 59a31c518..ff3517fd5 100644 --- a/test/test.js +++ b/test/test.js @@ -262,6 +262,13 @@ test('glob linting with failing files passes when ignored by multiple globs', as t.is(result.exitCode, 0); }); +test('glob linting with directory ignore applies to all files within', async t => { + const result = await execa('../markdownlint.js', ['subdir-incorrect/**', '--ignore', 'subdir-incorrect'], {stripFinalNewline: false}); + t.is(result.stdout, ''); + t.is(result.stderr, ''); + t.is(result.exitCode, 0); +}); + test('linting results are sorted by file/line/names/description', async t => { try { await execa('../markdownlint.js', ['--config', 'test-config.json', 'incorrect.md'], {stripFinalNewline: false});