-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): support path aliases in rulesets (#1692)
* feat(core): support path aliases in rulesets * chore: detect circular aliases * revert: keep the promise left in a comment
- Loading branch information
Showing
12 changed files
with
803 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/core/src/ruleset/__tests__/__fixtures__/overrides/aliases/scope.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { DiagnosticSeverity } from '@stoplight/types'; | ||
import {falsy, pattern, truthy} from '@stoplight/spectral-functions'; | ||
import { RulesetDefinition } from '@stoplight/spectral-core'; | ||
|
||
export { ruleset as default }; | ||
|
||
const ruleset: RulesetDefinition = { | ||
aliases: { | ||
Stoplight: '$..stoplight', | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.yaml'], | ||
rules: { | ||
'value-matches-stoplight': { | ||
message: 'Value must contain Stoplight', | ||
given: '#Stoplight', | ||
severity: DiagnosticSeverity.Error, | ||
then: { | ||
field: 'description', | ||
function: pattern, | ||
functionOptions: { | ||
match: 'Stoplight', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.json'], | ||
aliases: { | ||
Value: '$..value', | ||
}, | ||
rules: { | ||
'truthy-stoplight-property': { | ||
message: 'Value must contain Stoplight', | ||
given: '#Value', | ||
severity: DiagnosticSeverity.Error, | ||
then: { | ||
function: truthy, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
files: ['legacy/**/*.json'], | ||
rules: { | ||
'falsy-value': { | ||
given: '#Value', | ||
severity: DiagnosticSeverity.Warning, | ||
then: { | ||
function: falsy, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.