Skip to content

Commit 0d35969

Browse files
committed
fix: Upgrade dependencies
* Upgrade all dev, bench and prod dependencies. At least `commander` needs Node.js 12. Keep AJV at 6.x to retain support for JSON Schema draft 04. * Let the new `eslint` make many code formatting changes. * Replace `standard` with `eslint` to get better console output. * Replace `tslint` with `@typescript-eslint` to use a supported tool. * Replace `uglifyjs` with `terser` to use a supported tool. * Replace `npm` with `pnpm` to gain better performance. * Migrate from Travis CI to GitHub Actions to get semantic-release working properly. BREAKING CHANGE: The minimum supported version has become Node.js 12 instead of the previous Node.js 6. At least `commander` needs the new version.
1 parent 1a7c5ba commit 0d35969

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3672
-4507
lines changed

.github/workflows/ci.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test or Release
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
test-or-release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Sources
12+
uses: actions/checkout@v2
13+
- name: Install Node
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: 'lts/*'
17+
registry-url: 'https://registry.npmjs.org'
18+
- name: Install PNPM
19+
uses: pnpm/action-setup@v2
20+
with:
21+
version: '>=6'
22+
run_install: |
23+
- args: [--frozen-lockfile, --no-verify-store-integrity, --no-optional]
24+
- name: Test
25+
run: npm test
26+
- name: Coverage
27+
run: pnpx codecov --disable=gcov
28+
- name: Publish
29+
uses: cycjimmy/semantic-release-action@v2
30+
with:
31+
semantic_version: 18
32+
branches: master
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.npmignore

-16
This file was deleted.

.nycrc.yml

-3
This file was deleted.

.travis.yml

-16
This file was deleted.

.tslintrc.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root: true
2+
parser: '@typescript-eslint/parser'
3+
plugins:
4+
- '@typescript-eslint'
5+
extends:
6+
- eslint:recommended
7+
- 'plugin:@typescript-eslint/recommended'
8+
rules:
9+
'@typescript-eslint/ban-types': off

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22

33
Copyright (c) 2012-2018 Zachary Carter
4-
Copyright (c) 2019 Ferdinand Prantl
4+
Copyright (c) 2019-2022 Ferdinand Prantl
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# JSON Lint
22

