@isdk/json-repair 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.cn.md +126 -7
- package/README.md +148 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +571 -4
- package/dist/index.d.ts +571 -4
- package/dist/index.js +1 -1
- package/docs/README.md +148 -7
- package/docs/_media/README.cn.md +126 -7
- package/docs/classes/RepairParser.md +69 -3
- package/docs/classes/SchemaWalker.md +9 -9
- package/docs/functions/compareScores.md +32 -0
- package/docs/functions/discardedText.md +42 -0
- package/docs/functions/expectsArrayRoot.md +23 -0
- package/docs/functions/findImplicitRecordRegion.md +32 -0
- package/docs/functions/jsonRepair.md +4 -3
- package/docs/functions/jsonRepairResult.md +50 -0
- package/docs/functions/locateJsonCandidates.md +33 -0
- package/docs/functions/looksLikeSchemaEcho.md +29 -0
- package/docs/functions/renderValidatorErrors.md +32 -0
- package/docs/functions/scoreCandidate.md +45 -0
- package/docs/functions/validateValue.md +38 -0
- package/docs/globals.md +19 -0
- package/docs/interfaces/CandidateScore.md +63 -0
- package/docs/interfaces/JsonCandidate.md +71 -0
- package/docs/interfaces/LocatedJson.md +48 -0
- package/docs/interfaces/RepairOptions.md +210 -5
- package/docs/interfaces/RepairResult.md +58 -0
- package/docs/interfaces/ValidationError.md +27 -0
- package/docs/type-aliases/CommentStyle.md +13 -0
- package/docs/type-aliases/EscapeMode.md +13 -0
- package/docs/type-aliases/JSONPath.md +1 -1
- package/docs/type-aliases/LiteralDialect.md +13 -0
- package/docs/type-aliases/RepairFlag.md +11 -0
- package/package.json +26 -4
- package/.prettierignore +0 -12
- package/.prettierrc +0 -8
- package/.versionrc +0 -36
- package/CHANGELOG.md +0 -34
- package/TODO +0 -0
- package/eslint.config.mjs +0 -65
- package/setupVitest.mjs +0 -15
- package/tsconfig.json +0 -20
- package/tsconfig.release.json +0 -21
- package/tsup.config.ts +0 -38
- package/typedoc.config.cjs +0 -9
- package/vite.config.mjs +0 -21
package/eslint.config.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import antfu from '@antfu/eslint-config'
|
|
2
|
-
import tsdoc from 'eslint-plugin-tsdoc'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* ESLint 只负责「正确性」,代码风格交给 prettier(见 package.json 的 format 脚本与 .prettierrc)。
|
|
6
|
-
*
|
|
7
|
-
* 这里沿用 ../ai-tool 的做法:用 @antfu 的配置作为底座,但整体关闭风格类与教条类插件层,
|
|
8
|
-
* 只保留指向真实 bug 的核心规则。想重新启用某一层,把对应的 `false` 改成 `true` 即可。
|
|
9
|
-
*/
|
|
10
|
-
const config = await antfu(
|
|
11
|
-
{
|
|
12
|
-
gitignore: true,
|
|
13
|
-
ignores: ['web/**', 'docs/**', 'dist/**', '.cache/**'],
|
|
14
|
-
|
|
15
|
-
// 风格类规则全部交给 prettier
|
|
16
|
-
stylistic: false,
|
|
17
|
-
// 以下插件层噪音太大,先整体关闭
|
|
18
|
-
regexp: false,
|
|
19
|
-
unicorn: false,
|
|
20
|
-
test: false,
|
|
21
|
-
imports: false,
|
|
22
|
-
jsonc: false,
|
|
23
|
-
yaml: false,
|
|
24
|
-
toml: false,
|
|
25
|
-
markdown: false,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
plugins: { tsdoc },
|
|
29
|
-
rules: {
|
|
30
|
-
'tsdoc/syntax': 'off',
|
|
31
|
-
'antfu/no-top-level-await': 'off', // 测试文件里 top-level await 是正常写法
|
|
32
|
-
|
|
33
|
-
// 偏好类:不产生真实 bug,也不制造 diff
|
|
34
|
-
'prefer-const': 'off',
|
|
35
|
-
'prefer-template': 'off',
|
|
36
|
-
'object-shorthand': 'off',
|
|
37
|
-
'no-cond-assign': 'off', // 沿用旧配置:`while ((m = re.exec(s)))` 是惯用写法
|
|
38
|
-
'no-lone-blocks': 'off', // `case 'x': { … }; break;` 的花括号是刻意的
|
|
39
|
-
'unused-imports/no-unused-vars': 'off', // 未使用的函数参数多是签名占位
|
|
40
|
-
|
|
41
|
-
// TS 风格类
|
|
42
|
-
'ts/consistent-type-imports': 'off',
|
|
43
|
-
'ts/consistent-type-definitions': 'off',
|
|
44
|
-
'ts/no-use-before-define': 'off',
|
|
45
|
-
'ts/ban-ts-comment': 'off',
|
|
46
|
-
'ts/no-unused-expressions': 'off',
|
|
47
|
-
'ts/no-explicit-any': 'off', // 动态入参/出参本来就无静态类型(见 README 的 any 说明)
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
// ESLint 9 的 rules 通配符(如 `perfectionist/*`)只在 global config 生效,这里手动关掉整组噪音规则
|
|
53
|
-
const NOISE_GROUPS = ['perfectionist/', 'jsdoc/', 'node/', 'import/']
|
|
54
|
-
for (const item of config) {
|
|
55
|
-
if (!item.rules) {
|
|
56
|
-
continue
|
|
57
|
-
}
|
|
58
|
-
for (const name of Object.keys(item.rules)) {
|
|
59
|
-
if (NOISE_GROUPS.some((group) => name.startsWith(group))) {
|
|
60
|
-
item.rules[name] = 'off'
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default config
|
package/setupVitest.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// 这个 fetchMock 没有传递abort 中的 reason!
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
import createFetchMock from 'vitest-fetch-mock';
|
|
5
|
-
import { vi } from 'vitest';
|
|
6
|
-
// import './fetch-polyfill.mjs';
|
|
7
|
-
|
|
8
|
-
const fetchMocker = createFetchMock(vi);
|
|
9
|
-
|
|
10
|
-
// sets globalThis.fetch and globalThis.fetchMock to our mocked version
|
|
11
|
-
fetchMocker.enableMocks();
|
|
12
|
-
|
|
13
|
-
// changes default behavior of fetchMock to use the real 'fetch' implementation and not mock responses
|
|
14
|
-
fetchMocker.dontMock();
|
|
15
|
-
*/
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
|
|
12
|
-
// 这份 tsconfig 只给编辑器 / 类型检查用(构建走 tsup + tsconfig.release.json),
|
|
13
|
-
// 所以这里 noEmit,并且不要把 outDir 之类的产物配置放进来。
|
|
14
|
-
"noEmit": true
|
|
15
|
-
},
|
|
16
|
-
// 开发/编辑器视角:测试文件也要在 program 里,否则 VS Code 会把它们
|
|
17
|
-
// 当成 invisible file 放进 inferred project,这份配置对它们无效。
|
|
18
|
-
"include": ["src/**/*", "test/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist", "web", "docs"]
|
|
20
|
-
}
|
package/tsconfig.release.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// 发包专用:tsup --dts / typedoc 用这份配置,排除测试文件。
|
|
3
|
-
// 编辑器与类型检查请用根目录的 tsconfig.json。
|
|
4
|
-
"extends": "./tsconfig.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
// tsup --dts / typedoc 需要真正产出 .d.ts
|
|
7
|
-
"noEmit": false,
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"outDir": "./dist"
|
|
10
|
-
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"dist",
|
|
14
|
-
"web",
|
|
15
|
-
"docs",
|
|
16
|
-
"**/*.test.ts",
|
|
17
|
-
"**/*.spec.ts",
|
|
18
|
-
"**/*.test.js",
|
|
19
|
-
"**/*.spec.js"
|
|
20
|
-
]
|
|
21
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
// 发包用 release 配置(排除测试文件);
|
|
5
|
-
// 根目录 tsconfig.json 是编辑器/类型检查用的(含测试文件)。
|
|
6
|
-
tsconfig: 'tsconfig.release.json',
|
|
7
|
-
entry: ['src/index.ts'],
|
|
8
|
-
format: ['cjs', 'esm'],
|
|
9
|
-
// Inject cjs and esm shims:https://tsup.egoist.dev/#inject-cjs-and-esm-shims
|
|
10
|
-
shims: true,
|
|
11
|
-
// splitting: true,
|
|
12
|
-
// sourcemap: true,
|
|
13
|
-
// clean: true,
|
|
14
|
-
minify: 'terser',
|
|
15
|
-
terserOptions: {
|
|
16
|
-
// compress: {
|
|
17
|
-
// drop_console: true,
|
|
18
|
-
// drop_debugger: true,
|
|
19
|
-
// },
|
|
20
|
-
// https://terser.org/docs/options/#mangle-options
|
|
21
|
-
mangle: {
|
|
22
|
-
properties: {
|
|
23
|
-
regex: /^_[$]/,
|
|
24
|
-
// "undeclared": true, // Mangle those names when they are accessed as properties of known top level variables but their declarations are never found in input code.
|
|
25
|
-
},
|
|
26
|
-
toplevel: true,
|
|
27
|
-
reserved: [
|
|
28
|
-
// # expected names in web-extension content
|
|
29
|
-
'WeakSet',
|
|
30
|
-
'Set',
|
|
31
|
-
// # expected names in 3rd-party extensions' contents
|
|
32
|
-
'requestIdleCallback',
|
|
33
|
-
// # content global names:
|
|
34
|
-
'browser',
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
})
|
package/typedoc.config.cjs
DELETED
package/vite.config.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
plugins: [
|
|
6
|
-
tsconfigPaths({
|
|
7
|
-
projects: ['./tsconfig.json'],
|
|
8
|
-
}),
|
|
9
|
-
],
|
|
10
|
-
test: {
|
|
11
|
-
include: [
|
|
12
|
-
'src/**/*.spec.ts',
|
|
13
|
-
'src/**/*.test.ts',
|
|
14
|
-
'test/*.spec.ts',
|
|
15
|
-
'test/*.test.ts',
|
|
16
|
-
],
|
|
17
|
-
testTimeout: 80000,
|
|
18
|
-
globals: true,
|
|
19
|
-
setupFiles: ['./setupVitest.mjs'],
|
|
20
|
-
},
|
|
21
|
-
})
|