@markuplint/types 1.0.0-dev.20211213.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 (177) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/extends.json +12 -0
  4. package/gen/specific-schema.json +98 -0
  5. package/gen/types.ts +66 -0
  6. package/lib/check-multi-types.d.ts +2 -0
  7. package/lib/check-multi-types.js +29 -0
  8. package/lib/check.d.ts +8 -0
  9. package/lib/check.js +49 -0
  10. package/lib/check.spec.d.ts +1 -0
  11. package/lib/check.spec.js +57 -0
  12. package/lib/css-syntax.d.ts +2 -0
  13. package/lib/css-syntax.js +141 -0
  14. package/lib/css-syntax.spec.d.ts +1 -0
  15. package/lib/css-syntax.spec.js +157 -0
  16. package/lib/debug.d.ts +2 -0
  17. package/lib/debug.js +6 -0
  18. package/lib/defs.d.ts +3 -0
  19. package/lib/defs.js +752 -0
  20. package/lib/enum.d.ts +3 -0
  21. package/lib/enum.js +26 -0
  22. package/lib/get-candicate.d.ts +3 -0
  23. package/lib/get-candicate.js +26 -0
  24. package/lib/index.d.ts +3 -0
  25. package/lib/index.js +6 -0
  26. package/lib/keyword-type.d.ts +3 -0
  27. package/lib/keyword-type.js +46 -0
  28. package/lib/list.d.ts +3 -0
  29. package/lib/list.js +29 -0
  30. package/lib/list.spec.d.ts +1 -0
  31. package/lib/list.spec.js +129 -0
  32. package/lib/match-result.d.ts +9 -0
  33. package/lib/match-result.js +33 -0
  34. package/lib/number.d.ts +3 -0
  35. package/lib/number.js +41 -0
  36. package/lib/primitive/index.d.ts +7 -0
  37. package/lib/primitive/index.js +17 -0
  38. package/lib/primitive/index.spec.d.ts +1 -0
  39. package/lib/primitive/index.spec.js +62 -0
  40. package/lib/primitive/is-float.d.ts +6 -0
  41. package/lib/primitive/is-float.js +12 -0
  42. package/lib/primitive/is-int.d.ts +6 -0
  43. package/lib/primitive/is-int.js +12 -0
  44. package/lib/primitive/is-non-zero-uint.d.ts +6 -0
  45. package/lib/primitive/is-non-zero-uint.js +12 -0
  46. package/lib/primitive/is-quantity.d.ts +7 -0
  47. package/lib/primitive/is-quantity.js +41 -0
  48. package/lib/primitive/is-uint.d.ts +8 -0
  49. package/lib/primitive/is-uint.js +19 -0
  50. package/lib/primitive/range.d.ts +8 -0
  51. package/lib/primitive/range.js +18 -0
  52. package/lib/primitive/split-unit.d.ts +9 -0
  53. package/lib/primitive/split-unit.js +24 -0
  54. package/lib/rfc/is-bcp-47.d.ts +5 -0
  55. package/lib/rfc/is-bcp-47.js +14 -0
  56. package/lib/rfc/is-bcp-47.spec.d.ts +1 -0
  57. package/lib/rfc/is-bcp-47.spec.js +19 -0
  58. package/lib/token/index.d.ts +2 -0
  59. package/lib/token/index.js +7 -0
  60. package/lib/token/token-collection.d.ts +62 -0
  61. package/lib/token/token-collection.js +383 -0
  62. package/lib/token/token-collection.spec.d.ts +1 -0
  63. package/lib/token/token-collection.spec.js +144 -0
  64. package/lib/token/token.d.ts +55 -0
  65. package/lib/token/token.js +128 -0
  66. package/lib/types.d.ts +78 -0
  67. package/lib/types.js +2 -0
  68. package/lib/types.schema.d.ts +54 -0
  69. package/lib/types.schema.js +8 -0
  70. package/lib/w3c/check-serialized-permissions-policy.d.ts +15 -0
  71. package/lib/w3c/check-serialized-permissions-policy.js +251 -0
  72. package/lib/w3c/check-serialized-permissions-policy.spec.d.ts +1 -0
  73. package/lib/w3c/check-serialized-permissions-policy.spec.js +26 -0
  74. package/lib/whatwg/check-autocomplete.d.ts +5 -0
  75. package/lib/whatwg/check-autocomplete.js +282 -0
  76. package/lib/whatwg/check-autocomplete.spec.d.ts +1 -0
  77. package/lib/whatwg/check-autocomplete.spec.js +370 -0
  78. package/lib/whatwg/check-datetime/date-string.d.ts +5 -0
  79. package/lib/whatwg/check-datetime/date-string.js +31 -0
  80. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +3 -0
  81. package/lib/whatwg/check-datetime/datetime-tokens.js +509 -0
  82. package/lib/whatwg/check-datetime/duration-string.d.ts +6 -0
  83. package/lib/whatwg/check-datetime/duration-string.js +322 -0
  84. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +5 -0
  85. package/lib/whatwg/check-datetime/global-date-and-time-string.js +66 -0
  86. package/lib/whatwg/check-datetime/index.d.ts +5 -0
  87. package/lib/whatwg/check-datetime/index.js +35 -0
  88. package/lib/whatwg/check-datetime/index.spec.d.ts +1 -0
  89. package/lib/whatwg/check-datetime/index.spec.js +318 -0
  90. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +9 -0
  91. package/lib/whatwg/check-datetime/local-date-and-time-string.js +116 -0
  92. package/lib/whatwg/check-datetime/month-string.d.ts +5 -0
  93. package/lib/whatwg/check-datetime/month-string.js +20 -0
  94. package/lib/whatwg/check-datetime/time-string.d.ts +5 -0
  95. package/lib/whatwg/check-datetime/time-string.js +35 -0
  96. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +7 -0
  97. package/lib/whatwg/check-datetime/time-zone-offset-string.js +75 -0
  98. package/lib/whatwg/check-datetime/week-string.d.ts +5 -0
  99. package/lib/whatwg/check-datetime/week-string.js +29 -0
  100. package/lib/whatwg/check-datetime/year-string.d.ts +5 -0
  101. package/lib/whatwg/check-datetime/year-string.js +20 -0
  102. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +5 -0
  103. package/lib/whatwg/check-datetime/yearless-date-string.js +27 -0
  104. package/lib/whatwg/check-mime-type.d.ts +11 -0
  105. package/lib/whatwg/check-mime-type.js +42 -0
  106. package/lib/whatwg/check-mime-type.spec.d.ts +1 -0
  107. package/lib/whatwg/check-mime-type.spec.js +58 -0
  108. package/lib/whatwg/is-abs-url.d.ts +15 -0
  109. package/lib/whatwg/is-abs-url.js +34 -0
  110. package/lib/whatwg/is-abs-url.spec.d.ts +1 -0
  111. package/lib/whatwg/is-abs-url.spec.js +8 -0
  112. package/lib/whatwg/is-browser-context-name.d.ts +11 -0
  113. package/lib/whatwg/is-browser-context-name.js +18 -0
  114. package/lib/whatwg/is-custom-element-name.d.ts +22 -0
  115. package/lib/whatwg/is-custom-element-name.js +77 -0
  116. package/lib/whatwg/is-itemprop-name.d.ts +12 -0
  117. package/lib/whatwg/is-itemprop-name.js +19 -0
  118. package/package.json +33 -0
  119. package/src/check-multi-types.ts +35 -0
  120. package/src/check.spec.ts +62 -0
  121. package/src/check.ts +48 -0
  122. package/src/css-syntax.spec.ts +167 -0
  123. package/src/css-syntax.ts +177 -0
  124. package/src/debug.ts +3 -0
  125. package/src/defs.ts +810 -0
  126. package/src/enum.ts +25 -0
  127. package/src/get-candicate.ts +24 -0
  128. package/src/index.ts +3 -0
  129. package/src/keyword-type.ts +52 -0
  130. package/src/list.spec.ts +133 -0
  131. package/src/list.ts +34 -0
  132. package/src/match-result.ts +49 -0
  133. package/src/number.ts +46 -0
  134. package/src/primitive/index.spec.ts +65 -0
  135. package/src/primitive/index.ts +7 -0
  136. package/src/primitive/is-float.ts +8 -0
  137. package/src/primitive/is-int.ts +8 -0
  138. package/src/primitive/is-non-zero-uint.ts +8 -0
  139. package/src/primitive/is-quantity.ts +38 -0
  140. package/src/primitive/is-uint.ts +15 -0
  141. package/src/primitive/range.ts +14 -0
  142. package/src/primitive/split-unit.ts +20 -0
  143. package/src/rfc/is-bcp-47.spec.ts +23 -0
  144. package/src/rfc/is-bcp-47.ts +13 -0
  145. package/src/token/index.ts +2 -0
  146. package/src/token/token-collection.spec.ts +147 -0
  147. package/src/token/token-collection.ts +444 -0
  148. package/src/token/token.ts +144 -0
  149. package/src/types.schema.ts +1059 -0
  150. package/src/types.ts +118 -0
  151. package/src/w3c/check-serialized-permissions-policy.spec.ts +27 -0
  152. package/src/w3c/check-serialized-permissions-policy.ts +287 -0
  153. package/src/whatwg/check-autocomplete.spec.ts +378 -0
  154. package/src/whatwg/check-autocomplete.ts +324 -0
  155. package/src/whatwg/check-datetime/date-string.ts +44 -0
  156. package/src/whatwg/check-datetime/datetime-tokens.ts +600 -0
  157. package/src/whatwg/check-datetime/duration-string.ts +399 -0
  158. package/src/whatwg/check-datetime/global-date-and-time-string.ts +96 -0
  159. package/src/whatwg/check-datetime/index.spec.ts +333 -0
  160. package/src/whatwg/check-datetime/index.ts +36 -0
  161. package/src/whatwg/check-datetime/local-date-and-time-string.ts +163 -0
  162. package/src/whatwg/check-datetime/month-string.ts +31 -0
  163. package/src/whatwg/check-datetime/time-string.ts +49 -0
  164. package/src/whatwg/check-datetime/time-zone-offset-string.ts +93 -0
  165. package/src/whatwg/check-datetime/week-string.ts +41 -0
  166. package/src/whatwg/check-datetime/year-string.ts +26 -0
  167. package/src/whatwg/check-datetime/yearless-date-string.ts +38 -0
  168. package/src/whatwg/check-mime-type.spec.ts +59 -0
  169. package/src/whatwg/check-mime-type.ts +46 -0
  170. package/src/whatwg/is-abs-url.spec.ts +8 -0
  171. package/src/whatwg/is-abs-url.ts +31 -0
  172. package/src/whatwg/is-browser-context-name.ts +16 -0
  173. package/src/whatwg/is-custom-element-name.ts +76 -0
  174. package/src/whatwg/is-itemprop-name.ts +17 -0
  175. package/tsconfig.test.json +3 -0
  176. package/tsconfig.tsbuildinfo +1 -0
  177. package/types.schema.json +1092 -0
