-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
json
option to get accurate line/column listings
- Loading branch information
Showing
11 changed files
with
88 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"releases": [{ "name": "better-ajv-errors", "type": "minor" }], | ||
"dependents": [] | ||
} |
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 @@ | ||
Support json option to get accurate line/column listings |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
{ | ||
"type": "doc", | ||
"version": 1, | ||
"content": [{ "type": "paragarph" }] | ||
} |
File renamed without changes.
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,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Main should output error with codeframe 1`] = ` | ||
"[31m[1mENUM[22m[39m[31m should be equal to one of the allowed values[39m | ||
[31m(paragraph, bulletList, mediaSingle, codeBlock, orderedList, heading, panel, blockquote, rule, mediaGroup, applicationCard, decisionList, taskList, table, extension, bodiedExtension, blockCard, layoutSection)[39m | ||
[0m [90m 2 | [39m [32m\\"type\\"[39m[33m:[39m [32m\\"doc\\"[39m[33m,[39m[0m | ||
[0m [90m 3 | [39m [32m\\"version\\"[39m[33m:[39m [35m1[39m[33m,[39m[0m | ||
[0m[31m[1m>[22m[39m[90m 4 | [39m [32m\\"content\\"[39m[33m:[39m [{ [32m\\"type\\"[39m[33m:[39m [32m\\"paragarph\\"[39m }][0m | ||
[0m [90m | [39m [31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m [31m[1m👈🏽 Did you mean [95mparagraph[31m here?[22m[39m[0m | ||
[0m [90m 5 | [39m}[0m | ||
[0m [90m 6 | [39m[0m" | ||
`; | ||
exports[`Main should output error with reconstructed codeframe 1`] = ` | ||
"[31m[1mENUM[22m[39m[31m should be equal to one of the allowed values[39m | ||
[31m(paragraph, bulletList, mediaSingle, codeBlock, orderedList, heading, panel, blockquote, rule, mediaGroup, applicationCard, decisionList, taskList, table, extension, bodiedExtension, blockCard, layoutSection)[39m | ||
[0m [90m 4 | [39m [32m\\"content\\"[39m[33m:[39m [[0m | ||
[0m [90m 5 | [39m {[0m | ||
[0m[31m[1m>[22m[39m[90m 6 | [39m [32m\\"type\\"[39m[33m:[39m [32m\\"paragarph\\"[39m[0m | ||
[0m [90m | [39m [31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m[31m[1m^[22m[39m [31m[1m👈🏽 Did you mean [95mparagraph[31m here?[22m[39m[0m | ||
[0m [90m 7 | [39m }[0m | ||
[0m [90m 8 | [39m ][0m | ||
[0m [90m 9 | [39m}[0m" | ||
`; |
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,33 @@ | ||
import Ajv from 'ajv'; | ||
import { getSchemaAndData } from '../test-helpers'; | ||
import betterAjvErrors from '../'; | ||
|
||
describe('Main', () => { | ||
it('should output error with reconstructed codeframe', async () => { | ||
const [schema, data] = await getSchemaAndData('default', __dirname); | ||
const ajv = new Ajv({ jsonPointers: true }); | ||
const validate = ajv.compile(schema); | ||
const valid = validate(data); | ||
expect(valid).toBeFalsy(); | ||
|
||
const res = betterAjvErrors(schema, data, validate.errors, { | ||
format: 'cli', | ||
indent: 2, | ||
}); | ||
expect(res).toMatchSnapshot(); | ||
}); | ||
|
||
it('should output error with codeframe', async () => { | ||
const [schema, data, json] = await getSchemaAndData('default', __dirname); | ||
const ajv = new Ajv({ jsonPointers: true }); | ||
const validate = ajv.compile(schema); | ||
const valid = validate(data); | ||
expect(valid).toBeFalsy(); | ||
|
||
const res = betterAjvErrors(schema, data, validate.errors, { | ||
format: 'cli', | ||
json, | ||
}); | ||
expect(res).toMatchSnapshot(); | ||
}); | ||
}); |
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