- ⚔️ Lint all errors at once
- 🌈 Human-friendly, intuitive message to stdout
- 🚀 Smaller than ESLint
For NPM users
npm i @biu/jsonlint
for yarn users
yarn add @biu/jsonlint
const { lint, format } = require( '@biu/jsonlint' )
const result = lint( string, options )
const prettied = format( result )
console.log( result.codeframe ) // or console.log( prettied )
prettied
looks like Screenshot
result
looks like
{
source: '', // source code
errors: [], // with keys: `{ line, column, message, severity }`
comments: [], // with keys: `{ start: { line, column }, end: { line, column } }`
codeframe: '', // codeframe with error locations and syntax highlight
}
Type: String
By default it reports all comments as error, if you want to remove comment from errors, set allowComments
to true
JSON.parse
is not fault tolerant, so it cann't continue after seeing first error, while this library using a fault tolerant parser to avoid this
MIT