@kcconfigs/textlint 0.1.0-beta.0 → 0.1.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/comment-BYfI9NUG.cjs +71 -0
  3. package/dist/comment-BYfI9NUG.cjs.map +1 -0
  4. package/dist/comment-Dg2KjJvG.js +47 -0
  5. package/dist/comment-Dg2KjJvG.js.map +1 -0
  6. package/dist/config-BCGczZ5h.d.cts +36 -0
  7. package/dist/config-BCGczZ5h.d.cts.map +1 -0
  8. package/dist/config-DZLevSYy.d.ts +36 -0
  9. package/dist/config-DZLevSYy.d.ts.map +1 -0
  10. package/dist/configs/default.cjs +31 -0
  11. package/dist/configs/default.cjs.map +1 -0
  12. package/dist/configs/default.d.cts +8 -0
  13. package/dist/configs/default.d.cts.map +1 -0
  14. package/dist/configs/default.d.ts +9 -0
  15. package/dist/configs/default.d.ts.map +1 -0
  16. package/dist/configs/default.js +31 -0
  17. package/dist/configs/default.js.map +1 -0
  18. package/dist/definePreset-B6sruUgg.cjs +26 -0
  19. package/dist/definePreset-B6sruUgg.cjs.map +1 -0
  20. package/dist/definePreset-BufbSTvs.js +20 -0
  21. package/dist/definePreset-BufbSTvs.js.map +1 -0
  22. package/dist/index.cjs +11 -5
  23. package/dist/index.d.cts +18 -19
  24. package/dist/index.d.cts.map +1 -1
  25. package/dist/index.d.ts +18 -19
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -9
  28. package/dist/preset-DCOiMLaG.d.cts +37 -0
  29. package/dist/preset-DCOiMLaG.d.cts.map +1 -0
  30. package/dist/preset-DI2qdO9E.d.ts +37 -0
  31. package/dist/preset-DI2qdO9E.d.ts.map +1 -0
  32. package/dist/presets/default.cjs +4 -3
  33. package/dist/presets/default.cjs.map +1 -1
  34. package/dist/presets/default.d.cts +5 -2
  35. package/dist/presets/default.d.cts.map +1 -1
  36. package/dist/presets/default.d.ts +5 -2
  37. package/dist/presets/default.d.ts.map +1 -1
  38. package/dist/presets/default.js +4 -9
  39. package/dist/presets/default.js.map +1 -1
  40. package/dist/{defineConfig-BSVyAEFt.cjs → terminology-BJO_eqym.cjs} +11 -73
  41. package/dist/terminology-BJO_eqym.cjs.map +1 -0
  42. package/dist/terminology-BQqu0v3E.d.cts +16 -0
  43. package/dist/terminology-BQqu0v3E.d.cts.map +1 -0
  44. package/dist/terminology-CPBVBYUJ.d.ts +16 -0
  45. package/dist/terminology-CPBVBYUJ.d.ts.map +1 -0
  46. package/dist/terminology-CTuwYZjs.js +25 -0
  47. package/dist/terminology-CTuwYZjs.js.map +1 -0
  48. package/package.json +7 -8
  49. package/src/configs/default.test.ts +27 -0
  50. package/src/configs/default.ts +14 -0
  51. package/src/filters/allowlist.test.ts +41 -0
  52. package/src/filters/allowlist.ts +36 -0
  53. package/src/filters/comment.test.ts +20 -0
  54. package/src/filters/comment.ts +11 -0
  55. package/src/index.test.ts +17 -27
  56. package/src/index.ts +8 -4
  57. package/src/models/base.ts +29 -0
  58. package/src/models/config.ts +34 -30
  59. package/src/models/filter.ts +13 -0
  60. package/src/models/index.ts +6 -0
  61. package/src/models/plugin.ts +13 -0
  62. package/src/models/preset.ts +11 -0
  63. package/src/models/rule.ts +11 -32
  64. package/src/presets/default.test.ts +18 -0
  65. package/src/presets/default.ts +9 -9
  66. package/src/rules/terminology.test.ts +31 -0
  67. package/src/rules/terminology.ts +6 -9
  68. package/src/utils/defineConfig.test.ts +53 -0
  69. package/src/utils/defineConfig.ts +24 -37
  70. package/src/utils/defineFilter.test.ts +17 -0
  71. package/src/utils/defineFilter.ts +10 -0
  72. package/src/utils/definePreset.test.ts +33 -0
  73. package/src/utils/definePreset.ts +22 -0
  74. package/src/utils/defineRule.test.ts +21 -0
  75. package/src/utils/defineRule.ts +8 -0
  76. package/dist/config-CjR_suQD.d.cts +0 -34
  77. package/dist/config-CjR_suQD.d.cts.map +0 -1
  78. package/dist/config-KDNTBTCT.d.ts +0 -34
  79. package/dist/config-KDNTBTCT.d.ts.map +0 -1
  80. package/dist/defineConfig-BSVyAEFt.cjs.map +0 -1
  81. package/dist/defineConfig-Rcs53KN7.js +0 -100
  82. package/dist/defineConfig-Rcs53KN7.js.map +0 -1
  83. package/dist/index.js.map +0 -1
  84. package/src/rules/allowlist.ts +0 -27
  85. package/src/rules/comment.ts +0 -11
  86. package/src/rules/index.ts +0 -3
