-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: linter mode (experimental) (#160)
- Loading branch information
Showing
6 changed files
with
95 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
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,30 @@ | ||
# Linter mode | ||
|
||
**[Experimental]** | ||
|
||
`@exodus/schemasafe` can also function in a linter mode, collecting all schema | ||
errors instead of throwing on the first one. | ||
|
||
Usage: | ||
|
||
```cjs | ||
const { lint } = require('@exodus/schemasafe') | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const dir = 'schemas/json' | ||
const files = fs.readdirSync(dir).sort().map(x => path.join(dir, x)) | ||
const schemas = files.map(x => [x, JSON.parse(fs.readFileSync(x, 'utf-8'))]) | ||
|
||
for (const [name, schema] of schemas) { | ||
const errors = lint(schema) // lint(schema, { mode: 'strong' }) | ||
for (const e of errors) { | ||
console.log(`${name}: ${e.message}`) | ||
} | ||
} | ||
``` | ||
|
||
Other [options](./Options.md) are similar to `parser()` and `validator()` modes. | ||
|
||
**Warning:** Exact output messages/details are experimental and might change in | ||
non-major versions. |
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
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