-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ruleset-migrator): inline external rulesets & support exceptions (…
…#1711) * fix(ruleset-migrator): more proper npmCustomRegistry support & drop functions prop in output * feat(ruleset-migrator): inline external rulesets * feat(ruleset-migrator): cover exceptions
- Loading branch information
Showing
28 changed files
with
491 additions
and
129 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
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
19 changes: 19 additions & 0 deletions
19
packages/ruleset-migrator/src/__tests__/__fixtures__/exceptions-variant-1/output.cjs
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,19 @@ | ||
const { oas: oas } = require("@stoplight/spectral-rulesets"); | ||
module.exports = { | ||
extends: oas, | ||
overrides: [ | ||
{ | ||
files: ["subfolder/one.yaml#"], | ||
rules: { | ||
"no-$ref-siblings": "off", | ||
}, | ||
}, | ||
{ | ||
files: ["/tmp/docs/one.yaml#/info"], | ||
rules: { | ||
"info-contact": "off", | ||
"info-description": "off", | ||
}, | ||
}, | ||
], | ||
}; |
19 changes: 19 additions & 0 deletions
19
packages/ruleset-migrator/src/__tests__/__fixtures__/exceptions-variant-1/output.mjs
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,19 @@ | ||
import { oas } from "@stoplight/spectral-rulesets"; | ||
export default { | ||
extends: oas, | ||
overrides: [ | ||
{ | ||
files: ["subfolder/one.yaml#"], | ||
rules: { | ||
"no-$ref-siblings": "off", | ||
}, | ||
}, | ||
{ | ||
files: ["/tmp/docs/one.yaml#/info"], | ||
rules: { | ||
"info-contact": "off", | ||
"info-description": "off", | ||
}, | ||
}, | ||
], | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/ruleset-migrator/src/__tests__/__fixtures__/exceptions-variant-1/ruleset.yaml
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,8 @@ | ||
extends: spectral:oas | ||
|
||
except: | ||
"subfolder/one.yaml#": | ||
- no-$ref-siblings | ||
"/tmp/docs/one.yaml#/info": | ||
- info-contact | ||
- info-description |
5 changes: 5 additions & 0 deletions
5
packages/ruleset-migrator/src/__tests__/__fixtures__/extends-variant-5/assets/ruleset.yaml
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,5 @@ | ||
rules: | ||
my-rule: | ||
given: $ | ||
then: | ||
function: truthy |
15 changes: 13 additions & 2 deletions
15
packages/ruleset-migrator/src/__tests__/__fixtures__/extends-variant-5/output.cjs
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
const { migrateRuleset: migrateRuleset } = require('@stoplight/spectral-ruleset-migrator'); | ||
const { truthy: truthy } = require('@stoplight/spectral-functions'); | ||
module.exports = { | ||
extends: await migrateRuleset('https://stoplight.io/ruleset.json'), | ||
extends: [ | ||
{ | ||
rules: { | ||
'my-rule': { | ||
given: '$', | ||
then: { | ||
function: truthy, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}; |
15 changes: 13 additions & 2 deletions
15
packages/ruleset-migrator/src/__tests__/__fixtures__/extends-variant-5/output.mjs
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
import { migrateRuleset } from '@stoplight/spectral-ruleset-migrator'; | ||
import { truthy } from '@stoplight/spectral-functions'; | ||
export default { | ||
extends: await migrateRuleset('https://stoplight.io/ruleset.json'), | ||
extends: [ | ||
{ | ||
rules: { | ||
'my-rule': { | ||
given: '$', | ||
then: { | ||
function: truthy, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}; |
3 changes: 2 additions & 1 deletion
3
packages/ruleset-migrator/src/__tests__/__fixtures__/extends-variant-5/ruleset.yaml
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
{ 'extends': 'https://stoplight.io/ruleset.json' } | ||
extends: | ||
- ./assets/ruleset.yaml |
13 changes: 6 additions & 7 deletions
13
packages/ruleset-migrator/src/__tests__/__fixtures__/functions-variant-1/output.cjs
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
13 changes: 6 additions & 7 deletions
13
packages/ruleset-migrator/src/__tests__/__fixtures__/functions-variant-1/output.mjs
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
7 changes: 3 additions & 4 deletions
7
packages/ruleset-migrator/src/__tests__/__fixtures__/functions-variant-2/output.cjs
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
7 changes: 3 additions & 4 deletions
7
packages/ruleset-migrator/src/__tests__/__fixtures__/functions-variant-2/output.mjs
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
Oops, something went wrong.