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), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.48k stars 233 forks source link

Rule overrides with file paths don't work #2587

Closed jcageman closed 5 months ago

jcageman commented 7 months ago

This is a repost of : #2424 and in my opinion it's a bug that simple overrides won't work, such as:

overrides:
  - files:
      - "folder1/*.yml"
    rules:
      info-description: off

I now i have to work with relative paths compared to the location i am calling the script from which i think is not super nice. Documentation suggests it's possible given the examples, but they don't work. See documentation: https://docs.stoplight.io/docs/spectral/293426e270fac-overrides

Particular files/folders files: ['schemas/**/*.draft7.json']

aleung commented 7 months ago

Where is your ruleset file?

I just figured out that the file path should be related to the ruleset file but not the current directory.

For example, if the project folder structure is like below, the file path needs to be ../folder1/*.yml

/my_project
           /config
                   /spectral.yaml
           /folder1
                   /api_x.yml
                   /api_y.yml
jcageman commented 7 months ago

this is indeed similar to my folder structure, i think it's confusing that its relative to the spectral config to be honest and it makes more sense that it just does pattern matching on the files checked instead. E.g. regex like.