Skip to content

Commit 3ca1a2e

Browse files
committed
v0.0.1
1 parent 67fcdfe commit 3ca1a2e

File tree

9 files changed

+83
-64
lines changed

9 files changed

+83
-64
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ trial
2323

2424
test/coverage.html
2525

26+
coverage
27+
28+
package-lock.json
29+
yarn.lock

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# variant-jsonc
2-
JSONC
1+
# @jsonic/jsonc (JSONIC variant plugin)
2+
3+
This plugin allows the [Jsonic](https://jsonic.senecajs.org) JSON parser
4+
to parse [JSONC](https://github.com/microsoft/node-jsonc-parser) format files.
5+
6+
7+
38

4-
https://github.com/microsoft/node-jsonc-parser
59

610

jsonc.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ declare type JsoncOptions = {
44
disallowComments?: boolean;
55
};
66
declare function Jsonc(jsonic: Jsonic, options: JsoncOptions): void;
7-
export { Jsonc, };
8-
export type { JsoncOptions, };
7+
export { Jsonc };
8+
export type { JsoncOptions };

jsonc.js

Lines changed: 27 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonc.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonc.ts

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
1-
21
import { Jsonic } from 'jsonic'
32

4-
53
type JsoncOptions = {
64
allowTrailingComma?: boolean
75
disallowComments?: boolean
86
}
97

108
function Jsonc(jsonic: Jsonic, options: JsoncOptions) {
11-
// TODO: merge these calls
12-
139
jsonic.options({
14-
text: { lex: false },
15-
number: { hex: false, oct: false, bin: false, sep: null },
16-
string: { chars: '"', multiChars: '', allowUnknown: false, escape: { v: null } },
17-
comment: { lex: false },
18-
map: { extend: false },
19-
lex: { empty: false },
10+
text: {
11+
lex: false,
12+
},
13+
number: {
14+
hex: false,
15+
oct: false,
16+
bin: false,
17+
sep: null,
18+
},
19+
string: {
20+
chars: '"',
21+
multiChars: '',
22+
allowUnknown: false,
23+
escape: {
24+
v: null,
25+
},
26+
},
27+
comment: {
28+
lex: true !== options.disallowComments,
29+
},
30+
map: {
31+
extend: false,
32+
},
33+
lex: {
34+
empty: false,
35+
},
2036
rule: {
2137
finish: false,
22-
include: 'json' + (options.allowTrailingComma ? ',comma' : '')
38+
include: 'json' + (options.allowTrailingComma ? ',comma' : ''),
2339
},
2440
})
25-
26-
jsonic.options({
27-
comment: {
28-
lex: true && !options.disallowComments,
29-
marker: [
30-
{ line: true, start: '//', lex: true },
31-
{ line: false, start: '/' + '*', end: '*' + '/', lex: true },
32-
],
33-
}
34-
})
3541
}
3642

37-
export {
38-
Jsonc,
39-
}
43+
export { Jsonc }
4044

41-
export type {
42-
JsoncOptions,
43-
}
45+
export type { JsoncOptions }

package.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@jsonic/jsonc",
33
"version": "0.0.1",
4-
"main": "@jsonic/jsonc.js",
4+
"description": "Jsonic plugin for the JSONC variant of JSON.",
5+
"main": "jsonc.js",
56
"type": "commonjs",
6-
"browser": "@jsonic/jsonc.min.js",
7-
"types": "@jsonic/jsonc.d.ts",
8-
"description": "JSONC",
7+
"browser": "jsonc.min.js",
8+
"types": "jsonc.d.ts",
99
"homepage": "https://github.com/jsonicjs/variant-jsonc",
1010
"keywords": [
1111
"pattern",
@@ -17,19 +17,20 @@
1717
"author": "Richard Rodger (http://richardrodger.com)",
1818
"repository": {
1919
"type": "git",
20-
"url": "git://github.com/jsonicic/variant-jsonc.git"
20+
"url": "git://github.com/jsonicjs/variant-jsonc.git"
2121
},
2222
"scripts": {
2323
"test": "jest --coverage",
2424
"test-some": "jest -t",
25+
"test-watch": "jest --coverage --watchAll",
2526
"watch": "tsc -w -d",
2627
"build": "tsc -d && cp jsonc.js jsonc.min.js && browserify -o jsonc.min.js -e jsonc.js -s @JsonicJsonc -im -i assert -p tinyify",
2728
"prettier": "prettier --write --no-semi --single-quote *.ts test/*.js",
2829
"clean": "rm -rf node_modules yarn.lock package-lock.json",
2930
"reset": "npm run clean && npm i && npm test",
3031
"repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag v$REPO_VERSION && git push --tags;",
3132
"repo-publish": "npm run clean && npm i && npm run repo-publish-quick",
32-
"repo-publish-quick": "npm run prettier && npm run build && npm run test && npm run test-web && npm run repo-tag && npm publish --registry http://registry.npmjs.org "
33+
"repo-publish-quick": "npm run prettier && npm run build && npm run test && npm run repo-tag && npm publish --registry http://registry.npmjs.org "
3334
},
3435
"license": "MIT",
3536
"files": [
@@ -39,17 +40,15 @@
3940
"LICENSE"
4041
],
4142
"devDependencies": {
42-
"@hapi/code": "^8.0.3",
43-
"@hapi/lab": "^24.3.2",
44-
"@types/jest": "^26.0.24",
43+
"@types/jest": "^27.0.1",
4544
"browserify": "^17.0.0",
4645
"hapi-lab-shim": "0.0.2",
47-
"jest": "^27.0.6",
46+
"jest": "^27.1.1",
4847
"lab-transform-typescript": "^3.0.1",
49-
"prettier": "^2.3.2",
48+
"prettier": "^2.4.0",
5049
"tinyify": "^3.0.0",
51-
"ts-jest": "^27.0.4",
52-
"typescript": "^4.3.5",
50+
"ts-jest": "^27.0.5",
51+
"typescript": "^4.4.2",
5352
"jsonc-parser": "^3.0.0",
5453
"jsonic": "github:jsonicjs/jsonic#nextgen"
5554
},

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"esModuleInterop": true,
55
"module": "commonjs",
66
"noEmitOnError": true,
7-
"noImplicitAny": true,
87
"resolveJsonModule": true,
98
"sourceMap": true,
109
"strict": true,

0 commit comments

Comments
 (0)