@@ -0,0 +1,37 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ //#region src/models/base.d.ts
3
+ type Severity = "error" | "warning" | "info";
4
+ type WithEnabled<T> = T | boolean;
5
+ type ObjectType = "preset" | "rule" | "filter" | "plugin";
6
+ type AnyObject = Record<string, any>;
7
+ type EmptyObject = Record<never, never>;
8
+ interface BaseObject<T extends ObjectType, N extends string> {
9
+ type: T;
10
+ name: N;
11
+ }
12
+ type AnyBaseObject = BaseObject<ObjectType, string>;
13
+ interface ExtendSeverity {
14
+ severity?: Severity;
15
+ }
16
+ type UserBase<RS extends AnyBaseObject[], T extends ObjectType, K extends keyof RS[number]> = { [R in RS[number] as R extends BaseObject<T, infer N> ? N : never]: K extends keyof R ? R[K] : R };
17
+ //#endregion
18
+ //#region src/models/rule.d.ts
19
+ type RuleModule = any;
20
+ interface Rule<N extends string, C extends AnyObject> extends BaseObject<"rule", N> {
21
+ module: RuleModule;
22
+ config: WithEnabled<C>;
23
+ }
24
+ type AnyRule = Rule<string, AnyObject>;
25
+ type UserRule<RS extends AnyRule[], K extends keyof AnyRule> = UserBase<RS, "rule", K>;
26
+ //#endregion
27
+ //#region src/models/preset.d.ts
28
+ interface Preset<N extends string, RS extends AnyRule[]> extends BaseObject<"preset", N> {
29
+ rules: UserRule<RS, "module">;
30
+ rulesConfig: UserRule<RS, "config">;
31
+ }
32
+ type AnyPreset = Preset<string, AnyRule[]>;
33
+ type UserPreset<RS extends AnyPreset[]> = RS[number]["rulesConfig"];
34
+ //#endregion
35
+ export { Rule as a, AnyBaseObject as c, EmptyObject as d, ExtendSeverity as f, WithEnabled as g, UserBase as h, AnyRule as i, AnyObject as l, Severity as m, Preset as n, RuleModule as o, ObjectType as p, UserPreset as r, UserRule as s, AnyPreset as t, BaseObject as u };
36
+ // Generated by @kcconfigs/tsdown
37
+ //# sourceMappingURL=preset-DI2qdO9E.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset-DI2qdO9E.d.ts","names":[],"sources":["../src/models/base.ts","../src/models/rule.ts","../src/models/preset.ts"],"mappings":";;KAAY,QAAA;AAAA,KAEA,WAAA,MAAiB,CAAA;AAAA,KAEjB,UAAA;AAAA,KAGA,SAAA,GAAY,MAAA;AAAA,KACZ,WAAA,GAAc,MAAA;AAAA,UAET,UAAA,WAAqB,UAAA;EACrC,IAAA,EAAM,CAAA;EACN,IAAA,EAAM,CAAA;AAAA;AAAA,KAEK,aAAA,GAAgB,UAAA,CAAW,UAAA;AAAA,UAEtB,cAAA;EAChB,QAAA,GAAW,QAAA;AAAA;AAAA,KAGA,QAAA,YACA,aAAA,cACD,UAAA,kBACM,EAAA,oBAEV,EAAA,YAAc,CAAA,SAAU,UAAA,CAAW,CAAA,aACtC,CAAA,WACQ,CAAA,eAAgB,CAAA,GAAI,CAAA,CAAE,CAAA,IAAK,CAAA;;;KCxB3B,UAAA;AAAA,UAEK,IAAA,6BAAiC,SAAA,UACzC,UAAA,SAAmB,CAAA;EAC3B,MAAA,EAAQ,UAAA;EACR,MAAA,EAAQ,WAAA,CAAY,CAAA;AAAA;AAAA,KAGT,OAAA,GAAU,IAAA,SAAa,SAAA;AAAA,KAEvB,QAAA,YAAoB,OAAA,oBAA2B,OAAA,IAAW,QAAA,CACrE,EAAA,UAEA,CAAA;;;UCbgB,MAAA,8BAAoC,OAAA,YAC5C,UAAA,WAAqB,CAAA;EAC7B,KAAA,EAAO,QAAA,CAAS,EAAA;EAChB,WAAA,EAAa,QAAA,CAAS,EAAA;AAAA;AAAA,KAEX,SAAA,GAAY,MAAA,SAAe,OAAA;AAAA,KAE3B,UAAA,YAAsB,SAAA,MAAe,EAAA"}
@@ -1,10 +1,11 @@
1
1
  // @generated by tsdown, DO NOT edit it manually
