@termdock/twlint 1.0.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/LICENSE +201 -0
- package/README.md +185 -0
- package/TRADEMARK.md +39 -0
- package/bin/twlint +6 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +142 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/config-loader.d.ts +3 -0
- package/dist/core/config-loader.d.ts.map +1 -0
- package/dist/core/config-loader.js +54 -0
- package/dist/core/config-loader.js.map +1 -0
- package/dist/core/config-schema.d.ts +12 -0
- package/dist/core/config-schema.d.ts.map +1 -0
- package/dist/core/config-schema.js +64 -0
- package/dist/core/config-schema.js.map +1 -0
- package/dist/core/dictionary-manager.d.ts +14 -0
- package/dist/core/dictionary-manager.d.ts.map +1 -0
- package/dist/core/dictionary-manager.js +94 -0
- package/dist/core/dictionary-manager.js.map +1 -0
- package/dist/core/linter.d.ts +31 -0
- package/dist/core/linter.d.ts.map +1 -0
- package/dist/core/linter.js +182 -0
- package/dist/core/linter.js.map +1 -0
- package/dist/core/matching/match-strategies.d.ts +26 -0
- package/dist/core/matching/match-strategies.d.ts.map +1 -0
- package/dist/core/matching/match-strategies.js +170 -0
- package/dist/core/matching/match-strategies.js.map +1 -0
- package/dist/core/position-mapper.d.ts +31 -0
- package/dist/core/position-mapper.d.ts.map +1 -0
- package/dist/core/position-mapper.js +101 -0
- package/dist/core/position-mapper.js.map +1 -0
- package/dist/core/rules/context-sensitive.d.ts +17 -0
- package/dist/core/rules/context-sensitive.d.ts.map +1 -0
- package/dist/core/rules/context-sensitive.js +154 -0
- package/dist/core/rules/context-sensitive.js.map +1 -0
- package/dist/core/rules/mainland-terms.d.ts +11 -0
- package/dist/core/rules/mainland-terms.d.ts.map +1 -0
- package/dist/core/rules/mainland-terms.js +45 -0
- package/dist/core/rules/mainland-terms.js.map +1 -0
- package/dist/core/rules/simplified-chars.d.ts +10 -0
- package/dist/core/rules/simplified-chars.d.ts.map +1 -0
- package/dist/core/rules/simplified-chars.js +51 -0
- package/dist/core/rules/simplified-chars.js.map +1 -0
- package/dist/dictionaries/academic.json +141 -0
- package/dist/dictionaries/core.json +1491 -0
- package/dist/dictionaries/extended.json +141 -0
- package/dist/dictionaries/index.json +21 -0
- package/dist/formatters/json.d.ts +5 -0
- package/dist/formatters/json.d.ts.map +1 -0
- package/dist/formatters/json.js +18 -0
- package/dist/formatters/json.js.map +1 -0
- package/dist/formatters/stylish.d.ts +5 -0
- package/dist/formatters/stylish.d.ts.map +1 -0
- package/dist/formatters/stylish.js +45 -0
- package/dist/formatters/stylish.js.map +1 -0
- package/dist/types.d.ts +73 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metadata": {
|
|
3
|
+
"name": "extended",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"entries": 12
|
|
6
|
+
},
|
|
7
|
+
"lookup": {
|
|
8
|
+
"算法": {
|
|
9
|
+
"taiwan": "演算法",
|
|
10
|
+
"confidence": 0.9,
|
|
11
|
+
"category": "mainland-term",
|
|
12
|
+
"reason": "台灣學術標準用語"
|
|
13
|
+
},
|
|
14
|
+
"数据结构": {
|
|
15
|
+
"taiwan": "資料結構",
|
|
16
|
+
"confidence": 0.95,
|
|
17
|
+
"category": "mainland-term",
|
|
18
|
+
"reason": "台灣計算機科學標準"
|
|
19
|
+
},
|
|
20
|
+
"數據結構": {
|
|
21
|
+
"taiwan": "資料結構",
|
|
22
|
+
"confidence": 0.95,
|
|
23
|
+
"category": "mainland-term",
|
|
24
|
+
"reason": "台灣計算機科學標準"
|
|
25
|
+
},
|
|
26
|
+
"计算机科学": {
|
|
27
|
+
"taiwan": "計算機科學",
|
|
28
|
+
"confidence": 0.85,
|
|
29
|
+
"category": "mainland-term",
|
|
30
|
+
"reason": "台灣學術慣用語"
|
|
31
|
+
},
|
|
32
|
+
"計算機科學": {
|
|
33
|
+
"taiwan": "計算機科學",
|
|
34
|
+
"confidence": 0.85,
|
|
35
|
+
"category": "mainland-term",
|
|
36
|
+
"reason": "台灣學術慣用語"
|
|
37
|
+
},
|
|
38
|
+
"人工智能": {
|
|
39
|
+
"taiwan": "人工智慧",
|
|
40
|
+
"confidence": 0.9,
|
|
41
|
+
"category": "mainland-term",
|
|
42
|
+
"reason": "台灣AI領域標準"
|
|
43
|
+
},
|
|
44
|
+
"机器学习": {
|
|
45
|
+
"taiwan": "機器學習",
|
|
46
|
+
"confidence": 0.8,
|
|
47
|
+
"category": "mainland-term",
|
|
48
|
+
"reason": "台灣ML領域用語"
|
|
49
|
+
},
|
|
50
|
+
"機器學習": {
|
|
51
|
+
"taiwan": "機器學習",
|
|
52
|
+
"confidence": 0.8,
|
|
53
|
+
"category": "mainland-term",
|
|
54
|
+
"reason": "台灣ML領域用語"
|
|
55
|
+
},
|
|
56
|
+
"数据库系统": {
|
|
57
|
+
"taiwan": "資料庫系統",
|
|
58
|
+
"confidence": 0.95,
|
|
59
|
+
"category": "mainland-term",
|
|
60
|
+
"reason": "台灣資訊科學標準"
|
|
61
|
+
},
|
|
62
|
+
"數據庫系統": {
|
|
63
|
+
"taiwan": "資料庫系統",
|
|
64
|
+
"confidence": 0.95,
|
|
65
|
+
"category": "mainland-term",
|
|
66
|
+
"reason": "台灣資訊科學標準"
|
|
67
|
+
},
|
|
68
|
+
"操作系统": {
|
|
69
|
+
"taiwan": "作業系統",
|
|
70
|
+
"confidence": 0.9,
|
|
71
|
+
"category": "mainland-term",
|
|
72
|
+
"reason": "台灣系統軟體標準"
|
|
73
|
+
},
|
|
74
|
+
"操作系統": {
|
|
75
|
+
"taiwan": "作業系統",
|
|
76
|
+
"confidence": 0.9,
|
|
77
|
+
"category": "mainland-term",
|
|
78
|
+
"reason": "台灣系統軟體標準"
|
|
79
|
+
},
|
|
80
|
+
"用户界面": {
|
|
81
|
+
"taiwan": "使用者介面",
|
|
82
|
+
"confidence": 0.85,
|
|
83
|
+
"category": "mainland-term",
|
|
84
|
+
"reason": "台灣HCI標準用語"
|
|
85
|
+
},
|
|
86
|
+
"用戶界面": {
|
|
87
|
+
"taiwan": "使用者介面",
|
|
88
|
+
"confidence": 0.85,
|
|
89
|
+
"category": "mainland-term",
|
|
90
|
+
"reason": "台灣HCI標準用語"
|
|
91
|
+
},
|
|
92
|
+
"面向对象": {
|
|
93
|
+
"taiwan": "物件導向",
|
|
94
|
+
"confidence": 0.8,
|
|
95
|
+
"category": "mainland-term",
|
|
96
|
+
"reason": "台灣程式設計標準"
|
|
97
|
+
},
|
|
98
|
+
"面向對象": {
|
|
99
|
+
"taiwan": "物件導向",
|
|
100
|
+
"confidence": 0.8,
|
|
101
|
+
"category": "mainland-term",
|
|
102
|
+
"reason": "台灣程式設計標準"
|
|
103
|
+
},
|
|
104
|
+
"函数式编程": {
|
|
105
|
+
"taiwan": "函數式程式設計",
|
|
106
|
+
"confidence": 0.75,
|
|
107
|
+
"category": "mainland-term",
|
|
108
|
+
"reason": "台灣程式語言理論"
|
|
109
|
+
},
|
|
110
|
+
"函數式編程": {
|
|
111
|
+
"taiwan": "函數式程式設計",
|
|
112
|
+
"confidence": 0.75,
|
|
113
|
+
"category": "mainland-term",
|
|
114
|
+
"reason": "台灣程式語言理論"
|
|
115
|
+
},
|
|
116
|
+
"计算机视觉": {
|
|
117
|
+
"taiwan": "電腦視覺",
|
|
118
|
+
"confidence": 0.85,
|
|
119
|
+
"category": "mainland-term",
|
|
120
|
+
"reason": "台灣影像處理標準"
|
|
121
|
+
},
|
|
122
|
+
"計算機視覺": {
|
|
123
|
+
"taiwan": "電腦視覺",
|
|
124
|
+
"confidence": 0.85,
|
|
125
|
+
"category": "mainland-term",
|
|
126
|
+
"reason": "台灣影像處理標準"
|
|
127
|
+
},
|
|
128
|
+
"自然语言处理": {
|
|
129
|
+
"taiwan": "自然語言處理",
|
|
130
|
+
"confidence": 0.9,
|
|
131
|
+
"category": "mainland-term",
|
|
132
|
+
"reason": "台灣NLP標準用語"
|
|
133
|
+
},
|
|
134
|
+
"自然語言處理": {
|
|
135
|
+
"taiwan": "自然語言處理",
|
|
136
|
+
"confidence": 0.9,
|
|
137
|
+
"category": "mainland-term",
|
|
138
|
+
"reason": "台灣NLP標準用語"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dictionaries": [
|
|
3
|
+
{
|
|
4
|
+
"name": "core",
|
|
5
|
+
"description": "核心詞庫",
|
|
6
|
+
"required": true
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"name": "academic",
|
|
10
|
+
"description": "學術詞庫",
|
|
11
|
+
"required": false
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "extended",
|
|
15
|
+
"description": "擴展詞庫",
|
|
16
|
+
"required": false
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"version": "1.0.0",
|
|
20
|
+
"buildTime": "2025-09-20T09:13:04.221Z"
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/formatters/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAExD,qBAAa,aAAc,YAAW,SAAS;IAC7C,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM;CAgBtC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class JsonFormatter {
|
|
2
|
+
format(results) {
|
|
3
|
+
const output = results.map(result => ({
|
|
4
|
+
filePath: result.filePath,
|
|
5
|
+
messages: result.messages.map(message => ({
|
|
6
|
+
line: message.line,
|
|
7
|
+
column: message.column,
|
|
8
|
+
message: message.message,
|
|
9
|
+
severity: message.severity,
|
|
10
|
+
rule: message.rule,
|
|
11
|
+
suggestions: message.suggestions || [],
|
|
12
|
+
fixable: message.fixable
|
|
13
|
+
}))
|
|
14
|
+
}));
|
|
15
|
+
return JSON.stringify(output, null, 2);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/formatters/json.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACxB,MAAM,CAAC,OAAqB;QAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACpC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBACxC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;gBACtC,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;SACJ,CAAC,CAAC,CAAA;QAEH,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylish.d.ts","sourceRoot":"","sources":["../../src/formatters/stylish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAExD,qBAAa,gBAAiB,YAAW,SAAS;IAChD,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM;CA8CtC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export class StylishFormatter {
|
|
3
|
+
format(results) {
|
|
4
|
+
let output = '';
|
|
5
|
+
let totalErrors = 0;
|
|
6
|
+
let totalWarnings = 0;
|
|
7
|
+
for (const result of results) {
|
|
8
|
+
if (result.messages.length === 0)
|
|
9
|
+
continue;
|
|
10
|
+
output += `\n${chalk.underline(result.filePath)}\n`;
|
|
11
|
+
for (const message of result.messages) {
|
|
12
|
+
const { line, column, severity, message: msg, rule } = message;
|
|
13
|
+
const icon = severity === 'error' ? chalk.red('✖') : chalk.yellow('⚠');
|
|
14
|
+
const severityText = severity === 'error' ? chalk.red('error') : chalk.yellow('warning');
|
|
15
|
+
output += ` ${String(line).padStart(3)}:${String(column).padEnd(3)} ${icon} ${severityText} ${msg} ${chalk.dim(rule)}\n`;
|
|
16
|
+
if (severity === 'error')
|
|
17
|
+
totalErrors++;
|
|
18
|
+
if (severity === 'warning')
|
|
19
|
+
totalWarnings++;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (totalErrors > 0 || totalWarnings > 0) {
|
|
23
|
+
output += `\n${chalk.red('✖')} ${totalErrors + totalWarnings} problems (${totalErrors} errors, ${totalWarnings} warnings)`;
|
|
24
|
+
const fixableErrors = results.reduce((sum, result) => sum + result.messages.filter(msg => msg.fixable && msg.severity === 'error').length, 0);
|
|
25
|
+
const fixableWarnings = results.reduce((sum, result) => sum + result.messages.filter(msg => msg.fixable && msg.severity === 'warning').length, 0);
|
|
26
|
+
if (fixableErrors > 0 || fixableWarnings > 0) {
|
|
27
|
+
output += `\n ${fixableErrors + fixableWarnings} problems potentially fixable with the \`--fix\` option`;
|
|
28
|
+
if (fixableErrors > 0 && fixableWarnings > 0) {
|
|
29
|
+
output += ` (${fixableErrors} errors, ${fixableWarnings} warnings).`;
|
|
30
|
+
}
|
|
31
|
+
else if (fixableErrors > 0) {
|
|
32
|
+
output += ` (${fixableErrors} errors).`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
output += ` (${fixableWarnings} warnings).`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
output += `\n${chalk.green('✓')} No problems found!`;
|
|
41
|
+
}
|
|
42
|
+
return output;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=stylish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylish.js","sourceRoot":"","sources":["../../src/formatters/stylish.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,OAAqB;QAC1B,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,IAAI,WAAW,GAAG,CAAC,CAAA;QACnB,IAAI,aAAa,GAAG,CAAC,CAAA;QAErB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAQ;YAE1C,MAAM,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA;YAEnD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACtC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;gBAC9D,MAAM,IAAI,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBACtE,MAAM,YAAY,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,C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yD,CAAA;gBACzG,IAAI,aAAa,GAAG,CAAC,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;oBAC7C,MAAM,IAAI,KAAK,aAAa,YAAY,eAAe,aAAa,CAAA;gBACtE,CAAC;qBAAM,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;oBAC7B,MAAM,IAAI,KAAK,aAAa,WAAW,CAAA;gBACzC,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,eAAe,aAAa,CAAA;gBAC7C,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAA;QACtD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface Issue {
|
|
2
|
+
line: number;
|
|
3
|
+
column: number;
|
|
4
|
+
message: string;
|
|
5
|
+
severity: 'error' | 'warning' | 'info';
|
|
6
|
+
rule: string;
|
|
7
|
+
suggestions?: string[];
|
|
8
|
+
fixable: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface LintResult {
|
|
11
|
+
filePath: string;
|
|
12
|
+
messages: Issue[];
|
|
13
|
+
}
|
|
14
|
+
export interface TWLintConfig {
|
|
15
|
+
files?: string[];
|
|
16
|
+
dictionaries?: string[];
|
|
17
|
+
rules?: Record<string, 'error' | 'warning' | 'info' | 'off'>;
|
|
18
|
+
}
|
|
19
|
+
export type MatchType = 'exact' | 'word_boundary' | 'context_sensitive';
|
|
20
|
+
export interface ContextRule {
|
|
21
|
+
before?: string[];
|
|
22
|
+
after?: string[];
|
|
23
|
+
exclude?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface DictEntry {
|
|
26
|
+
id: string;
|
|
27
|
+
taiwan: string;
|
|
28
|
+
china_simplified: string;
|
|
29
|
+
china_traditional: string;
|
|
30
|
+
english?: string;
|
|
31
|
+
confidence: number;
|
|
32
|
+
category: string;
|
|
33
|
+
reason: string;
|
|
34
|
+
domain: string;
|
|
35
|
+
match_type: MatchType;
|
|
36
|
+
context?: ContextRule;
|
|
37
|
+
}
|
|
38
|
+
export interface MatchResult {
|
|
39
|
+
term: string;
|
|
40
|
+
replacement: string;
|
|
41
|
+
start: number;
|
|
42
|
+
end: number;
|
|
43
|
+
confidence: number;
|
|
44
|
+
rule: string;
|
|
45
|
+
}
|
|
46
|
+
export interface CompiledDict {
|
|
47
|
+
metadata: {
|
|
48
|
+
name: string;
|
|
49
|
+
version: string;
|
|
50
|
+
entries: number;
|
|
51
|
+
};
|
|
52
|
+
lookup: Record<string, {
|
|
53
|
+
taiwan: string;
|
|
54
|
+
confidence: number;
|
|
55
|
+
category: string;
|
|
56
|
+
reason: string;
|
|
57
|
+
match_type: MatchType;
|
|
58
|
+
context?: ContextRule;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
export interface MatchStrategy {
|
|
62
|
+
name: MatchType;
|
|
63
|
+
match(text: string, term: string, context?: ContextRule): MatchResult[];
|
|
64
|
+
}
|
|
65
|
+
export interface Rule {
|
|
66
|
+
name: string;
|
|
67
|
+
check(text: string): Promise<Issue[]>;
|
|
68
|
+
fix?(text: string): Promise<string>;
|
|
69
|
+
}
|
|
70
|
+
export interface Formatter {
|
|
71
|
+
format(results: LintResult[]): string;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,EAAE,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AA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QACrB,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,SAAS,CAAA;QACrB,OAAO,CAAC,EAAE,WAAW,CAAA;KACtB,CAAC,CAAA;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;CACxE;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;IACrC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;CACtC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@termdock/twlint",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A CLI tool for detecting simplified Chinese terms and suggesting Taiwan traditional alternatives",
|
|
5
|
+
"main": "dist/cli.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"twlint": "./bin/twlint"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "npm run dict:build && tsx watch src/cli.ts",
|
|
12
|
+
"build": "npm run dict:build && tsc && cp -r src/dictionaries dist/",
|
|
13
|
+
"test": "vitest",
|
|
14
|
+
"dict:build": "tsx tools/build-dict.ts",
|
|
15
|
+
"dict:validate": "tsx tools/validate-dict.ts",
|
|
16
|
+
"dict:convert": "tsx tools/dict-manager.ts convert",
|
|
17
|
+
"dict:template": "tsx tools/dict-manager.ts template",
|
|
18
|
+
"dict:check": "tsx tools/dict-manager.ts validate",
|
|
19
|
+
"dict:list": "tsx tools/dict-manager.ts list",
|
|
20
|
+
"dict:merge": "tsx tools/dict-manager.ts merge",
|
|
21
|
+
"lint": "eslint src/ --fix",
|
|
22
|
+
"format": "prettier --write src/",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/",
|
|
27
|
+
"bin/",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"README.md",
|
|
30
|
+
"TRADEMARK.md"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"chalk": "^5.3.0",
|
|
34
|
+
"commander": "^11.0.0",
|
|
35
|
+
"glob": "^10.3.0",
|
|
36
|
+
"minimatch": "^9.0.3",
|
|
37
|
+
"opencc-js": "^1.0.5",
|
|
38
|
+
"papaparse": "^5.4.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^20.0.0",
|
|
42
|
+
"@types/papaparse": "^5.3.7",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
44
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
45
|
+
"eslint": "^8.0.0",
|
|
46
|
+
"prettier": "^3.0.0",
|
|
47
|
+
"tsx": "^3.12.0",
|
|
48
|
+
"typescript": "^5.0.0",
|
|
49
|
+
"vitest": "^0.34.0"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"chinese",
|
|
53
|
+
"traditional",
|
|
54
|
+
"simplified",
|
|
55
|
+
"taiwan",
|
|
56
|
+
"lint",
|
|
57
|
+
"cli",
|
|
58
|
+
"linter",
|
|
59
|
+
"mainland-terms",
|
|
60
|
+
"繁體中文",
|
|
61
|
+
"簡體中文",
|
|
62
|
+
"用語檢測"
|
|
63
|
+
],
|
|
64
|
+
"author": "Huang Chung YI",
|
|
65
|
+
"license": "Apache-2.0",
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "git+https://github.com/HCYT/twlint.git"
|
|
69
|
+
},
|
|
70
|
+
"homepage": "https://github.com/HCYT/twlint#readme",
|
|
71
|
+
"bugs": {
|
|
72
|
+
"url": "https://github.com/HCYT/twlint/issues"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=18.0.0"
|
|
76
|
+
}
|
|
77
|
+
}
|