Rule exceptions
See original GitHub issueUser story. As a user, I can add exceptions to certain rules to ignore failures so that I can guard against new changes but run against legacy descriptions.
Is your feature request related to a problem?
For API descriptions that have a “pre-linting” era, but with linting rules that should be enforced for new changes, it would be nice to have some kind of mechanism similar to eslint’s // eslint-disable-line no-use-before-define
.
Describe the solution you’d like
I couldn’t find any talks about this feature in issues / PRs, let me know if it exists already. I can see different ways of tackling this.
-
YAGNI: Users are expected to run spectral in a custom way, running only against new changes / diffs. Or maybe expected to write custom JS rules and do the filtering there.
-
Users are expected to handle this with
given
’s JSON PATH entirely. -
A new rule attribute:
paths-kebab-case:
description: Should paths be kebab-case.
message: '{{property}} is not kebab-case: {{error}}'
severity: error
recommended: true
given: $.paths[*]~
then:
function: pattern
functionOptions:
match: "^(\/[a-z0-9-{}]+)+$"
except:
- <json_path_matching-legacy-paths>
- An eslint style convention directly on API specifications (Tricky since users would be required to strip this out before making public)
x-spectral-disable: "paths-kebab-case"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (8 by maintainers)
The CLI has
—skip-rule
Which probably doesn’t help, and the config files (rulesets) allow turning entire rules off, but we don’t support specific exceptions on a line or file basis just yet. I think x- extensions would be the way to go for now yeah.@idosal so far efforts have been going into v5.0 and cleaning out some of the old cruft which has been deprecated throughout v4.2. With that work nearing an end, we can look at new functionality like this.
@P0lip @marbemac I would love to see this coming for v5.1 so we can work on getting it into Studio too? A Right Click > “Ignore this instance” to accompany the Right Click > “Ignore this rule” option I’ve heard mentioned before. 😃