2
- const require_defineConfig = require('../defineConfig-BSVyAEFt.cjs');
2
+ const require_terminology = require('../terminology-BJO_eqym.cjs');
3
+ const require_definePreset = require('../definePreset-B6sruUgg.cjs');
3
4
 
4
5
  //#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;
6
+ const config = require_definePreset.definePreset("@kcconfigs/textlint/preset-default", require_terminology.terminology());
7
7
 
8
8
  //#endregion
9
+ module.exports = config;
9
10
  // Generated by @kcconfigs/tsdown
10
11
  //# sourceMappingURL=default.cjs.map
@@ -1 +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"}
1
+ {"version":3,"file":"default.cjs","names":["definePreset","terminology"],"sources":["../../src/presets/default.ts"],"sourcesContent":["import type { Preset } from \"../models\";\nimport { type TerminologyRule, terminology } from \"../rules/terminology\";\nimport { definePreset } from \"../utils/definePreset\";\n\nconst name = \"@kcconfigs/textlint/preset-default\";\n\ntype DefaultPreset = Preset<typeof name, [TerminologyRule]>;\n\nconst config: DefaultPreset = definePreset(name, terminology());\n\nexport default config;\n"],"mappings":";;;;;AAQA,MAAM,SAAwBA,kCAJjB,sCAIoCC,iCAAa,CAAC"}
@@ -1,8 +1,11 @@
1
1
  // @generated by tsdown, DO NOT edit it manually
2
- import { t as UserConfig } from "../config-CjR_suQD.cjs";
2
+ import { n as Preset } from "../preset-DCOiMLaG.cjs";
3
+ import { n as TerminologyRule } from "../terminology-BQqu0v3E.cjs";
3
4
 
4
5
  //#region src/presets/default.d.ts
