markdownlint-cli icon indicating copy to clipboard operation
markdownlint-cli copied to clipboard

Misleading error message when no input files are detected

Open arvigeus opened this issue 5 years ago • 4 comments

Continued from markdownlint#304

markdownlint --fix '**/*.md'

When running this command in a project without any md files, it gives me confusing error:

  Usage: markdownlint [options] <files|directories|globs>

  MarkdownLint Command Line Interface

  Options:

    -h, --help                                  output usage information
    -V, --version                               output the version number
    -f, --fix                                   fix basic errors (does not work with STDIN)
    -s, --stdin                                 read from STDIN (does not work with files)
    -o, --output [outputFile]                   write issues to file (no console)
    -c, --config [configFile]                   configuration file (JSON, JSONC, JS, or YAML)
    -i, --ignore [file|directory|glob]          file(s) to ignore/exclude
    -p, --ignore-path [file]                    path to file with ignore pattern(s)
    -r, --rules  [file|directory|glob|package]  custom rule files

It was my mistake to forget to add a readme file, but I think in this case the output should be something more specific, like No valid files found. Now it suggests I entered invalid command.

arvigeus avatar Jul 03 '20 19:07 arvigeus

+1

MrBra1nwash avatar Apr 21 '22 18:04 MrBra1nwash

This same symptom occurs if the user provides a path to a specific existing file but that file is ignored via any of the ignore mechanisms.

My two cents is that either of these two situations should be a 0 exit code -- the tool has considered all 0 files and none of them had any lint issues

micahjsmith avatar Feb 11 '23 00:02 micahjsmith

This is related to https://github.com/igorshubovych/markdownlint-cli/issues/370 but it seems like if the user explicity provides a path to a file to lint, and the file doesn't exist, then we should exit with 1 to indicate the error.

jrwagz avatar Mar 13 '23 17:03 jrwagz

This same symptom occurs if the user provides a path to a specific existing file but that file is ignored via any of the ignore mechanisms.

My two cents is that either of these two situations should be a 0 exit code -- the tool has considered all 0 files and none of them had any lint issues

This totally got me and I've spent quite a bit of time trying to understand why the glob was not working.

moltar avatar Jan 25 '24 20:01 moltar