stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v3.1, v3.0, and v2.0 as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.43k stars 235 forks source link

Return code is OK if file does not exist #2493

Closed nico01h closed 1 year ago

nico01h commented 1 year ago

User story. As a developer, I can check that the files I want to verify are present, so that I can check that spectral returns OK only when files are checked.

Is your feature request related to a problem? Yes, because if I add spectral in a CI, I can have a false positive : the CI will return OK even if the file does not exist. A developer could easily rename the filename, and spectral would return OK.

Describe the solution you'd like I would like to have an error if any of the files to check does not exist. It may be with an option, or the default behavior, it does not matter to me.

Additional context Current behaviour (spectral file not present)

$ spectral lint --ruleset .spectral.yaml swagger.yml -F=warn No results with a severity of 'warn' or higher found!

$ ls package.json README.md

Thank you for your help, and the amazing job!

P0lip commented 1 year ago

Hey @nico01h. Please use the --fail-on-unmatched-globs flag. That won't be required in the next major release - it'll be enabled by default, but currently it's not, so you need to provide it explicitly. hanks!

nico01h commented 1 year ago

Hi, I didn't see/understood it in the options, works fine! Thanks for the quick answer!