5
- declare const config: UserConfig;
6
+ declare const name = "@kcconfigs/textlint/preset-default";
7
+ type DefaultPreset = Preset<typeof name, [TerminologyRule]>;
8
+ declare const config: DefaultPreset;
6
9
  export = config;
7
10
  // Generated by @kcconfigs/tsdown
8
11
  //# sourceMappingURL=default.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.cts","names":["config: UserConfig"],"sources":["../../src/presets/default.ts"],"sourcesContent":[],"mappings":";;;;cAIMA,QAAQ"}
1
+ {"version":3,"file":"default.d.cts","names":[],"sources":["../../src/presets/default.ts"],"mappings":";;;;;cAIM,IAAA;AAAA,KAED,aAAA,GAAgB,MAAA,QAAc,IAAA,GAAO,eAAA;AAAA,cAEpC,MAAA,EAAQ,aAAA;AAAA"}
@@ -1,8 +1,11 @@
1
1
  // @generated by tsdown, DO NOT edit it manually
2
- import { t as UserConfig } from "../config-KDNTBTCT.js";
2
+ import { n as Preset } from "../preset-DI2qdO9E.js";
3
+ import { n as TerminologyRule } from "../terminology-CPBVBYUJ.js";
3
4
 
4
5
  //#region src/presets/default.d.ts
5
- declare const config: UserConfig;
6
+ declare const name = "@kcconfigs/textlint/preset-default";
7
+ type DefaultPreset = Preset<typeof name, [TerminologyRule]>;
8
+ declare const config: DefaultPreset;
6
9
  //#endregion
7
10
  export { config as default };
8
11
  // Generated by @kcconfigs/tsdown
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","names":["config: UserConfig"],"sources":["../../src/presets/default.ts"],"sourcesContent":[],"mappings":";;;;cAIMA,QAAQ"}
1
+ {"version":3,"file":"default.d.ts","names":[],"sources":["../../src/presets/default.ts"],"mappings":";;;;;cAIM,IAAA;AAAA,KAED,aAAA,GAAgB,MAAA,QAAc,IAAA,GAAO,eAAA;AAAA,cAEpC,MAAA,EAAQ,aAAA"}
@@ -1,16 +1,11 @@
1
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";
2
+ import { t as terminology } from "../terminology-CTuwYZjs.js";
3
+ import { t as definePreset } from "../definePreset-BufbSTvs.js";
3
4
 
4
5
  //#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
- }));
6
+ const config = definePreset("@kcconfigs/textlint/preset-default", terminology());
11
7
 
12
8
  //#endregion
13
- export default require_default();
14
-
9
+ export { config as default };
15
10
  // Generated by @kcconfigs/tsdown
16
11
  //# sourceMappingURL=default.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"default.js","names":[],"sources":["../../src/presets/default.ts"],"sourcesContent":["import type { Preset } from \"../models\";\nimport { type TerminologyRule, terminology } from \"../rules/terminology\";\nimport { definePreset } from \"../utils/definePreset\";\n\nconst name = \"@kcconfigs/textlint/preset-default\";\n\ntype DefaultPreset = Preset<typeof name, [TerminologyRule]>;\n\nconst config: DefaultPreset = definePreset(name, terminology());\n\nexport default config;\n"],"mappings":";;;;;AAQA,MAAM,SAAwB,aAJjB,sCAIoC,aAAa,CAAC"}
@@ -1,5 +1,5 @@
1
1
  // @generated by tsdown, DO NOT edit it manually
2
- //#region rolldown:runtime
2
+ //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -29,91 +29,29 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  let textlint_rule_terminology = require("textlint-rule-terminology");
30
30
  textlint_rule_terminology = __toESM(textlint_rule_terminology);