3-
[![NPM version](https://badge.fury.io/js/%40prantlf%2Fjsonlint.svg)](https://badge.fury.io/js/%40prantlf%2Fjsonlint)
4-
[![Build Status](https://travis-ci.com/prantlf/jsonlint.svg?branch=master)](https://travis-ci.com/prantlf/jsonlint)
5-
[![codecov](https://codecov.io/gh/prantlf/jsonlint/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/jsonlint)
6-
[![Dependency Status](https://david-dm.org/prantlf/jsonlint.svg)](https://david-dm.org/prantlf/jsonlint)
7-
[![devDependency Status](https://david-dm.org/prantlf/jsonlint/dev-status.svg)](https://david-dm.org/prantlf/jsonlint#info=devDependencies)
8-
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
3+
[![Latest version](https://img.shields.io/npm/v/@prantlf/jsonlint)
4+
![Dependency status](https://img.shields.io/librariesio/release/npm/@prantlf/jsonlint)
5+
](https://www.npmjs.com/package/@prantlf/jsonlint)
6+
[![Code coverage](https://codecov.io/gh/prantlf/jsonlint/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/jsonlint)
97

108
A [JSON]/CJSON/[JSON5] parser, validator and pretty-printer with a command-line client. A [pure JavaScript version] of the service provided at [jsonlint.com].
119

@@ -319,7 +317,7 @@ ${reason}`)
319317

320318
## License
321319

322-
Copyright (C) 2012-2019 Zachary Carter, Ferdinand Prantl
320+
Copyright (C) 2012-2022 Zachary Carter, Ferdinand Prantl
323321

324322
Licensed under the [MIT License].
325323

benchmarks/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,34 @@ If you modify some grammars, you have to regenerate parsers before running the t
2222

2323
npm run prepare
2424

25+
## Performance
26+
27+
❯ node parse
28+
Parsing JSON data 4868 characters long using:
29+
the built-in parser x 51,485 ops/sec ±7.66% (58 runs sampled)
30+
the pure chevrotain parser x 6,445 ops/sec ±9.27% (52 runs sampled)
31+
the extended chevrotain parser x 6,802 ops/sec ±8.64% (63 runs sampled)
32+
the standard jsonlint parser x 56,024 ops/sec ±8.26% (66 runs sampled)
33+
the extended jsonlint parser x 5,664 ops/sec ±9.85% (64 runs sampled)
34+
the tokenising jsonlint parser x 5,086 ops/sec ±8.54% (65 runs sampled)
35+
the pure hand-built parser x 9,260 ops/sec ±8.53% (67 runs sampled)
36+
the extended hand-built parser x 8,965 ops/sec ±8.46% (66 runs sampled)
37+
the AST parser x 6,226 ops/sec ±7.87% (85 runs sampled)
38+
the Myna parser x 1,784 ops/sec ±7.12% (81 runs sampled)
39+
the pure jju parser x 5,047 ops/sec ±8.06% (72 runs sampled)
40+
the extended jju parser x 4,966 ops/sec ±7.73% (73 runs sampled)
41+
the tokenisable jju parser x 4,287 ops/sec ±8.43% (65 runs sampled)
42+
the tokenising jju parser x 3,378 ops/sec ±8.30% (65 runs sampled)
43+
the comments-enabled parser x 4,101 ops/sec ±9.01% (65 runs sampled)
44+
the pure pegjs parser x 1,628 ops/sec ±8.18% (59 runs sampled)
45+
the extended pegjs parser x 1,611 ops/sec ±9.66% (63 runs sampled)
46+
the pure jison parser x 1,283 ops/sec ±9.04% (57 runs sampled)
47+
the extended jison parser x 1,186 ops/sec ±8.65% (58 runs sampled)
48+
the JSON5 parser x 953 ops/sec ±8.71% (68 runs sampled)
49+
the Nearley parser x 663 ops/sec ±8.44% (59 runs sampled)
50+
The fastest one was the standard jsonlint parser.
51+
52+
2553
[performance]: ./results/performance.md
2654
[quality of error reporting]: ./results/errorReportingQuality.md
2755
[the best parsers for particular scenarios]: ./results/evaluation.md

benchmarks/chevrotain/extended.js

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
var chevrotain = require('chevrotain')
1+
const chevrotain = require('chevrotain')
22

33
// ----------------- lexer -----------------
4-
var createToken = chevrotain.createToken
5-
var Lexer = chevrotain.Lexer
6-
var Parser = chevrotain.Parser
7-
8-
var True = createToken({ name: 'True', pattern: /true/ })
9-
var False = createToken({ name: 'False', pattern: /false/ })
10-
var Null = createToken({ name: 'Null', pattern: /null/ })
11-
var LCurly = createToken({ name: 'LCurly', pattern: /{/ })
12-
var RCurly = createToken({ name: 'RCurly', pattern: /}/ })
13-
var LSquare = createToken({ name: 'LSquare', pattern: /\[/ })
14-
var RSquare = createToken({ name: 'RSquare', pattern: /]/ })
15-
var Comma = createToken({ name: 'Comma', pattern: /,/ })
16-
var Colon = createToken({ name: 'Colon', pattern: /:/ })
17-
var StringLiteral = createToken({
4+
const createToken = chevrotain.createToken
5+
const Lexer = chevrotain.Lexer
6+
const Parser = chevrotain.CstParser
7+
8+
const True = createToken({ name: 'True', pattern: /true/ })
9+
const False = createToken({ name: 'False', pattern: /false/ })
10+
const Null = createToken({ name: 'Null', pattern: /null/ })
11+
const LCurly = createToken({ name: 'LCurly', pattern: /{/ })
12+
const RCurly = createToken({ name: 'RCurly', pattern: /}/ })
13+
const LSquare = createToken({ name: 'LSquare', pattern: /\[/ })
14+
const RSquare = createToken({ name: 'RSquare', pattern: /]/ })
15+
const Comma = createToken({ name: 'Comma', pattern: /,/ })
16+
const Colon = createToken({ name: 'Colon', pattern: /:/ })
17+
const StringLiteral = createToken({
1818
name: 'StringLiteral',
1919
pattern: /"(?:[^\\"]|\\(?:[bfnrtv"\\/]|u[0-9a-fA-F]{4}))*"/
2020
})
21-
var SingleQuotedStringLiteral = createToken({
21+
const SingleQuotedStringLiteral = createToken({
2222
name: 'SingleQuotedStringLiteral',
2323
pattern: /'(?:[^\\']|\\(?:[bfnrtv'\\/]|u[0-9a-fA-F]{4}))*'/
2424
})
25-
var NumberLiteral = createToken({
25+
const NumberLiteral = createToken({
2626
name: 'NumberLiteral',
2727
pattern: /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/
2828
})
29-
var WhiteSpace = createToken({
29+
const WhiteSpace = createToken({
3030
name: 'WhiteSpace',
3131
pattern: /[ \t\n\r]+/,
3232
group: Lexer.SKIPPED
@@ -37,13 +37,13 @@ const Comment = createToken({
3737
group: Lexer.SKIPPED
3838
})
3939
Comment.LINE_BREAKS = true
40-
var SingleLineComment = createToken({
40+
const SingleLineComment = createToken({
4141
name: 'SingleLineComment',
4242
pattern: /\/\/[^\n\r]*/,
4343
group: Lexer.SKIPPED
4444
})
4545

46-
var allTokens = [
46+
const allTokens = [
4747
WhiteSpace,
4848
Comment,
4949
SingleLineComment,
@@ -60,15 +60,15 @@ var allTokens = [
6060
False,
6161
Null
6262
]
63-
var JsonLexer = new Lexer(allTokens)
63+
const JsonLexer = new Lexer(allTokens)
6464

6565
// ----------------- parser -----------------
6666
function JsonParserES5 () {
6767
// invoke super constructor
6868
Parser.call(this, allTokens)
6969

7070
// not mandatory, using <$> (or any other sign) to reduce verbosity (this. this. this. this. .......)
71-
var $ = this
71+
const $ = this
7272

7373
this.RULE('json', function () {
7474
// prettier-ignore
@@ -136,19 +136,19 @@ JsonParserES5.prototype.constructor = JsonParserES5
136136
// ----------------- wrapping it all together -----------------
137137

138138
// reuse the same parser instance.
139-
var parser = new JsonParserES5()
139+
const parser = new JsonParserES5()
140140

141141
module.exports = function (text) {
142-
var lexResult = JsonLexer.tokenize(text)
142+
const lexResult = JsonLexer.tokenize(text)
143143

144144
// setting a new input will RESET the parser instance's state.
145145
parser.input = lexResult.tokens
146146

147147
// any top level rule may be used as an entry point
148-
var cst = parser.json()
148+
const cst = parser.json()
149149

150150
return {
151-
cst: cst,
151+
cst,
152152
lexErrors: lexResult.errors,
153153
parseErrors: parser.errors
154154
}

benchmarks/chevrotain/pure.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
var chevrotain = require('chevrotain')
1+
const chevrotain = require('chevrotain')
22

33
// ----------------- lexer -----------------
4-
var createToken = chevrotain.createToken
5-
var Lexer = chevrotain.Lexer
6-
var Parser = chevrotain.Parser
7-
8-
var True = createToken({ name: 'True', pattern: /true/ })
9-
var False = createToken({ name: 'False', pattern: /false/ })
10-
var Null = createToken({ name: 'Null', pattern: /null/ })
11-
var LCurly = createToken({ name: 'LCurly', pattern: /{/ })
12-
var RCurly = createToken({ name: 'RCurly', pattern: /}/ })
13-
var LSquare = createToken({ name: 'LSquare', pattern: /\[/ })
14-
var RSquare = createToken({ name: 'RSquare', pattern: /]/ })
15-
var Comma = createToken({ name: 'Comma', pattern: /,/ })
16-
var Colon = createToken({ name: 'Colon', pattern: /:/ })
17-
var StringLiteral = createToken({
4+
const createToken = chevrotain.createToken
5+
const Lexer = chevrotain.Lexer
6+
const Parser = chevrotain.CstParser
7+
8+
const True = createToken({ name: 'True', pattern: /true/ })
9+
const False = createToken({ name: 'False', pattern: /false/ })
10+
const Null = createToken({ name: 'Null', pattern: /null/ })
11+
const LCurly = createToken({ name: 'LCurly', pattern: /{/ })
12+
const RCurly = createToken({ name: 'RCurly', pattern: /}/ })
13+
const LSquare = createToken({ name: 'LSquare', pattern: /\[/ })
14+
const RSquare = createToken({ name: 'RSquare', pattern: /]/ })
15+
const Comma = createToken({ name: 'Comma', pattern: /,/ })
16+
const Colon = createToken({ name: 'Colon', pattern: /:/ })
17+
const StringLiteral = createToken({
1818
name: 'StringLiteral',
1919
pattern: /"(?:[^\\"]|\\(?:[bfnrtv"\\/]|u[0-9a-fA-F]{4}))*"/
2020
})
21-
var NumberLiteral = createToken({
21+
const NumberLiteral = createToken({
2222
name: 'NumberLiteral',
2323
pattern: /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/
2424
})
25-
var WhiteSpace = createToken({
25+
const WhiteSpace = createToken({
2626
name: 'WhiteSpace',
2727
pattern: /[ \t\n\r]+/,
2828
group: Lexer.SKIPPED
2929
})
3030

31-
var allTokens = [
31+
const allTokens = [
3232
WhiteSpace,
3333
NumberLiteral,
3434
StringLiteral,
@@ -42,15 +42,15 @@ var allTokens = [
4242
False,
4343
Null
4444
]
45-
var JsonLexer = new Lexer(allTokens)
45+
const JsonLexer = new Lexer(allTokens)
4646

4747
// ----------------- parser -----------------
4848
function JsonParserES5 () {
4949
// invoke super constructor
5050
Parser.call(this, allTokens)
5151

5252
// not mandatory, using <$> (or any other sign) to reduce verbosity (this. this. this. this. .......)
53-
var $ = this
53+
const $ = this
5454

5555
this.RULE('json', function () {
5656
// prettier-ignore
@@ -114,19 +114,19 @@ JsonParserES5.prototype.constructor = JsonParserES5
114114
// ----------------- wrapping it all together -----------------
115115

116116
// reuse the same parser instance.
117-
var parser = new JsonParserES5()
117+
const parser = new JsonParserES5()
118118

119119
module.exports = function (text) {
120-
var lexResult = JsonLexer.tokenize(text)
120+
const lexResult = JsonLexer.tokenize(text)
121121

122122
// setting a new input will RESET the parser instance's state.
123123
parser.input = lexResult.tokens
124124

125125
// any top level rule may be used as an entry point
126-
var cst = parser.json()
126+
const cst = parser.json()
127127

128128
return {
129-
cst: cst,
129+
cst,
130130
lexErrors: lexResult.errors,
131131
parseErrors: parser.errors
132132
}

0 commit comments

Comments
 (0)