Skip to content

Commit daeb448

Browse files
committed
update
1 parent f27e887 commit daeb448

File tree

11 files changed

+83
-31
lines changed

11 files changed

+83
-31
lines changed

jest.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
21
module.exports = {
3-
preset: 'ts-jest',
2+
transform: {
3+
"^.+\\.tsx?$": "es-jest"
4+
},
45
testEnvironment: 'node',
5-
testMatch: ['**/test/**/*.test.ts']
6-
};
6+
testMatch: ['**/test/**/*.test.ts'],
7+
watchPathIgnorePatterns: ['.*.js$'],
8+
}

jsonc.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Jsonic } from 'jsonic';
2-
declare type JsoncOptions = {
1+
import { Jsonic } from '@jsonic/jsonic-next';
2+
type JsoncOptions = {
33
allowTrailingComma?: boolean;
44
disallowComments?: boolean;
55
};

jsonc.js

Lines changed: 12 additions & 1 deletion
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.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { Jsonic } from 'jsonic'
1+
/* Copyright (c) 2021-2023 Richard Rodger, MIT License */
2+
3+
// Import Jsonic types used by plugin.
4+
import {
5+
Jsonic,
6+
RuleSpec,
7+
} from '@jsonic/jsonic-next'
8+
29

310
type JsoncOptions = {
411
allowTrailingComma?: boolean
@@ -15,6 +22,7 @@ function Jsonc(jsonic: Jsonic, options: JsoncOptions) {
1522
oct: false,
1623
bin: false,
1724
sep: null,
25+
exclude: /^\./
1826
},
1927
string: {
2028
chars: '"',
@@ -35,9 +43,20 @@ function Jsonc(jsonic: Jsonic, options: JsoncOptions) {
3543
},
3644
rule: {
3745
finish: false,
38-
include: 'json' + (options.allowTrailingComma ? ',comma' : ''),
46+
include: 'jsonc,json' + (options.allowTrailingComma ? ',comma' : ''),
3947
},
4048
})
49+
50+
const { ZZ } = jsonic.token
51+
52+
jsonic.rule('val', (rs: RuleSpec) => {
53+
rs.open([
54+
{
55+
s: [ZZ],
56+
g: 'jsonc'
57+
}
58+
])
59+
})
4160
}
4261

4362
export { Jsonc }

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@jsonic/jsonc",
33
"version": "0.0.2",
4-
"description": "Jsonic plugin for the JSONC variant of JSON.",
4+
"description": "This plugin allows the [Jsonic](https://jsonic.senecajs.org) JSON parser to support JSONC syntax.",
55
"main": "jsonc.js",
66
"type": "commonjs",
77
"browser": "jsonc.min.js",
88
"types": "jsonc.d.ts",
9-
"homepage": "https://github.com/jsonicjs/variant-jsonc",
9+
"homepage": "https://github.com/jsonicjs/jsonc",
1010
"keywords": [
1111
"pattern",
1212
"matcher",
@@ -17,7 +17,7 @@
1717
"author": "Richard Rodger (http://richardrodger.com)",
1818
"repository": {
1919
"type": "git",
20-
"url": "git://github.com/jsonicjs/variant-jsonc.git"
20+
"url": "git://github.com/jsonicjs/jsonc.git"
2121
},
2222
"scripts": {
2323
"test": "jest --coverage",
@@ -27,7 +27,7 @@
2727
"build": "tsc -d && cp jsonc.js jsonc.min.js && browserify -o jsonc.min.js -e jsonc.js -s @JsonicJsonc -im -i assert -p tinyify",
2828
"prettier": "prettier --write --no-semi --single-quote *.ts test/*.js",
2929
"clean": "rm -rf node_modules yarn.lock package-lock.json",
30-
"reset": "npm run clean && npm i && npm test",
30+
"reset": "npm run clean && npm i && npm run build && npm test",
3131
"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;",
3232
"repo-publish": "npm run clean && npm i && npm run repo-publish-quick",
3333
"repo-publish-quick": "npm run prettier && npm run build && npm run test && npm run repo-tag && npm publish --access public --registry http://registry.npmjs.org "
@@ -40,17 +40,17 @@
4040
"LICENSE"
4141
],
4242
"devDependencies": {
43-
"@types/jest": "^27.0.1",
43+
"@types/jest": "^29.4.0",
4444
"browserify": "^17.0.0",
45-
"hapi-lab-shim": "0.0.2",
46-
"jest": "^27.1.1",
47-
"lab-transform-typescript": "^3.0.1",
48-
"prettier": "^2.4.0",
49-
"tinyify": "^3.0.0",
50-
"ts-jest": "^27.0.5",
51-
"typescript": "^4.4.2",
52-
"jsonc-parser": "^3.0.0",
53-
"jsonic": "github:jsonicjs/jsonic#nextgen"
45+
"jest": "^29.4.1",
46+
"prettier": "^2.8.3",
47+
"tinyify": "^4.0.0",
48+
"typescript": "^4.9.5",
49+
"es-jest": "^2.1.0",
50+
"esbuild": "^0.17.5"
5451
},
55-
"dependencies": {}
52+
"dependencies": {},
53+
"peerDependencies": {
54+
"@jsonic/jsonic-next": ">=2.7.0"
55+
}
5656
}

test/jsonc.test.js

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

0 commit comments

Comments
 (0)