@@ -0,0 +1,167 @@
1
+ import type { CustomCssSyntax } from './types';
2
+
3
+ import { cssSyntaxMatch } from './css-syntax';
4
+
5
+ test('CSS Standard', () => {
6
+ expect(cssSyntaxMatch('10px', '<length>').matched).toBe(true);
7
+ expect(cssSyntaxMatch('one-pixel', '<length>').matched).toBe(false);
8
+ expect(cssSyntaxMatch('(prefers-color-scheme: dark)', '<media-query-list>').matched).toBe(true);
9
+ });
10
+
11
+ test('Extends', () => {
12
+ const sourceSizeList: CustomCssSyntax = {
13
+ ref: 'https://html.spec.whatwg.org/multipage/images.html#sizes-attributes',
14
+ syntax: {
15
+ apply: '<source-size-list>',
16
+ def: {
17
+ 'source-size-list': '[ <source-size># , ]? <source-size-value>',
18
+ 'source-size': '<media-condition> <source-size-value>',
19
+ 'source-size-value': '<length>',
20
+ },
21
+ },
22
+ };
23
+ expect(cssSyntaxMatch('50vw', sourceSizeList).matched).toBe(true);
24
+ expect(cssSyntaxMatch('(max-width: 600px) 200px, 50vw', sourceSizeList).matched).toBe(true);
25
+ expect(cssSyntaxMatch('print 300vw', sourceSizeList).matched).toBe(false);
26
+ expect(cssSyntaxMatch('(max-width: 600px) 200px', sourceSizeList).matched).toBe(false);
27
+ expect(
28
+ cssSyntaxMatch('(max-width: 600px) 200px', {
29
+ ...sourceSizeList,
30
+ syntax: {
31
+ ...sourceSizeList.syntax,
32
+ apply: '<source-size>',
33
+ },
34
+ }).matched,
35
+ ).toBe(true);
36
+
37
+ const keyTimes: CustomCssSyntax = {
38
+ ref: 'https://svgwg.org/specs/animations/#KeyTimesAttribute',
39
+ syntax: {
40
+ apply: '<key-times>',
41
+ def: {
42
+ 'key-times': '<number> [; <number>]* [;]?',
43
+ },
44
+ },
45
+ };
46
+ expect(cssSyntaxMatch('20; 20; 30', keyTimes).matched).toBe(true);
47
+ expect(cssSyntaxMatch('20; 20; 30;', keyTimes).matched).toBe(true);
48
+ expect(cssSyntaxMatch('20; 20; abc;', keyTimes).matched).toBe(false);
49
+ expect(cssSyntaxMatch('20; 20; ;', keyTimes).matched).toBe(false);
50
+
51
+ const SVGViewBox: CustomCssSyntax = {
52
+ ref: 'https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute',
53
+ syntax: {
54
+ apply: '<view-box>',
55
+ def: {
56
+ 'view-box': '<min-x> [,]? <min-y> [,]? <width> [,]? <height>',
57
+ 'min-x': '<number>',
58
+ 'min-y': '<number>',
59
+ width: '<number>',
60
+ height: '<number>',
61
+ },
62
+ },
63
+ };
64
+ expect(cssSyntaxMatch('0 0 30 10', SVGViewBox).matched).toBe(true);
65
+ expect(cssSyntaxMatch('0 0, 30, 10', SVGViewBox).matched).toBe(true);
66
+ expect(cssSyntaxMatch('0 0, 30', SVGViewBox).matched).toBe(false);
67
+
68
+ const percentageList: CustomCssSyntax = {
69
+ ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage',
70
+ syntax: {
71
+ apply: '<percentage-list>',
72
+ def: {
73
+ 'percentage-list': '[ <number> [,]? ]* <number>',
74
+ },
75
+ },
76
+ };
77
+ expect(cssSyntaxMatch('0 0 30 10', percentageList).matched).toBe(true);
78
+ expect(cssSyntaxMatch('0, 0, 30 10', percentageList).matched).toBe(true);
79
+ expect(cssSyntaxMatch('0', percentageList).matched).toBe(true);
80
+ expect(cssSyntaxMatch('', percentageList).matched).toBe(false);
81
+
82
+ const custom: CustomCssSyntax = {
83
+ ref: 'n/a',
84
+ syntax: {
85
+ apply: '<custom>',
86
+ def: {
87
+ custom: '0 | 1 | .',
88
+ },
89
+ },
90
+ };
91
+ expect(cssSyntaxMatch('0', custom).matched).toBe(true);
92
+ expect(cssSyntaxMatch('1', custom).matched).toBe(true);
93
+ expect(cssSyntaxMatch('.', custom).matched).toBe(true);
94
+ expect(cssSyntaxMatch('2', custom).matched).toBe(false);
95
+ expect(cssSyntaxMatch(':', custom).matched).toBe(false);
96
+ });
97
+
98
+ test('custom-type-checking', () => {
99
+ const custom: CustomCssSyntax = {
100
+ ref: 'n/a',
101
+ caseSensitive: true,
102
+ syntax: {
103
+ apply: '<custom>',
104
+ def: {
105
+ custom: '<custom-type>',
106
+ 'custom-type': token => {
107
+ if (!token) {
108
+ return 0;
109
+ }
110
+ return token.value === '1' ? 1 : 0;
111
+ },
112
+ },
113
+ },
114
+ };
115
+ expect(cssSyntaxMatch('1', custom).matched).toBe(true);
116
+ expect(cssSyntaxMatch('0', custom).matched).toBe(false);
117
+ });
118
+
119
+ test('case-sensivite', () => {
120
+ const custom: CustomCssSyntax = {
121
+ ref: 'n/a',
122
+ caseSensitive: true,
123
+ syntax: {
124
+ apply: '<custom>',
125
+ def: {
126
+ custom: 'CaSeS [a | B | aBc]',
127
+ },
128
+ },
129
+ };
130
+ expect(cssSyntaxMatch('CaSeS a', custom).matched).toBe(true);
131
+ expect(cssSyntaxMatch('CaSeS B', custom).matched).toBe(true);
132
+ expect(cssSyntaxMatch('CaSeS aBc', custom).matched).toBe(true);
133
+ expect(cssSyntaxMatch('CaSeS A', custom)).toStrictEqual({
134
+ column: 7,
135
+ line: 1,
136
+ matched: false,
137
+ length: 1,
138
+ offset: 6,
139
+ partName: 'value',
140
+ raw: 'A',
141
+ reason: 'syntax-error',
142
+ ref: 'n/a',
143
+ expects: [
144
+ {
145
+ type: 'syntax',
146
+ value: 'CaSeS [ a | B | aBc ]',
147
+ },
148
+ ],
149
+ });
150
+ expect(cssSyntaxMatch('CaSeS abc', custom)).toStrictEqual({
151
+ column: 7,
152
+ line: 1,
153
+ matched: false,
154
+ length: 3,
155
+ offset: 6,
156
+ partName: 'value',
157
+ raw: 'abc',
158
+ reason: 'syntax-error',
159
+ ref: 'n/a',
160
+ expects: [
161
+ {
162
+ type: 'syntax',
163
+ value: 'CaSeS [ a | B | aBc ]',
164
+ },
165
+ ],
166
+ });
167
+ });
@@ -0,0 +1,177 @@
1
+ import type { CustomCssSyntax, CssSyntaxTokenizer, CSSSyntaxToken, GetNextToken, Result, CssSyntax } from './types';
2
+
3
+ // @ts-ignore
4
+ import csstree from 'css-tree';
5
+ // @ts-ignore
6
+ import { SyntaxMatchError } from 'css-tree/lib/lexer/error.js';
7
+ // @ts-ignore
8
+ import { matchAsTree } from 'css-tree/lib/lexer/match.js';
9
+ // @ts-ignore
10
+ import prepareTokens from 'css-tree/lib/lexer/prepare-tokens.js';
11
+
12
+ import { log } from './debug';
13
+ import { tokenizers } from './defs';
14
+ import { matched } from './match-result';
15
+
16
+ // eslint-disable-next-line no-redeclare
17
+ interface SyntaxMatchError {
18
+ message: string;
19
+ rawMessage: 'Mismatch';
20
+ syntax: string;
21
+ css: string;
22
+ mismatchOffset: number;
23
+ mismatchLength: number;
24
+ offset: number;
25
+ line: number;
26
+ column: number;
27
+ loc: {
28
+ source: '<unknown>';
29
+ start: { offset: number; line: number; column: number };
30
+ end: { offset: number; line: number; column: number };
31
+ };
32
+ }
33
+
34
+ export function cssSyntaxMatch(value: string, type: CssSyntax | CustomCssSyntax): Result {
35
+ const origin = value;
36
+ let defName: `<${string}>`;
37
+ const typesExtended: Record<string, string> = {};
38
+ const typesCheckers: Record<string, CssSyntaxTokenizer> = {};
39
+ let propsExtended: Record<string, string>;
40
+ let ref: string | undefined = undefined;
41
+ let caseSensitive = false;
42
+ let ebnf: Record<string, string | string[]> | null = null;
43
+
44
+ if (typeof type === 'string') {
45
+ defName = type;
46
+ propsExtended = {};
47
+ } else {
48
+ defName = type.syntax.apply;
49
+ ebnf = type.syntax.ebnf || null;
50
+
51
+ if (ebnf) {
52
+ // Work in progress
53
+ return matched();
54
+ }
55
+
56
+ const types = {
57
+ ...tokenizers,
58
+ ...type.syntax.def,
59
+ };
60
+ Object.keys(types).forEach(key => {
61
+ const valueOrChecker = types[key];
62
+ if (typeof valueOrChecker === 'string') {
63
+ typesExtended[key] = valueOrChecker;
64
+ } else {
65
+ typesCheckers[key] = valueOrChecker;
66
+ }
67
+ });
68
+ propsExtended = { ...type.syntax.properties };
69
+ if (type.caseSensitive) {
70
+ caseSensitive = true;
71
+ Object.keys(typesExtended).forEach(key => eachMimicCases(key, typesExtended));
72
+ Object.keys(propsExtended).forEach(key => eachMimicCases(key, propsExtended));
73
+ value = mimicCases(value);
74
+ }
75
+ ref = type.ref;
76
+ }
77
+
78
+ // @ts-ignore
79
+ const lexer = csstree.fork({
80
+ types: typesExtended,
81
+ properties: propsExtended,
82
+ }).lexer;
83
+
84
+ Object.keys(typesCheckers).forEach(key => {
85
+ const checker = typesCheckers[key];
86
+ lexer.addType_(key, (token: CSSSyntaxToken, getNextToken: GetNextToken) =>
87
+ checker(token, getNextToken, cssSyntaxMatch),
88
+ );
89
+ });
90
+
91
+ const { isProp, name, matcher } = defToMatcher(lexer, defName);
92
+ const refParam = isProp ? 'Property' : 'Type';
93
+ ref = ref || `https://csstree.github.io/docs/syntax/#${refParam}:${name}`;
94
+
95
+ // eslint-disable-next-line no-console
96
+ const _w = console.warn;
97
+ // eslint-disable-next-line no-console
98
+ console.warn = warn => log('WARNING: %s (by %s => %s)', warn, value, type);
99
+
100
+ const tokens = prepareTokens(value, lexer.syntax);
101
+ const result = matchAsTree(tokens, matcher.match, lexer);
102
+
103
+ if (caseSensitive) {
104
+ if (result.tokens && Array.isArray(result.tokens)) {
105
+ let reducer = 0;
106
+ result.tokens = result.tokens.map((token: CSSSyntaxToken) => {
107
+ const value = token.value;
108
+ const originValue = deMimicCases(value || '');
109
+ const isMimiced = value !== originValue;
110
+ reducer += isMimiced ? 'mimiccases------mimiccases'.length : 0;
111
+ token.value = originValue;
112
+ token.balance = token.balance - reducer;
113
+ return token;
114
+ });
115
+ }
116
+ }
117
+
118
+ log('css-tree/result: %O', result);
119
+ // eslint-disable-next-line no-console
120
+ console.warn = _w;
121
+
122
+ if (result.match) {
123
+ log('css-tree/result.match: %s', JSON.stringify(result.match, null, 2));
124
+ return matched();
125
+ }
126
+
127
+ const error: SyntaxMatchError = new SyntaxMatchError(result.reason, matcher.syntax, value, result);
128
+
129
+ if (caseSensitive) {
130
+ error.message = deMimicCases(error.message);
131
+ error.syntax = deMimicCases(error.syntax);
132
+ }
133
+
134
+ log('css-tree/SyntaxMatchError: %O', error);
135
+
136
+ return {
137
+ matched: false,
138
+ ref,
139
+ raw: origin.slice(error.mismatchOffset, error.mismatchOffset + error.mismatchLength),
140
+ offset: error.mismatchOffset,
141
+ length: error.mismatchLength,
142
+ line: error.line,
143
+ column: error.column,
144
+ expects: [
145
+ {
146
+ type: 'syntax',
147
+ value: error.syntax,
148
+ },
149
+ ],
150
+ partName: error.mismatchOffset === 0 ? undefined : 'value',
151
+ reason: 'syntax-error',
152
+ };
153
+ }
154
+
155
+ function defToMatcher(lexer: any, def: `<${string}>`) {
156
+ const isProp = def.search("<'") === 0;
157
+ const name = def.replace(/^<'?|'?>$/g, '');
158
+ const matcher = isProp ? lexer.properties[name] : lexer.types[name];
159
+ return {
160
+ isProp,
161
+ name,
162
+ matcher,
163
+ };
164
+ }
165
+
166
+ function eachMimicCases(key: string, obj: Record<string, string>) {
167
+ const value = obj[key];
168
+ obj[key] = mimicCases(value);
169
+ }
170
+
171
+ function mimicCases(value: string) {
172
+ return value.replace(/[A-Z]/g, $0 => `mimiccases---${$0}---mimiccases`);
173
+ }
174
+
175
+ function deMimicCases(value: string) {
176
+ return value.replace(/mimiccases---([A-Z])---mimiccases/g, (_, $1) => $1);
177
+ }
package/src/debug.ts ADDED
@@ -0,0 +1,3 @@
1
+ import debug from 'debug';
2
+
3
+ export const log = debug('@markuplint/types');