31
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) => {
32
+ //#region src/utils/defineRule.ts
33
+ const defineRule = (rule) => {
52
34
  return {
53
- type: "filter",
54
- name: "comments",
55
- config: enabled
35
+ type: "rule",
36
+ ...rule
56
37
  };
57
38
  };
58
39
 
59
40
  //#endregion
60
41
  //#region src/rules/terminology.ts
61
42
  const terminology = (config) => {
62
- return {
63
- type: "rule",
43
+ return defineRule({
64
44
  name: "terminology",
65
45
  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
- };
46
+ config: config ?? true
47
+ });
98
48
  };
99
49
 
100
50
  //#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', {
51
+ Object.defineProperty(exports, 'defineRule', {
114
52
  enumerable: true,
115
53
  get: function () {
116
- return defineConfig;
54
+ return defineRule;
117
55
  }
118
56
  });
119
57
  Object.defineProperty(exports, 'terminology', {
@@ -123,4 +61,4 @@ Object.defineProperty(exports, 'terminology', {
123
61
  }
124
62
  });
125
63
  // Generated by @kcconfigs/tsdown
126
- //# sourceMappingURL=defineConfig-BSVyAEFt.cjs.map
64
+ //# sourceMappingURL=terminology-BJO_eqym.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminology-BJO_eqym.cjs","names":["terminologyModule"],"sources":["../src/utils/defineRule.ts","../src/rules/terminology.ts"],"sourcesContent":["import type { AnyRule } from \"../models\";\n\nexport const defineRule = <R extends AnyRule>(rule: Omit<R, \"type\">): R => {\n\treturn {\n\t\ttype: \"rule\",\n\t\t...rule,\n\t} as R;\n};\n","import terminologyModule from \"textlint-rule-terminology\";\nimport type { Rule } from \"../models\";\nimport { defineRule } from \"../utils/defineRule\";\n\nexport interface TerminologyConfig {\n\tdefaultTerms?: boolean;\n\tskip?: string[];\n\tterms?: string[];\n\texclude?: string[];\n}\n\nexport type TerminologyRule = Rule<\"terminology\", TerminologyConfig>;\n\nexport const terminology = (config?: TerminologyConfig): TerminologyRule => {\n\treturn defineRule({\n\t\tname: \"terminology\",\n\t\tmodule: terminologyModule,\n\t\tconfig: config ?? true,\n\t});\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,cAAiC,SAA6B;AAC1E,QAAO;EACN,MAAM;EACN,GAAG;EACH;;;;;ACOF,MAAa,eAAe,WAAgD;AAC3E,QAAO,WAAW;EACjB,MAAM;EACN,QAAQA;EACR,QAAQ,UAAU;EAClB,CAAC"}
@@ -0,0 +1,16 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ import { a as Rule } from "./preset-DCOiMLaG.cjs";
3
+
4
+ //#region src/rules/terminology.d.ts
5
+ interface TerminologyConfig {
6
+ defaultTerms?: boolean;
7
+ skip?: string[];
8
+ terms?: string[];
9
+ exclude?: string[];
10
+ }
11
+ type TerminologyRule = Rule<"terminology", TerminologyConfig>;
12
+ declare const terminology: (config?: TerminologyConfig) => TerminologyRule;
13
+ //#endregion
14
+ export { TerminologyRule as n, terminology as r, TerminologyConfig as t };
15
+ // Generated by @kcconfigs/tsdown
16
+ //# sourceMappingURL=terminology-BQqu0v3E.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminology-BQqu0v3E.d.cts","names":[],"sources":["../src/rules/terminology.ts"],"mappings":";;;;UAIiB,iBAAA;EAChB,YAAA;EACA,IAAA;EACA,KAAA;EACA,OAAA;AAAA;AAAA,KAGW,eAAA,GAAkB,IAAA,gBAAoB,iBAAA;AAAA,cAErC,WAAA,GAAe,MAAA,GAAS,iBAAA,KAAoB,eAAA"}
@@ -0,0 +1,16 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ import { a as Rule } from "./preset-DI2qdO9E.js";
3
+
4
+ //#region src/rules/terminology.d.ts
5
+ interface TerminologyConfig {
6
+ defaultTerms?: boolean;
7
+ skip?: string[];
8
+ terms?: string[];
9
+ exclude?: string[];
10
+ }
11
+ type TerminologyRule = Rule<"terminology", TerminologyConfig>;
12
+ declare const terminology: (config?: TerminologyConfig) => TerminologyRule;
13
+ //#endregion
14
+ export { TerminologyRule as n, terminology as r, TerminologyConfig as t };
15
+ // Generated by @kcconfigs/tsdown
16
+ //# sourceMappingURL=terminology-CPBVBYUJ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminology-CPBVBYUJ.d.ts","names":[],"sources":["../src/rules/terminology.ts"],"mappings":";;;;UAIiB,iBAAA;EAChB,YAAA;EACA,IAAA;EACA,KAAA;EACA,OAAA;AAAA;AAAA,KAGW,eAAA,GAAkB,IAAA,gBAAoB,iBAAA;AAAA,cAErC,WAAA,GAAe,MAAA,GAAS,iBAAA,KAAoB,eAAA"}
@@ -0,0 +1,25 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ import terminologyModule from "textlint-rule-terminology";
3
+
4
+ //#region src/utils/defineRule.ts
5
+ const defineRule = (rule) => {
6
+ return {
7
+ type: "rule",
8
+ ...rule
9
+ };
10
+ };
11
+
12
+ //#endregion
13
+ //#region src/rules/terminology.ts
14
+ const terminology = (config) => {
15
+ return defineRule({
16
+ name: "terminology",
17
+ module: terminologyModule,
18
+ config: config ?? true
19
+ });
20
+ };
21
+
22
+ //#endregion
23
+ export { defineRule as n, terminology as t };
24
+ // Generated by @kcconfigs/tsdown
25
+ //# sourceMappingURL=terminology-CTuwYZjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminology-CTuwYZjs.js","names":[],"sources":["../src/utils/defineRule.ts","../src/rules/terminology.ts"],"sourcesContent":["import type { AnyRule } from \"../models\";\n\nexport const defineRule = <R extends AnyRule>(rule: Omit<R, \"type\">): R => {\n\treturn {\n\t\ttype: \"rule\",\n\t\t...rule,\n\t} as R;\n};\n","import terminologyModule from \"textlint-rule-terminology\";\nimport type { Rule } from \"../models\";\nimport { defineRule } from \"../utils/defineRule\";\n\nexport interface TerminologyConfig {\n\tdefaultTerms?: boolean;\n\tskip?: string[];\n\tterms?: string[];\n\texclude?: string[];\n}\n\nexport type TerminologyRule = Rule<\"terminology\", TerminologyConfig>;\n\nexport const terminology = (config?: TerminologyConfig): TerminologyRule => {\n\treturn defineRule({\n\t\tname: \"terminology\",\n\t\tmodule: terminologyModule,\n\t\tconfig: config ?? true,\n\t});\n};\n"],"mappings":";;;;AAEA,MAAa,cAAiC,SAA6B;AAC1E,QAAO;EACN,MAAM;EACN,GAAG;EACH;;;;;ACOF,MAAa,eAAe,WAAgD;AAC3E,QAAO,WAAW;EACjB,MAAM;EACN,QAAQ;EACR,QAAQ,UAAU;EAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kcconfigs/textlint",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0",
4
4
  "description": "Shared textlint rule configuration",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -9,14 +9,13 @@
9
9
  "textlint-rule-terminology": "5.2.16"
10
10
  },
11
11
  "devDependencies": {
12
- "@biomejs/biome": "2.3.10",
13
- "textlint": "15.5.0",
14
- "tsdown": "0.18.4",
12
+ "@biomejs/biome": "2.4.6",
13
+ "tsdown": "0.20.3",
15
14
  "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"
15
+ "@kcconfigs/biome": "0.2.2",
16
+ "@kcconfigs/tsconfig": "0.1.1",
17
+ "@kcconfigs/tsdown": "0.1.1-beta.3",
18
+ "@kcconfigs/vitest": "0.1.1-beta.2"
20
19
  },
21
20
  "peerDependencies": {
22
21
  "textlint": "^15.0.0"
@@ -0,0 +1,27 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import defaultConfig from "./default";
3
+
4
+ describe("default config", () => {
5
+ test("should compose the package default textlint config", () => {
6
+ expect(defaultConfig).toEqual({
7
+ plugins: [],
8
+ filters: [
9
+ {
10
+ type: "filter",
11
+ name: "comments",
12
+ config: true,
13
+ },
14
+ {
15
+ type: "filter",
16
+ name: "allowlist",
17
+ config: {
18
+ allow: [""],
19
+ },
20
+ },
21
+ ],
22
+ rules: {
23
+ terminology: true,
24
+ },
25
+ });
26
+ });
27
+ });
@@ -0,0 +1,14 @@
1
+ import { allowlist } from "../filters/allowlist";
2
+ import { comments } from "../filters/comment";
3
+ import type { AnyUserConfig } from "../models";
4
+ import { terminology } from "../rules/terminology";
5
+ import { defineConfig } from "../utils/defineConfig";
6
+
7
+ const config: AnyUserConfig = defineConfig({
8
+ presets: [],
9
+ rules: [terminology()],
10
+ filters: [comments(), allowlist({ allow: [""] })],
11
+ plugins: [],
12
+ });
13
+
14
+ export default config;
@@ -0,0 +1,41 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { allowlist, DEFAULT_ALLOWLIST } from "./allowlist";
3
+
4
+ describe(allowlist.name, () => {
5
+ test("should disable the filter when no config is provided", () => {
6
+ expect(allowlist()).toEqual({
7
+ type: "filter",
8
+ name: "allowlist",
9
+ config: false,
10
+ });
11
+ });
12
+
13
+ test("should apply the default allow list when allow is omitted", () => {
14
+ expect(
15
+ allowlist({
16
+ allowlistConfigPaths: ["./allowlist.txt"],
17
+ }),
18
+ ).toEqual({
19
+ type: "filter",
20
+ name: "allowlist",
21
+ config: {
22
+ allow: DEFAULT_ALLOWLIST,
23
+ allowlistConfigPaths: ["./allowlist.txt"],
24
+ },
25
+ });
26
+ });
27
+
28
+ test("should preserve an explicit allow list", () => {
29
+ expect(
30
+ allowlist({
31
+ allow: ["bun", "pnpm"],
32
+ }),
33
+ ).toEqual({
34
+ type: "filter",
35
+ name: "allowlist",
36
+ config: {
37
+ allow: ["bun", "pnpm"],
38
+ },
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,36 @@
1
+ import type { Filter } from "../models";
2
+ import { defineFilter } from "../utils/defineFilter";
3
+
4
+ export interface AllowListConfig {
5
+ allow?: string[];
6
+ allowlistConfigPaths?: string[];
7
+ }
8
+
9
+ export const DEFAULT_ALLOWLIST: string[] = [
10
+ "editorconfig",
11
+ "url",
12
+ "html",
13
+ "api",
14
+ "apis",
15
+ "github",
16
+ "typescript",
17
+ "json",
18
+ ];
19
+
20
+ export type AllowListRule = Filter<"allowlist", AllowListConfig>;
21
+
22
+ export const allowlist = (config?: AllowListConfig): AllowListRule => {
23
+ const name = "allowlist";
24
+ if (!config) {
25
+ return defineFilter({
26
+ name,
27
+ config: false,
28
+ });
29
+ }
30
+
31
+ if (!config.allow) config.allow = DEFAULT_ALLOWLIST;
32
+ return defineFilter({
33
+ name,
34
+ config,
35
+ });
36
+ };
@@ -0,0 +1,20 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { comments } from "./comment";
3
+
4
+ describe(comments.name, () => {
5
+ test("should enable the filter by default", () => {
6
+ expect(comments()).toEqual({
7
+ type: "filter",
8
+ name: "comments",
9
+ config: true,
10
+ });
11
+ });
12
+
13
+ test("should allow disabling the filter", () => {
14
+ expect(comments(false)).toEqual({
15
+ type: "filter",
16
+ name: "comments",
17
+ config: false,
18
+ });
19
+ });
20
+ });
@@ -0,0 +1,11 @@
1
+ import type { EmptyObject, Filter } from "../models";
2
+ import { defineFilter } from "../utils/defineFilter";
3
+
4
+ export type CommentRule = Filter<"comments", EmptyObject>;
5
+
6
+ export const comments = (enabled = true): CommentRule => {
7
+ return defineFilter({
8
+ name: "comments",
9
+ config: enabled,
10
+ });
11
+ };
package/src/index.test.ts CHANGED
@@ -1,35 +1,25 @@
1
1
  import { describe, expect, test } from "vitest";
2
- import { multiply } from ".";
2
+ import * as exports from "./index";
3
3
 
4
- describe(multiply.name, () => {
5
- test("should multiply two numbers correctly", () => {
6
- expect(multiply(3, 4)).toBe(12);
4
+ describe("index exports", () => {
5
+ test("should export filter factories", () => {
6
+ expect(exports.allowlist).toBeDefined();
7
+ expect(typeof exports.allowlist).toBe("function");
8
+ expect(exports.comments).toBeDefined();
9
+ expect(typeof exports.comments).toBe("function");
7
10
  });
8
11
 
9
- test("should handle negative numbers", () => {
10
- expect(multiply(-2, 5)).toBe(-10);
12
+ test("should export rule factories", () => {
13
+ expect(exports.terminology).toBeDefined();
14
+ expect(typeof exports.terminology).toBe("function");
11
15
  });
12
16
 
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);
17
+ test("should export helper factories", () => {
18
+ expect(exports.defineFilter).toBeDefined();
19
+ expect(typeof exports.defineFilter).toBe("function");
20
+ expect(exports.definePreset).toBeDefined();
21
+ expect(typeof exports.definePreset).toBe("function");
22
+ expect(exports.defineRule).toBeDefined();
23
+ expect(typeof exports.defineRule).toBe("function");
34
24
  });
35
25
  });
package/src/index.ts CHANGED
@@ -1,6 +1,10 @@
1
- export type * from "./models/config";
2
- export type * from "./models/rule";
1
+ export * from "./filters/allowlist";
2
+ export * from "./filters/comment";
3
3
 
4
- export * from "./rules";
4
+ export type * from "./models";
5
5
 
6
- export * from "./utils/defineConfig";
6
+ export * from "./rules/terminology";
7
+
8
+ export * from "./utils/defineFilter";
9
+ export * from "./utils/definePreset";
10
+ export * from "./utils/defineRule";
@@ -0,0 +1,29 @@
1
+ export type Severity = "error" | "warning" | "info";
2
+
3
+ export type WithEnabled<T> = T | boolean;
4
+
5
+ export type ObjectType = "preset" | "rule" | "filter" | "plugin";
6
+
7
+ // biome-ignore lint/suspicious/noExplicitAny: Any object type
8
+ export type AnyObject = Record<string, any>;
9
+ export type EmptyObject = Record<never, never>;
10
+
11
+ export interface BaseObject<T extends ObjectType, N extends string> {
12
+ type: T;
13
+ name: N;
14
+ }
15
+ export type AnyBaseObject = BaseObject<ObjectType, string>;
16
+
17
+ export interface ExtendSeverity {
18
+ severity?: Severity;
19
+ }
20
+
21
+ export type UserBase<
22
+ RS extends AnyBaseObject[],
23
+ T extends ObjectType,
24
+ K extends keyof RS[number],
25
+ > = {
26
+ [R in RS[number] as R extends BaseObject<T, infer N>
27
+ ? N
28
+ : never]: K extends keyof R ? R[K] : R;
29
+ };