@kcconfigs/textlint 0.1.0-beta.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/dist/config-CjR_suQD.d.cts +34 -0
- package/dist/config-CjR_suQD.d.cts.map +1 -0
- package/dist/config-KDNTBTCT.d.ts +34 -0
- package/dist/config-KDNTBTCT.d.ts.map +1 -0
- package/dist/defineConfig-BSVyAEFt.cjs +126 -0
- package/dist/defineConfig-BSVyAEFt.cjs.map +1 -0
- package/dist/defineConfig-Rcs53KN7.js +100 -0
- package/dist/defineConfig-Rcs53KN7.js.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +31 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/presets/default.cjs +10 -0
- package/dist/presets/default.cjs.map +1 -0
- package/dist/presets/default.d.cts +8 -0
- package/dist/presets/default.d.cts.map +1 -0
- package/dist/presets/default.d.ts +9 -0
- package/dist/presets/default.d.ts.map +1 -0
- package/dist/presets/default.js +16 -0
- package/dist/presets/default.js.map +1 -0
- package/package.json +93 -0
- package/src/global.d.ts +1 -0
- package/src/index.test.ts +35 -0
- package/src/index.ts +6 -0
- package/src/models/config.ts +35 -0
- package/src/models/rule.ts +39 -0
- package/src/presets/default.ts +11 -0
- package/src/rules/allowlist.ts +27 -0
- package/src/rules/comment.ts +11 -0
- package/src/rules/index.ts +3 -0
- package/src/rules/terminology.ts +23 -0
- package/src/utils/defineConfig.ts +41 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
//#region src/models/rule.d.ts
|
|
3
|
+
type WithEnabled<T> = boolean | T;
|
|
4
|
+
type RuleType = "filter" | "rule";
|
|
5
|
+
type RuleConfig = Record<string, any>;
|
|
6
|
+
type RuleModule = any;
|
|
7
|
+
interface Rule<T extends RuleType, N extends string, C extends RuleConfig> {
|
|
8
|
+
type: T;
|
|
9
|
+
name: N;
|
|
10
|
+
config: WithEnabled<C>;
|
|
11
|
+
}
|
|
12
|
+
interface RuleRule<N extends string, C extends RuleConfig> extends Rule<"rule", N, C> {
|
|
13
|
+
module: RuleModule;
|
|
14
|
+
}
|
|
15
|
+
interface FilterRule<N extends string, C extends RuleConfig> extends Rule<"filter", N, C> {}
|
|
16
|
+
type AnyRule = Rule<RuleType, string, RuleConfig>;
|
|
17
|
+
type AnyRules = Record<string, AnyRule>;
|
|
18
|
+
type AnyRuleRules = Record<string, RuleRule<string, RuleConfig>>;
|
|
19
|
+
type AnyRuleFilters = Record<string, FilterRule<string, RuleConfig>>;
|
|
20
|
+
type ToRuleMap<RS extends AnyRule[], T extends RuleType> = { [K in RS[number] as K extends Rule<T, infer N, RuleConfig> ? N : never]: T extends "filter" ? FilterRule<K["name"], Exclude<K["config"], boolean>> : T extends "rule" ? RuleRule<K["name"], Exclude<K["config"], boolean>> : never };
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/models/config.d.ts
|
|
23
|
+
type UserConfigFilter<R extends AnyRuleFilters> = { [K in keyof R]: R[K]["config"] };
|
|
24
|
+
type UserConfigRule<R extends AnyRuleRules> = { [K in keyof R]: R[K]["module"] };
|
|
25
|
+
type UserConfigRuleConfig<R extends AnyRuleRules> = { [K in keyof R]: R[K]["config"] };
|
|
26
|
+
interface UserConfig<RS extends AnyRule[] = AnyRule[]> {
|
|
27
|
+
filters: UserConfigFilter<ToRuleMap<RS, "filter">>;
|
|
28
|
+
rules: UserConfigRule<ToRuleMap<RS, "rule">>;
|
|
29
|
+
rulesConfig: UserConfigRuleConfig<ToRuleMap<RS, "rule">>;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { AnyRules as a, RuleModule as c, ToRuleMap as d, WithEnabled as f, AnyRuleRules as i, RuleRule as l, AnyRule as n, FilterRule as o, AnyRuleFilters as r, RuleConfig as s, UserConfig as t, RuleType as u };
|
|
33
|
+
// Generated by @kcconfigs/tsdown
|
|
34
|
+
//# sourceMappingURL=config-CjR_suQD.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CjR_suQD.d.cts","names":[],"sources":["../src/models/rule.ts","../src/models/config.ts"],"sourcesContent":[],"mappings":";;KAAY,2BAA2B;AAA3B,KAEA,QAAA,GAFA,QAA2B,GAAA,MAAA;AAE3B,KAGA,UAAA,GAAa,MAHb,CAAA,MAAA,EAAA,GAAA,CAAA;AAGA,KAGA,UAAA,GAHA,GAAa;AAGzB,UAEU,IAFE,CAAA,UAEa,QAAf,EAAe,UAAA,MAAA,EAAsC,UAAA,UAAA,CACxD,CAAA;EACA,IAAA,EADA,CACA;EACc,IAAA,EADd,CACc;EAAZ,MAAA,EAAA,WAAA,CAAY,CAAZ,CAAA;;AAGQ,UAAA,QAAA,CAAqC,UAAA,MAAA,EAChC,UADgC,UAChC,CAAG,SAAhB,IAAgB,CAAA,MAAA,EAAH,CAAG,EAAA,CAAA,CAAA,CAAA;EAChB,MAAA,EAAA,UAAA;;AADA,UAIQ,UAJR,CAIT,UAAiB,MAAA,EAAuC,UAAA,UAAA,CAChC,SAAf,IAAe,CAAA,QAAA,EAAA,CAAA,EAAG,CAAH,CAAA,CAAA,CAAA;AAAG,KAEf,OAAA,GAAU,IAFK,CAEA,QAFA,EAAA,MAAA,EAEkB,UAFlB,CAAA;AAAlB,KAIG,QAAA,GAAW,MAJd,CAAA,MAAA,EAI6B,OAJ7B,CAAA;AAAA,KAKG,YAAA,GAAe,MALlB,CAAA,MAAA,EAKiC,QALjC,CAAA,MAAA,EAKkD,UALlD,CAAA,CAAA;AAEG,KAIA,cAAA,GAAiB,MAJjB,CAAA,MAAA,EAIgC,UAJhC,CAAA,MAAA,EAImD,UAJnD,CAAA,CAAA;AAAe,KAMf,SANe,CAAkB,WAMZ,OANY,EAAA,EAAvB,UAMgC,QANhC,CAAA,GAAA,QAOf,EAPe,CAAA,MAAA,CAAA,IAOD,CAPC,SAOS,IAPT,CAOc,CAPd,EAAA,KAAA,EAAA,EAO0B,UAP1B,CAAA,GAAA,CAAA,GAAA,KAAA,GASV,CATU,SAAA,QAAA,GAUlB,UAVkB,CAUP,CAVO,CAAA,MAAA,CAAA,EAUI,OAVJ,CAUY,CAVZ,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,CAAA,GAWlB,CAXkB,SAAA,MAAA,GAYjB,QAZiB,CAYR,CAZQ,CAAA,MAAA,CAAA,EAYG,OAZH,CAYW,CAZX,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,CAAA,GAAA,KAAA,EAAA;;;AAxBtB,KCoBK,gBDpBO,CAAA,UCoBoB,cDpBO,CAAA,GAAA,QAAA,MCqB1B,CDrB0B,GCqBtB,CDrBsB,CCqBpB,CDrBoB,CAAA,CAAA,QAAA,CAAA,EAAA;AAEvC,KCqBK,cDrBO,CAAA,UCqBkB,YDrBlB,CAAA,GAAA,QAAA,MCsBC,CDtBD,GCsBK,CDtBL,CCsBO,CDtBP,CAAA,CAAA,QAAA,CAAA,EAAA;AAGZ,KCqBK,oBDrBO,CAAA,UCqBwB,YDrBX,CAAA,GAAA,QAAA,MCsBZ,CDtBY,GCsBR,CDtBQ,CCsBN,CDtBM,CAAA,CAAA,QAAA,CAAA,EAAA;AAGb,UCsBK,UDtBL,CAAA,WCsB2B,ODtB3B,EAAA,GCsBuC,ODtBvC,EAAA,CAAA,CAAA;EAAA,OAEF,ECqBA,gBDrBA,CCqBiB,SDrBjB,CCqB2B,EDrB3B,EAAA,QAAA,CAAA,CAAA;EAAe,KAAA,ECsBjB,cDtBiB,CCsBF,SDtBE,CCsBQ,EDtBR,EAAA,MAAA,CAAA,CAAA;EAAsC,WAAA,ECuBjD,oBDvBiD,CCuB5B,SDvB4B,CCuBlB,EDvBkB,EAAA,MAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
//#region src/models/rule.d.ts
|
|
3
|
+
type WithEnabled<T> = boolean | T;
|
|
4
|
+
type RuleType = "filter" | "rule";
|
|
5
|
+
type RuleConfig = Record<string, any>;
|
|
6
|
+
type RuleModule = any;
|
|
7
|
+
interface Rule<T extends RuleType, N extends string, C extends RuleConfig> {
|
|
8
|
+
type: T;
|
|
9
|
+
name: N;
|
|
10
|
+
config: WithEnabled<C>;
|
|
11
|
+
}
|
|
12
|
+
interface RuleRule<N extends string, C extends RuleConfig> extends Rule<"rule", N, C> {
|
|
13
|
+
module: RuleModule;
|
|
14
|
+
}
|
|
15
|
+
interface FilterRule<N extends string, C extends RuleConfig> extends Rule<"filter", N, C> {}
|
|
16
|
+
type AnyRule = Rule<RuleType, string, RuleConfig>;
|
|
17
|
+
type AnyRules = Record<string, AnyRule>;
|
|
18
|
+
type AnyRuleRules = Record<string, RuleRule<string, RuleConfig>>;
|
|
19
|
+
type AnyRuleFilters = Record<string, FilterRule<string, RuleConfig>>;
|
|
20
|
+
type ToRuleMap<RS extends AnyRule[], T extends RuleType> = { [K in RS[number] as K extends Rule<T, infer N, RuleConfig> ? N : never]: T extends "filter" ? FilterRule<K["name"], Exclude<K["config"], boolean>> : T extends "rule" ? RuleRule<K["name"], Exclude<K["config"], boolean>> : never };
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/models/config.d.ts
|
|
23
|
+
type UserConfigFilter<R extends AnyRuleFilters> = { [K in keyof R]: R[K]["config"] };
|
|
24
|
+
type UserConfigRule<R extends AnyRuleRules> = { [K in keyof R]: R[K]["module"] };
|
|
25
|
+
type UserConfigRuleConfig<R extends AnyRuleRules> = { [K in keyof R]: R[K]["config"] };
|
|
26
|
+
interface UserConfig<RS extends AnyRule[] = AnyRule[]> {
|
|
27
|
+
filters: UserConfigFilter<ToRuleMap<RS, "filter">>;
|
|
28
|
+
rules: UserConfigRule<ToRuleMap<RS, "rule">>;
|
|
29
|
+
rulesConfig: UserConfigRuleConfig<ToRuleMap<RS, "rule">>;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { AnyRules as a, RuleModule as c, ToRuleMap as d, WithEnabled as f, AnyRuleRules as i, RuleRule as l, AnyRule as n, FilterRule as o, AnyRuleFilters as r, RuleConfig as s, UserConfig as t, RuleType as u };
|
|
33
|
+
// Generated by @kcconfigs/tsdown
|
|
34
|
+
//# sourceMappingURL=config-KDNTBTCT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-KDNTBTCT.d.ts","names":[],"sources":["../src/models/rule.ts","../src/models/config.ts"],"sourcesContent":[],"mappings":";;KAAY,2BAA2B;AAA3B,KAEA,QAAA,GAFA,QAA2B,GAAA,MAAA;AAE3B,KAGA,UAAA,GAAa,MAHb,CAAA,MAAA,EAAA,GAAA,CAAA;AAGA,KAGA,UAAA,GAHA,GAAa;AAGzB,UAEU,IAFE,CAAA,UAEa,QAAf,EAAe,UAAA,MAAA,EAAsC,UAAA,UAAA,CACxD,CAAA;EACA,IAAA,EADA,CACA;EACc,IAAA,EADd,CACc;EAAZ,MAAA,EAAA,WAAA,CAAY,CAAZ,CAAA;;AAGQ,UAAA,QAAA,CAAqC,UAAA,MAAA,EAChC,UADgC,UAChC,CAAG,SAAhB,IAAgB,CAAA,MAAA,EAAH,CAAG,EAAA,CAAA,CAAA,CAAA;EAChB,MAAA,EAAA,UAAA;;AADA,UAIQ,UAJR,CAIT,UAAiB,MAAA,EAAuC,UAAA,UAAA,CAChC,SAAf,IAAe,CAAA,QAAA,EAAA,CAAA,EAAG,CAAH,CAAA,CAAA,CAAA;AAAG,KAEf,OAAA,GAAU,IAFK,CAEA,QAFA,EAAA,MAAA,EAEkB,UAFlB,CAAA;AAAlB,KAIG,QAAA,GAAW,MAJd,CAAA,MAAA,EAI6B,OAJ7B,CAAA;AAAA,KAKG,YAAA,GAAe,MALlB,CAAA,MAAA,EAKiC,QALjC,CAAA,MAAA,EAKkD,UALlD,CAAA,CAAA;AAEG,KAIA,cAAA,GAAiB,MAJjB,CAAA,MAAA,EAIgC,UAJhC,CAAA,MAAA,EAImD,UAJnD,CAAA,CAAA;AAAe,KAMf,SANe,CAAkB,WAMZ,OANY,EAAA,EAAvB,UAMgC,QANhC,CAAA,GAAA,QAOf,EAPe,CAAA,MAAA,CAAA,IAOD,CAPC,SAOS,IAPT,CAOc,CAPd,EAAA,KAAA,EAAA,EAO0B,UAP1B,CAAA,GAAA,CAAA,GAAA,KAAA,GASV,CATU,SAAA,QAAA,GAUlB,UAVkB,CAUP,CAVO,CAAA,MAAA,CAAA,EAUI,OAVJ,CAUY,CAVZ,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,CAAA,GAWlB,CAXkB,SAAA,MAAA,GAYjB,QAZiB,CAYR,CAZQ,CAAA,MAAA,CAAA,EAYG,OAZH,CAYW,CAZX,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,CAAA,GAAA,KAAA,EAAA;;;AAxBtB,KCoBK,gBDpBO,CAAA,UCoBoB,cDpBO,CAAA,GAAA,QAAA,MCqB1B,CDrB0B,GCqBtB,CDrBsB,CCqBpB,CDrBoB,CAAA,CAAA,QAAA,CAAA,EAAA;AAEvC,KCqBK,cDrBO,CAAA,UCqBkB,YDrBlB,CAAA,GAAA,QAAA,MCsBC,CDtBD,GCsBK,CDtBL,CCsBO,CDtBP,CAAA,CAAA,QAAA,CAAA,EAAA;AAGZ,KCqBK,oBDrBO,CAAA,UCqBwB,YDrBX,CAAA,GAAA,QAAA,MCsBZ,CDtBY,GCsBR,CDtBQ,CCsBN,CDtBM,CAAA,CAAA,QAAA,CAAA,EAAA;AAGb,UCsBK,UDtBL,CAAA,WCsB2B,ODtB3B,EAAA,GCsBuC,ODtBvC,EAAA,CAAA,CAAA;EAAA,OAEF,ECqBA,gBDrBA,CCqBiB,SDrBjB,CCqB2B,EDrB3B,EAAA,QAAA,CAAA,CAAA;EAAe,KAAA,ECsBjB,cDtBiB,CCsBF,SDtBE,CCsBQ,EDtBR,EAAA,MAAA,CAAA,CAAA;EAAsC,WAAA,ECuBjD,oBDvBiD,CCuB5B,SDvB4B,CCuBlB,EDvBkB,EAAA,MAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
let textlint_rule_terminology = require("textlint-rule-terminology");
|
|
30
|
+
textlint_rule_terminology = __toESM(textlint_rule_terminology);
|
|
31
|
+
|
|
32
|
+
//#region src/rules/allowlist.ts
|
|
33
|
+
const allowlist = (config) => {
|
|
34
|
+
if (!config) return {
|
|
35
|
+
type: "filter",
|
|
36
|
+
name: "allowlist",
|
|
37
|
+
config: false
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
type: "filter",
|
|
41
|
+
name: "allowlist",
|
|
42
|
+
config: {
|
|
43
|
+
allow: config.allow,
|
|
44
|
+
allowlistConfigPaths: config.allowlistConfigPaths
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/rules/comment.ts
|
|
51
|
+
const comments = (enabled = true) => {
|
|
52
|
+
return {
|
|
53
|
+
type: "filter",
|
|
54
|
+
name: "comments",
|
|
55
|
+
config: enabled
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/rules/terminology.ts
|
|
61
|
+
const terminology = (config) => {
|
|
62
|
+
return {
|
|
63
|
+
type: "rule",
|
|
64
|
+
name: "terminology",
|
|
65
|
+
module: textlint_rule_terminology.default,
|
|
66
|
+
config: {
|
|
67
|
+
defaultTerms: true,
|
|
68
|
+
...config
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/utils/defineConfig.ts
|
|
75
|
+
const defineConfig = (...inputs) => {
|
|
76
|
+
const filters = {};
|
|
77
|
+
const rules = {};
|
|
78
|
+
const rulesConfig = {};
|
|
79
|
+
for (const input of inputs) {
|
|
80
|
+
if (input.config === false) continue;
|
|
81
|
+
switch (input.type) {
|
|
82
|
+
case "filter":
|
|
83
|
+
filters[input.name] = input.config;
|
|
84
|
+
break;
|
|
85
|
+
case "rule": {
|
|
86
|
+
const rule = input;
|
|
87
|
+
rules[rule.name] = rule.module;
|
|
88
|
+
rulesConfig[rule.name] = rule.config;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
filters,
|
|
95
|
+
rules,
|
|
96
|
+
rulesConfig
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
Object.defineProperty(exports, 'allowlist', {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return allowlist;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, 'comments', {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () {
|
|
110
|
+
return comments;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, 'defineConfig', {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () {
|
|
116
|
+
return defineConfig;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, 'terminology', {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () {
|
|
122
|
+
return terminology;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
// Generated by @kcconfigs/tsdown
|
|
126
|
+
//# sourceMappingURL=defineConfig-BSVyAEFt.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineConfig-BSVyAEFt.cjs","names":["terminologyModule"],"sources":["../src/rules/allowlist.ts","../src/rules/comment.ts","../src/rules/terminology.ts","../src/utils/defineConfig.ts"],"sourcesContent":["import type { FilterRule } from \"../models/rule\";\n\nexport interface AllowListConfig {\n\tallow: string[];\n\tallowlistConfigPaths: string[];\n}\n\nexport type AllowListRule = FilterRule<\"allowlist\", AllowListConfig>;\n\nexport const allowlist = (config?: AllowListConfig): AllowListRule => {\n\tif (!config) {\n\t\treturn {\n\t\t\ttype: \"filter\",\n\t\t\tname: \"allowlist\",\n\t\t\tconfig: false,\n\t\t};\n\t}\n\n\treturn {\n\t\ttype: \"filter\",\n\t\tname: \"allowlist\",\n\t\tconfig: {\n\t\t\tallow: config.allow,\n\t\t\tallowlistConfigPaths: config.allowlistConfigPaths,\n\t\t},\n\t};\n};\n","import type { FilterRule } from \"../models/rule\";\n\nexport type CommentRule = FilterRule<\"comments\", Record<string, never>>;\n\nexport const comments = (enabled = true): CommentRule => {\n\treturn {\n\t\ttype: \"filter\",\n\t\tname: \"comments\",\n\t\tconfig: enabled,\n\t};\n};\n","import terminologyModule from \"textlint-rule-terminology\";\nimport type { RuleRule } from \"../models/rule\";\n\nexport interface TerminologyConfig {\n\tdefaultTerms?: boolean;\n\tskip?: string[];\n\tterms?: string[];\n\texclude?: string[];\n}\n\nexport type TerminologyRule = RuleRule<\"terminology\", TerminologyConfig>;\n\nexport const terminology = (config?: TerminologyConfig): TerminologyRule => {\n\treturn {\n\t\ttype: \"rule\",\n\t\tname: \"terminology\",\n\t\tmodule: terminologyModule,\n\t\tconfig: {\n\t\t\tdefaultTerms: true,\n\t\t\t...config,\n\t\t},\n\t};\n};\n","import type { UserConfig } from \"../models/config\";\nimport type { AnyRule, RuleConfig, RuleRule } from \"../models/rule\";\n\nexport const defineConfig = <RS extends AnyRule[]>(\n\t...inputs: RS\n): UserConfig<RS> => {\n\ttype Filters = UserConfig<RS>[\"filters\"];\n\ttype Rules = UserConfig<RS>[\"rules\"];\n\ttype RulesConfig = UserConfig<RS>[\"rulesConfig\"];\n\n\tconst filters = {} as Filters;\n\tconst rules = {} as Rules;\n\tconst rulesConfig = {} as RulesConfig;\n\n\tfor (const input of inputs) {\n\t\tif (input.config === false) continue;\n\n\t\tswitch (input.type) {\n\t\t\tcase \"filter\": {\n\t\t\t\ttype Name = keyof Filters;\n\t\t\t\ttype Config = Filters[Name];\n\t\t\t\tfilters[input.name as Name] = input.config as Config;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"rule\": {\n\t\t\t\tconst rule = input as RuleRule<string, RuleConfig>;\n\t\t\t\ttype Name = keyof Rules;\n\t\t\t\ttype Config = RuleConfig[Name];\n\t\t\t\trules[rule.name as Name] = rule.module;\n\t\t\t\trulesConfig[rule.name as Name] = rule.config as Config;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tfilters,\n\t\trules,\n\t\trulesConfig,\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,aAAa,WAA4C;AACrE,KAAI,CAAC,OACJ,QAAO;EACN,MAAM;EACN,MAAM;EACN,QAAQ;EACR;AAGF,QAAO;EACN,MAAM;EACN,MAAM;EACN,QAAQ;GACP,OAAO,OAAO;GACd,sBAAsB,OAAO;GAC7B;EACD;;;;;ACrBF,MAAa,YAAY,UAAU,SAAsB;AACxD,QAAO;EACN,MAAM;EACN,MAAM;EACN,QAAQ;EACR;;;;;ACGF,MAAa,eAAe,WAAgD;AAC3E,QAAO;EACN,MAAM;EACN,MAAM;EACN,QAAQA;EACR,QAAQ;GACP,cAAc;GACd,GAAG;GACH;EACD;;;;;AClBF,MAAa,gBACZ,GAAG,WACiB;CAKpB,MAAM,UAAU,EAAE;CAClB,MAAM,QAAQ,EAAE;CAChB,MAAM,cAAc,EAAE;AAEtB,MAAK,MAAM,SAAS,QAAQ;AAC3B,MAAI,MAAM,WAAW,MAAO;AAE5B,UAAQ,MAAM,MAAd;GACC,KAAK;AAGJ,YAAQ,MAAM,QAAgB,MAAM;AACpC;GAED,KAAK,QAAQ;IACZ,MAAM,OAAO;AAGb,UAAM,KAAK,QAAgB,KAAK;AAChC,gBAAY,KAAK,QAAgB,KAAK;AACtC;;;;AAKH,QAAO;EACN;EACA;EACA;EACA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import terminologyModule from "textlint-rule-terminology";
|
|
3
|
+
|
|
4
|
+
//#region rolldown:runtime
|
|
5
|
+
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
6
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/rules/allowlist.ts
|
|
10
|
+
var allowlist;
|
|
11
|
+
var init_allowlist = __esmMin(() => {
|
|
12
|
+
allowlist = (config) => {
|
|
13
|
+
if (!config) return {
|
|
14
|
+
type: "filter",
|
|
15
|
+
name: "allowlist",
|
|
16
|
+
config: false
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
type: "filter",
|
|
20
|
+
name: "allowlist",
|
|
21
|
+
config: {
|
|
22
|
+
allow: config.allow,
|
|
23
|
+
allowlistConfigPaths: config.allowlistConfigPaths
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/rules/comment.ts
|
|
31
|
+
var comments;
|
|
32
|
+
var init_comment = __esmMin(() => {
|
|
33
|
+
comments = (enabled = true) => {
|
|
34
|
+
return {
|
|
35
|
+
type: "filter",
|
|
36
|
+
name: "comments",
|
|
37
|
+
config: enabled
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/rules/terminology.ts
|
|
44
|
+
var terminology;
|
|
45
|
+
var init_terminology = __esmMin(() => {
|
|
46
|
+
terminology = (config) => {
|
|
47
|
+
return {
|
|
48
|
+
type: "rule",
|
|
49
|
+
name: "terminology",
|
|
50
|
+
module: terminologyModule,
|
|
51
|
+
config: {
|
|
52
|
+
defaultTerms: true,
|
|
53
|
+
...config
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/rules/index.ts
|
|
61
|
+
var init_rules = __esmMin(() => {
|
|
62
|
+
init_allowlist();
|
|
63
|
+
init_comment();
|
|
64
|
+
init_terminology();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/utils/defineConfig.ts
|
|
69
|
+
var defineConfig;
|
|
70
|
+
var init_defineConfig = __esmMin(() => {
|
|
71
|
+
defineConfig = (...inputs) => {
|
|
72
|
+
const filters = {};
|
|
73
|
+
const rules = {};
|
|
74
|
+
const rulesConfig = {};
|
|
75
|
+
for (const input of inputs) {
|
|
76
|
+
if (input.config === false) continue;
|
|
77
|
+
switch (input.type) {
|
|
78
|
+
case "filter":
|
|
79
|
+
filters[input.name] = input.config;
|
|
80
|
+
break;
|
|
81
|
+
case "rule": {
|
|
82
|
+
const rule = input;
|
|
83
|
+
rules[rule.name] = rule.module;
|
|
84
|
+
rulesConfig[rule.name] = rule.config;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
filters,
|
|
91
|
+
rules,
|
|
92
|
+
rulesConfig
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
export { comments as a, terminology as i, init_defineConfig as n, allowlist as o, init_rules as r, __commonJSMin as s, defineConfig as t };
|
|
99
|
+
// Generated by @kcconfigs/tsdown
|
|
100
|
+
//# sourceMappingURL=defineConfig-Rcs53KN7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineConfig-Rcs53KN7.js","names":[],"sources":["../src/rules/allowlist.ts","../src/rules/comment.ts","../src/rules/terminology.ts","../src/rules/index.ts","../src/utils/defineConfig.ts"],"sourcesContent":["import type { FilterRule } from \"../models/rule\";\n\nexport interface AllowListConfig {\n\tallow: string[];\n\tallowlistConfigPaths: string[];\n}\n\nexport type AllowListRule = FilterRule<\"allowlist\", AllowListConfig>;\n\nexport const allowlist = (config?: AllowListConfig): AllowListRule => {\n\tif (!config) {\n\t\treturn {\n\t\t\ttype: \"filter\",\n\t\t\tname: \"allowlist\",\n\t\t\tconfig: false,\n\t\t};\n\t}\n\n\treturn {\n\t\ttype: \"filter\",\n\t\tname: \"allowlist\",\n\t\tconfig: {\n\t\t\tallow: config.allow,\n\t\t\tallowlistConfigPaths: config.allowlistConfigPaths,\n\t\t},\n\t};\n};\n","import type { FilterRule } from \"../models/rule\";\n\nexport type CommentRule = FilterRule<\"comments\", Record<string, never>>;\n\nexport const comments = (enabled = true): CommentRule => {\n\treturn {\n\t\ttype: \"filter\",\n\t\tname: \"comments\",\n\t\tconfig: enabled,\n\t};\n};\n","import terminologyModule from \"textlint-rule-terminology\";\nimport type { RuleRule } from \"../models/rule\";\n\nexport interface TerminologyConfig {\n\tdefaultTerms?: boolean;\n\tskip?: string[];\n\tterms?: string[];\n\texclude?: string[];\n}\n\nexport type TerminologyRule = RuleRule<\"terminology\", TerminologyConfig>;\n\nexport const terminology = (config?: TerminologyConfig): TerminologyRule => {\n\treturn {\n\t\ttype: \"rule\",\n\t\tname: \"terminology\",\n\t\tmodule: terminologyModule,\n\t\tconfig: {\n\t\t\tdefaultTerms: true,\n\t\t\t...config,\n\t\t},\n\t};\n};\n","export * from \"./allowlist\";\nexport * from \"./comment\";\nexport * from \"./terminology\";\n","import type { UserConfig } from \"../models/config\";\nimport type { AnyRule, RuleConfig, RuleRule } from \"../models/rule\";\n\nexport const defineConfig = <RS extends AnyRule[]>(\n\t...inputs: RS\n): UserConfig<RS> => {\n\ttype Filters = UserConfig<RS>[\"filters\"];\n\ttype Rules = UserConfig<RS>[\"rules\"];\n\ttype RulesConfig = UserConfig<RS>[\"rulesConfig\"];\n\n\tconst filters = {} as Filters;\n\tconst rules = {} as Rules;\n\tconst rulesConfig = {} as RulesConfig;\n\n\tfor (const input of inputs) {\n\t\tif (input.config === false) continue;\n\n\t\tswitch (input.type) {\n\t\t\tcase \"filter\": {\n\t\t\t\ttype Name = keyof Filters;\n\t\t\t\ttype Config = Filters[Name];\n\t\t\t\tfilters[input.name as Name] = input.config as Config;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"rule\": {\n\t\t\t\tconst rule = input as RuleRule<string, RuleConfig>;\n\t\t\t\ttype Name = keyof Rules;\n\t\t\t\ttype Config = RuleConfig[Name];\n\t\t\t\trules[rule.name as Name] = rule.module;\n\t\t\t\trulesConfig[rule.name as Name] = rule.config as Config;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tfilters,\n\t\trules,\n\t\trulesConfig,\n\t};\n};\n"],"mappings":";;;;;;;;;;;CASa,aAAa,WAA4C;AACrE,MAAI,CAAC,OACJ,QAAO;GACN,MAAM;GACN,MAAM;GACN,QAAQ;GACR;AAGF,SAAO;GACN,MAAM;GACN,MAAM;GACN,QAAQ;IACP,OAAO,OAAO;IACd,sBAAsB,OAAO;IAC7B;GACD;;;;;;;;CCrBW,YAAY,UAAU,SAAsB;AACxD,SAAO;GACN,MAAM;GACN,MAAM;GACN,QAAQ;GACR;;;;;;;;CCGW,eAAe,WAAgD;AAC3E,SAAO;GACN,MAAM;GACN,MAAM;GACN,QAAQ;GACR,QAAQ;IACP,cAAc;IACd,GAAG;IACH;GACD;;;;;;;;;;;;;;;;CElBW,gBACZ,GAAG,WACiB;EAKpB,MAAM,UAAU,EAAE;EAClB,MAAM,QAAQ,EAAE;EAChB,MAAM,cAAc,EAAE;AAEtB,OAAK,MAAM,SAAS,QAAQ;AAC3B,OAAI,MAAM,WAAW,MAAO;AAE5B,WAAQ,MAAM,MAAd;IACC,KAAK;AAGJ,aAAQ,MAAM,QAAgB,MAAM;AACpC;IAED,KAAK,QAAQ;KACZ,MAAM,OAAO;AAGb,WAAM,KAAK,QAAgB,KAAK;AAChC,iBAAY,KAAK,QAAgB,KAAK;AACtC;;;;AAKH,SAAO;GACN;GACA;GACA;GACA"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
const require_defineConfig = require('./defineConfig-BSVyAEFt.cjs');
|
|
3
|
+
|
|
4
|
+
exports.allowlist = require_defineConfig.allowlist;
|
|
5
|
+
exports.comments = require_defineConfig.comments;
|
|
6
|
+
exports.defineConfig = require_defineConfig.defineConfig;
|
|
7
|
+
exports.terminology = require_defineConfig.terminology;
|
|
8
|
+
// Generated by @kcconfigs/tsdown
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { a as AnyRules, c as RuleModule, d as ToRuleMap, f as WithEnabled, i as AnyRuleRules, l as RuleRule, n as AnyRule, o as FilterRule, r as AnyRuleFilters, s as RuleConfig, t as UserConfig, u as RuleType } from "./config-CjR_suQD.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/rules/allowlist.d.ts
|
|
5
|
+
interface AllowListConfig {
|
|
6
|
+
allow: string[];
|
|
7
|
+
allowlistConfigPaths: string[];
|
|
8
|
+
}
|
|
9
|
+
type AllowListRule = FilterRule<"allowlist", AllowListConfig>;
|
|
10
|
+
declare const allowlist: (config?: AllowListConfig) => AllowListRule;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/rules/comment.d.ts
|
|
13
|
+
type CommentRule = FilterRule<"comments", Record<string, never>>;
|
|
14
|
+
declare const comments: (enabled?: boolean) => CommentRule;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/rules/terminology.d.ts
|
|
17
|
+
interface TerminologyConfig {
|
|
18
|
+
defaultTerms?: boolean;
|
|
19
|
+
skip?: string[];
|
|
20
|
+
terms?: string[];
|
|
21
|
+
exclude?: string[];
|
|
22
|
+
}
|
|
23
|
+
type TerminologyRule = RuleRule<"terminology", TerminologyConfig>;
|
|
24
|
+
declare const terminology: (config?: TerminologyConfig) => TerminologyRule;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/utils/defineConfig.d.ts
|
|
27
|
+
declare const defineConfig: <RS extends AnyRule[]>(...inputs: RS) => UserConfig<RS>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { AllowListConfig, AllowListRule, AnyRule, AnyRuleFilters, AnyRuleRules, AnyRules, CommentRule, FilterRule, RuleConfig, RuleModule, RuleRule, RuleType, TerminologyConfig, TerminologyRule, ToRuleMap, UserConfig, WithEnabled, allowlist, comments, defineConfig, terminology };
|
|
30
|
+
// Generated by @kcconfigs/tsdown
|
|
31
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/rules/allowlist.ts","../src/rules/comment.ts","../src/rules/terminology.ts","../src/utils/defineConfig.ts"],"sourcesContent":[],"mappings":";;;;UAEiB,eAAA;;EAAjB,oBAAiB,EAAA,MAAA,EAAA;AAKjB;AAEa,KAFD,aAAA,GAAgB,UAEO,CAAA,WAAkB,EAFD,eAEC,CAAA;cAAxC,qBAAsB,oBAAkB;;;KCPzC,WAAA,GAAc,uBAAuB;cAEpC,iCAA6B;;;UCDzB,iBAAA;;EFDjB,IAAiB,CAAA,EAAA,MAAA,EAAA;EAKjB,KAAY,CAAA,EAAA,MAAA,EAAA;EAEZ,OAAa,CAAA,EAAA,MAAwC,EAAA;;KECzC,eAAA,GAAkB,wBAAwB;cAEzC,uBAAwB,sBAAoB;;;cCT5C,0BAA2B,sBAC5B,OACT,WAAW"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { a as AnyRules, c as RuleModule, d as ToRuleMap, f as WithEnabled, i as AnyRuleRules, l as RuleRule, n as AnyRule, o as FilterRule, r as AnyRuleFilters, s as RuleConfig, t as UserConfig, u as RuleType } from "./config-KDNTBTCT.js";
|
|
3
|
+
|
|
4
|
+
//#region src/rules/allowlist.d.ts
|
|
5
|
+
interface AllowListConfig {
|
|
6
|
+
allow: string[];
|
|
7
|
+
allowlistConfigPaths: string[];
|
|
8
|
+
}
|
|
9
|
+
type AllowListRule = FilterRule<"allowlist", AllowListConfig>;
|
|
10
|
+
declare const allowlist: (config?: AllowListConfig) => AllowListRule;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/rules/comment.d.ts
|
|
13
|
+
type CommentRule = FilterRule<"comments", Record<string, never>>;
|
|
14
|
+
declare const comments: (enabled?: boolean) => CommentRule;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/rules/terminology.d.ts
|
|
17
|
+
interface TerminologyConfig {
|
|
18
|
+
defaultTerms?: boolean;
|
|
19
|
+
skip?: string[];
|
|
20
|
+
terms?: string[];
|
|
21
|
+
exclude?: string[];
|
|
22
|
+
}
|
|
23
|
+
type TerminologyRule = RuleRule<"terminology", TerminologyConfig>;
|
|
24
|
+
declare const terminology: (config?: TerminologyConfig) => TerminologyRule;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/utils/defineConfig.d.ts
|
|
27
|
+
declare const defineConfig: <RS extends AnyRule[]>(...inputs: RS) => UserConfig<RS>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { AllowListConfig, AllowListRule, AnyRule, AnyRuleFilters, AnyRuleRules, AnyRules, CommentRule, FilterRule, RuleConfig, RuleModule, RuleRule, RuleType, TerminologyConfig, TerminologyRule, ToRuleMap, UserConfig, WithEnabled, allowlist, comments, defineConfig, terminology };
|
|
30
|
+
// Generated by @kcconfigs/tsdown
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/rules/allowlist.ts","../src/rules/comment.ts","../src/rules/terminology.ts","../src/utils/defineConfig.ts"],"sourcesContent":[],"mappings":";;;;UAEiB,eAAA;;EAAjB,oBAAiB,EAAA,MAAA,EAAA;AAKjB;AAEa,KAFD,aAAA,GAAgB,UAEO,CAAA,WAAkB,EAFD,eAEC,CAAA;cAAxC,qBAAsB,oBAAkB;;;KCPzC,WAAA,GAAc,uBAAuB;cAEpC,iCAA6B;;;UCDzB,iBAAA;;EFDjB,IAAiB,CAAA,EAAA,MAAA,EAAA;EAKjB,KAAY,CAAA,EAAA,MAAA,EAAA;EAEZ,OAAa,CAAA,EAAA,MAAwC,EAAA;;KECzC,eAAA,GAAkB,wBAAwB;cAEzC,uBAAwB,sBAAoB;;;cCT5C,0BAA2B,sBAC5B,OACT,WAAW"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { a as comments, i as terminology, n as init_defineConfig, o as allowlist, r as init_rules, t as defineConfig } from "./defineConfig-Rcs53KN7.js";
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
init_rules();
|
|
6
|
+
init_defineConfig();
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { allowlist, comments, defineConfig, terminology };
|
|
10
|
+
// Generated by @kcconfigs/tsdown
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export type * from \"./models/config\";\nexport type * from \"./models/rule\";\n\nexport * from \"./rules\";\n\nexport * from \"./utils/defineConfig\";\n"],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
const require_defineConfig = require('../defineConfig-BSVyAEFt.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/presets/default.ts
|
|
5
|
+
const config = require_defineConfig.defineConfig(require_defineConfig.comments(true), require_defineConfig.allowlist(), require_defineConfig.terminology());
|
|
6
|
+
module.exports = config;
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
// Generated by @kcconfigs/tsdown
|
|
10
|
+
//# sourceMappingURL=default.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.cjs","names":["config: UserConfig","defineConfig","comments","allowlist","terminology"],"sources":["../../src/presets/default.ts"],"sourcesContent":["import type { UserConfig } from \"../models/config\";\nimport { allowlist, comments, terminology } from \"../rules\";\nimport { defineConfig } from \"../utils/defineConfig\";\n\nconst config: UserConfig = defineConfig(\n\tcomments(true),\n\tallowlist(),\n\tterminology(),\n);\n\nexport = config;\n"],"mappings":";;;;AAIA,MAAMA,SAAqBC,kCAC1BC,8BAAS,KAAK,EACdC,gCAAW,EACXC,kCAAa,CACb;iBAEQ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { t as UserConfig } from "../config-CjR_suQD.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/presets/default.d.ts
|
|
5
|
+
declare const config: UserConfig;
|
|
6
|
+
export = config;
|
|
7
|
+
// Generated by @kcconfigs/tsdown
|
|
8
|
+
//# sourceMappingURL=default.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.cts","names":["config: UserConfig"],"sources":["../../src/presets/default.ts"],"sourcesContent":[],"mappings":";;;;cAIMA,QAAQ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { t as UserConfig } from "../config-KDNTBTCT.js";
|
|
3
|
+
|
|
4
|
+
//#region src/presets/default.d.ts
|
|
5
|
+
declare const config: UserConfig;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { config as default };
|
|
8
|
+
// Generated by @kcconfigs/tsdown
|
|
9
|
+
//# sourceMappingURL=default.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","names":["config: UserConfig"],"sources":["../../src/presets/default.ts"],"sourcesContent":[],"mappings":";;;;cAIMA,QAAQ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { a as comments, i as terminology, n as init_defineConfig, o as allowlist, r as init_rules, s as __commonJSMin, t as defineConfig } from "../defineConfig-Rcs53KN7.js";
|
|
3
|
+
|
|
4
|
+
//#region src/presets/default.ts
|
|
5
|
+
var require_default = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
|
+
init_rules();
|
|
7
|
+
init_defineConfig();
|
|
8
|
+
const config = defineConfig(comments(true), allowlist(), terminology());
|
|
9
|
+
module.exports = config;
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export default require_default();
|
|
14
|
+
|
|
15
|
+
// Generated by @kcconfigs/tsdown
|
|
16
|
+
//# sourceMappingURL=default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.js","names":["config: UserConfig"],"sources":["../../src/presets/default.ts"],"sourcesContent":["import type { UserConfig } from \"../models/config\";\nimport { allowlist, comments, terminology } from \"../rules\";\nimport { defineConfig } from \"../utils/defineConfig\";\n\nconst config: UserConfig = defineConfig(\n\tcomments(true),\n\tallowlist(),\n\tterminology(),\n);\n\nexport = config;\n"],"mappings":";;;;;aAC4D;oBACP;CAErD,MAAMA,SAAqB,aAC1B,SAAS,KAAK,EACd,WAAW,EACX,aAAa,CACb;kBAEQ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kcconfigs/textlint",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "Shared textlint rule configuration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"textlint-filter-rule-allowlist": "4.0.0",
|
|
8
|
+
"textlint-filter-rule-comments": "1.3.0",
|
|
9
|
+
"textlint-rule-terminology": "5.2.16"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@biomejs/biome": "2.3.10",
|
|
13
|
+
"textlint": "15.5.0",
|
|
14
|
+
"tsdown": "0.18.4",
|
|
15
|
+
"vitest": "4.0.15",
|
|
16
|
+
"@kcconfigs/biome": "0.2.1",
|
|
17
|
+
"@kcconfigs/tsdown": "0.1.0-beta.3",
|
|
18
|
+
"@kcconfigs/vitest": "0.1.0-beta.2",
|
|
19
|
+
"@kcconfigs/tsconfig": "0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"textlint": "^15.0.0"
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.cts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"source": "./src/index.ts",
|
|
29
|
+
"typedoc": "./src/index.ts",
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/index.d.cts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"default": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"./preset-*": {
|
|
40
|
+
"source": "./src/presets/*.ts",
|
|
41
|
+
"typedoc": "./src/presets/*.ts",
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/presets/*.d.cts",
|
|
44
|
+
"default": "./dist/presets/*.cjs"
|
|
45
|
+
},
|
|
46
|
+
"default": {
|
|
47
|
+
"types": "./dist/presets/*.d.ts",
|
|
48
|
+
"default": "./dist/presets/*.js"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"license": "AGPL-3.0-only",
|
|
53
|
+
"homepage": "https://github.com/kc-workspace/kcws/tree/main/packages/@kcconfigs/textlint",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"directory": "@kcconfigs/textlint",
|
|
57
|
+
"url": "git+https://github.com/kc-workspace/kcws.git"
|
|
58
|
+
},
|
|
59
|
+
"author": {
|
|
60
|
+
"name": "Kamontat Chantrachirathumrong",
|
|
61
|
+
"email": "kcws@kc.in.th",
|
|
62
|
+
"url": "https://github.com/kamontat"
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"textlint",
|
|
66
|
+
"textlintrule",
|
|
67
|
+
"config",
|
|
68
|
+
"preset"
|
|
69
|
+
],
|
|
70
|
+
"files": [
|
|
71
|
+
"CHANGELOG.json",
|
|
72
|
+
"CHANGELOG.md",
|
|
73
|
+
"dist",
|
|
74
|
+
"src"
|
|
75
|
+
],
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=14"
|
|
78
|
+
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "tsdown",
|
|
84
|
+
"test": "vitest run",
|
|
85
|
+
"fix": "biome check --fix --unsafe",
|
|
86
|
+
"check": "pnpm run lint:check && pnpm run format:check && pnpm run type:check",
|
|
87
|
+
"format": "biome format --fix",
|
|
88
|
+
"format:check": "biome format",
|
|
89
|
+
"lint": "biome lint --fix --unsafe",
|
|
90
|
+
"lint:check": "biome lint",
|
|
91
|
+
"type:check": "tsc --noEmit"
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "textlint-rule-terminology";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { multiply } from ".";
|
|
3
|
+
|
|
4
|
+
describe(multiply.name, () => {
|
|
5
|
+
test("should multiply two numbers correctly", () => {
|
|
6
|
+
expect(multiply(3, 4)).toBe(12);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("should handle negative numbers", () => {
|
|
10
|
+
expect(multiply(-2, 5)).toBe(-10);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("should handle zero", () => {
|
|
14
|
+
expect(multiply(0, 5)).toBe(0);
|
|
15
|
+
expect(multiply(10, 0)).toBe(0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("should handle decimal numbers", () => {
|
|
19
|
+
expect(multiply(2.5, 4)).toBe(10);
|
|
20
|
+
expect(multiply(1.5, 2.5)).toBe(3.75);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("should handle both negative numbers", () => {
|
|
24
|
+
expect(multiply(-3, -4)).toBe(12);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("should handle multiplication by one", () => {
|
|
28
|
+
expect(multiply(7, 1)).toBe(7);
|
|
29
|
+
expect(multiply(1, 7)).toBe(7);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("should handle large numbers", () => {
|
|
33
|
+
expect(multiply(1000, 1000)).toBe(1000000);
|
|
34
|
+
});
|
|
35
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AnyRule, AnyRuleFilters, AnyRuleRules, ToRuleMap } from "./rule";
|
|
2
|
+
|
|
3
|
+
// type RulesKeyByType<R extends Rules, T extends RuleType> = {
|
|
4
|
+
// [K in keyof R]: R[K] extends Rule<T, RuleConfig>
|
|
5
|
+
// ? K extends string
|
|
6
|
+
// ? K
|
|
7
|
+
// : never
|
|
8
|
+
// : never;
|
|
9
|
+
// }[keyof R];
|
|
10
|
+
|
|
11
|
+
// export type UserConfigRules<R extends Rules> = {
|
|
12
|
+
// [Key in RulesKeyByType<R, "rule">]: R[Key] extends { module: infer M }
|
|
13
|
+
// ? M
|
|
14
|
+
// : never;
|
|
15
|
+
// };
|
|
16
|
+
|
|
17
|
+
// export type UserConfigConfig<R extends Rules, T extends RuleType> = {
|
|
18
|
+
// [Key in RulesKeyByType<R, T>]: R[Key]["config"];
|
|
19
|
+
// };
|
|
20
|
+
|
|
21
|
+
type UserConfigFilter<R extends AnyRuleFilters> = {
|
|
22
|
+
[K in keyof R]: R[K]["config"];
|
|
23
|
+
};
|
|
24
|
+
type UserConfigRule<R extends AnyRuleRules> = {
|
|
25
|
+
[K in keyof R]: R[K]["module"];
|
|
26
|
+
};
|
|
27
|
+
type UserConfigRuleConfig<R extends AnyRuleRules> = {
|
|
28
|
+
[K in keyof R]: R[K]["config"];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface UserConfig<RS extends AnyRule[] = AnyRule[]> {
|
|
32
|
+
filters: UserConfigFilter<ToRuleMap<RS, "filter">>;
|
|
33
|
+
rules: UserConfigRule<ToRuleMap<RS, "rule">>;
|
|
34
|
+
rulesConfig: UserConfigRuleConfig<ToRuleMap<RS, "rule">>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type WithEnabled<T> = boolean | T;
|
|
2
|
+
|
|
3
|
+
export type RuleType = "filter" | "rule";
|
|
4
|
+
|
|
5
|
+
// biome-ignore lint/suspicious/noExplicitAny: config from third-party
|
|
6
|
+
export type RuleConfig = Record<string, any>;
|
|
7
|
+
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: rule exported from third-party
|
|
9
|
+
export type RuleModule = any;
|
|
10
|
+
|
|
11
|
+
interface Rule<T extends RuleType, N extends string, C extends RuleConfig> {
|
|
12
|
+
type: T;
|
|
13
|
+
name: N;
|
|
14
|
+
config: WithEnabled<C>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RuleRule<N extends string, C extends RuleConfig>
|
|
18
|
+
extends Rule<"rule", N, C> {
|
|
19
|
+
module: RuleModule;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FilterRule<N extends string, C extends RuleConfig>
|
|
23
|
+
extends Rule<"filter", N, C> {}
|
|
24
|
+
|
|
25
|
+
export type AnyRule = Rule<RuleType, string, RuleConfig>;
|
|
26
|
+
|
|
27
|
+
export type AnyRules = Record<string, AnyRule>;
|
|
28
|
+
export type AnyRuleRules = Record<string, RuleRule<string, RuleConfig>>;
|
|
29
|
+
export type AnyRuleFilters = Record<string, FilterRule<string, RuleConfig>>;
|
|
30
|
+
|
|
31
|
+
export type ToRuleMap<RS extends AnyRule[], T extends RuleType> = {
|
|
32
|
+
[K in RS[number] as K extends Rule<T, infer N, RuleConfig>
|
|
33
|
+
? N
|
|
34
|
+
: never]: T extends "filter"
|
|
35
|
+
? FilterRule<K["name"], Exclude<K["config"], boolean>>
|
|
36
|
+
: T extends "rule"
|
|
37
|
+
? RuleRule<K["name"], Exclude<K["config"], boolean>>
|
|
38
|
+
: never;
|
|
39
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UserConfig } from "../models/config";
|
|
2
|
+
import { allowlist, comments, terminology } from "../rules";
|
|
3
|
+
import { defineConfig } from "../utils/defineConfig";
|
|
4
|
+
|
|
5
|
+
const config: UserConfig = defineConfig(
|
|
6
|
+
comments(true),
|
|
7
|
+
allowlist(),
|
|
8
|
+
terminology(),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export = config;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FilterRule } from "../models/rule";
|
|
2
|
+
|
|
3
|
+
export interface AllowListConfig {
|
|
4
|
+
allow: string[];
|
|
5
|
+
allowlistConfigPaths: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type AllowListRule = FilterRule<"allowlist", AllowListConfig>;
|
|
9
|
+
|
|
10
|
+
export const allowlist = (config?: AllowListConfig): AllowListRule => {
|
|
11
|
+
if (!config) {
|
|
12
|
+
return {
|
|
13
|
+
type: "filter",
|
|
14
|
+
name: "allowlist",
|
|
15
|
+
config: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
type: "filter",
|
|
21
|
+
name: "allowlist",
|
|
22
|
+
config: {
|
|
23
|
+
allow: config.allow,
|
|
24
|
+
allowlistConfigPaths: config.allowlistConfigPaths,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FilterRule } from "../models/rule";
|
|
2
|
+
|
|
3
|
+
export type CommentRule = FilterRule<"comments", Record<string, never>>;
|
|
4
|
+
|
|
5
|
+
export const comments = (enabled = true): CommentRule => {
|
|
6
|
+
return {
|
|
7
|
+
type: "filter",
|
|
8
|
+
name: "comments",
|
|
9
|
+
config: enabled,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import terminologyModule from "textlint-rule-terminology";
|
|
2
|
+
import type { RuleRule } from "../models/rule";
|
|
3
|
+
|
|
4
|
+
export interface TerminologyConfig {
|
|
5
|
+
defaultTerms?: boolean;
|
|
6
|
+
skip?: string[];
|
|
7
|
+
terms?: string[];
|
|
8
|
+
exclude?: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type TerminologyRule = RuleRule<"terminology", TerminologyConfig>;
|
|
12
|
+
|
|
13
|
+
export const terminology = (config?: TerminologyConfig): TerminologyRule => {
|
|
14
|
+
return {
|
|
15
|
+
type: "rule",
|
|
16
|
+
name: "terminology",
|
|
17
|
+
module: terminologyModule,
|
|
18
|
+
config: {
|
|
19
|
+
defaultTerms: true,
|
|
20
|
+
...config,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { UserConfig } from "../models/config";
|
|
2
|
+
import type { AnyRule, RuleConfig, RuleRule } from "../models/rule";
|
|
3
|
+
|
|
4
|
+
export const defineConfig = <RS extends AnyRule[]>(
|
|
5
|
+
...inputs: RS
|
|
6
|
+
): UserConfig<RS> => {
|
|
7
|
+
type Filters = UserConfig<RS>["filters"];
|
|
8
|
+
type Rules = UserConfig<RS>["rules"];
|
|
9
|
+
type RulesConfig = UserConfig<RS>["rulesConfig"];
|
|
10
|
+
|
|
11
|
+
const filters = {} as Filters;
|
|
12
|
+
const rules = {} as Rules;
|
|
13
|
+
const rulesConfig = {} as RulesConfig;
|
|
14
|
+
|
|
15
|
+
for (const input of inputs) {
|
|
16
|
+
if (input.config === false) continue;
|
|
17
|
+
|
|
18
|
+
switch (input.type) {
|
|
19
|
+
case "filter": {
|
|
20
|
+
type Name = keyof Filters;
|
|
21
|
+
type Config = Filters[Name];
|
|
22
|
+
filters[input.name as Name] = input.config as Config;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case "rule": {
|
|
26
|
+
const rule = input as RuleRule<string, RuleConfig>;
|
|
27
|
+
type Name = keyof Rules;
|
|
28
|
+
type Config = RuleConfig[Name];
|
|
29
|
+
rules[rule.name as Name] = rule.module;
|
|
30
|
+
rulesConfig[rule.name as Name] = rule.config as Config;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
filters,
|
|
38
|
+
rules,
|
|
39
|
+
rulesConfig,
|
|
40
|
+
};
|
|
41
|
+
};
|