eslint-markdown 0.12.1 → 0.14.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/build/configs/all.d.ts +1 -0
- package/build/configs/all.js +1 -0
- package/build/configs/stylistic.d.ts +1 -0
- package/build/configs/stylistic.js +1 -0
- package/build/core/utils/index.d.ts +2 -1
- package/build/core/utils/index.js +2 -1
- package/build/core/utils/normalize-regex-pattern.d.ts +11 -0
- package/build/core/utils/normalize-regex-pattern.js +16 -0
- package/build/index.d.ts +148 -20
- package/build/rules/allow-heading.d.ts +74 -14
- package/build/rules/allow-heading.js +8 -12
- package/build/rules/allow-image-url.d.ts +14 -4
- package/build/rules/allow-image-url.js +13 -5
- package/build/rules/allow-link-url.d.ts +14 -4
- package/build/rules/allow-link-url.js +13 -5
- package/build/rules/consistent-thematic-break-style.d.ts +1 -0
- package/build/rules/consistent-thematic-break-style.js +10 -0
- package/build/rules/index.d.ts +148 -20
- package/build/rules/index.js +2 -2
- package/build/rules/no-trailing-heading-punctuation.d.ts +53 -0
- package/build/rules/no-trailing-heading-punctuation.js +187 -0
- package/package.json +2 -2
- package/build/rules/no-bold-paragraph.d.ts +0 -30
- package/build/rules/no-bold-paragraph.js +0 -48
package/build/configs/all.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export default function all(plugin: ESLint.Plugin): {
|
|
|
37
37
|
readonly 'md/no-irregular-dash': "error";
|
|
38
38
|
readonly 'md/no-irregular-whitespace': "error";
|
|
39
39
|
readonly 'md/no-tab': "error";
|
|
40
|
+
readonly 'md/no-trailing-heading-punctuation': "error";
|
|
40
41
|
readonly 'md/no-url-trailing-slash': "error";
|
|
41
42
|
readonly 'md/require-heading-id': "error";
|
|
42
43
|
readonly 'md/require-image-title': "error";
|
package/build/configs/all.js
CHANGED
|
@@ -45,6 +45,7 @@ export default function all(plugin) {
|
|
|
45
45
|
'md/no-irregular-dash': 'error',
|
|
46
46
|
'md/no-irregular-whitespace': 'error',
|
|
47
47
|
'md/no-tab': 'error',
|
|
48
|
+
'md/no-trailing-heading-punctuation': 'error',
|
|
48
49
|
'md/no-url-trailing-slash': 'error',
|
|
49
50
|
'md/require-heading-id': 'error',
|
|
50
51
|
'md/require-image-title': 'error',
|
|
@@ -25,5 +25,6 @@ export default function stylistic(plugin: ESLint.Plugin): {
|
|
|
25
25
|
readonly 'md/consistent-unordered-list-style': "error";
|
|
26
26
|
readonly 'md/no-consecutive-blank-line': "error";
|
|
27
27
|
readonly 'md/no-tab': "error";
|
|
28
|
+
readonly 'md/no-trailing-heading-punctuation': "error";
|
|
28
29
|
};
|
|
29
30
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import escapeStringRegexp from './escape-string-regexp.js';
|
|
2
2
|
import getElementsByTagName from './html.js';
|
|
3
3
|
import isBlankLine from './is-blank-line.js';
|
|
4
|
+
import normalizeRegexPattern from './normalize-regex-pattern.js';
|
|
4
5
|
import SkipRanges from './skip-ranges.js';
|
|
5
6
|
import testRegexStateless from './test-regex-stateless.js';
|
|
6
|
-
export { escapeStringRegexp, getElementsByTagName, isBlankLine, SkipRanges, testRegexStateless, };
|
|
7
|
+
export { escapeStringRegexp, getElementsByTagName, isBlankLine, normalizeRegexPattern, SkipRanges, testRegexStateless, };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import escapeStringRegexp from './escape-string-regexp.js';
|
|
2
2
|
import getElementsByTagName from './html.js';
|
|
3
3
|
import isBlankLine from './is-blank-line.js';
|
|
4
|
+
import normalizeRegexPattern from './normalize-regex-pattern.js';
|
|
4
5
|
import SkipRanges from './skip-ranges.js';
|
|
5
6
|
import testRegexStateless from './test-regex-stateless.js';
|
|
6
|
-
export { escapeStringRegexp, getElementsByTagName, isBlankLine, SkipRanges, testRegexStateless, };
|
|
7
|
+
export { escapeStringRegexp, getElementsByTagName, isBlankLine, normalizeRegexPattern, SkipRanges, testRegexStateless, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Utility to normalize a pattern option into a `RegExp`.
|
|
3
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v73.0.0/rules/filename-case.js#L276-L282
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes a pattern option into a `RegExp`.
|
|
7
|
+
* String patterns are compiled with the `u` flag.
|
|
8
|
+
* @param pattern `RegExp` or string pattern to normalize.
|
|
9
|
+
* @returns The normalized `RegExp`.
|
|
10
|
+
*/
|
|
11
|
+
export default function normalizeRegexPattern(pattern: RegExp | string): RegExp;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Utility to normalize a pattern option into a `RegExp`.
|
|
3
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v73.0.0/rules/filename-case.js#L276-L282
|
|
4
|
+
*/
|
|
5
|
+
// --------------------------------------------------------------------------------
|
|
6
|
+
// Export
|
|
7
|
+
// --------------------------------------------------------------------------------
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes a pattern option into a `RegExp`.
|
|
10
|
+
* String patterns are compiled with the `u` flag.
|
|
11
|
+
* @param pattern `RegExp` or string pattern to normalize.
|
|
12
|
+
* @returns The normalized `RegExp`.
|
|
13
|
+
*/
|
|
14
|
+
export default function normalizeRegexPattern(pattern) {
|
|
15
|
+
return typeof pattern === 'string' ? new RegExp(pattern, 'u') : pattern;
|
|
16
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -26,14 +26,24 @@ declare const plugin: {
|
|
|
26
26
|
readonly allow: {
|
|
27
27
|
readonly type: "array";
|
|
28
28
|
readonly items: {
|
|
29
|
-
readonly
|
|
29
|
+
readonly oneOf: readonly [{
|
|
30
|
+
readonly type: "object";
|
|
31
|
+
readonly additionalProperties: false;
|
|
32
|
+
}, {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
}];
|
|
30
35
|
};
|
|
31
36
|
readonly uniqueItems: true;
|
|
32
37
|
};
|
|
33
38
|
readonly disallow: {
|
|
34
39
|
readonly type: "array";
|
|
35
40
|
readonly items: {
|
|
36
|
-
readonly
|
|
41
|
+
readonly oneOf: readonly [{
|
|
42
|
+
readonly type: "object";
|
|
43
|
+
readonly additionalProperties: false;
|
|
44
|
+
}, {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
}];
|
|
37
47
|
};
|
|
38
48
|
readonly uniqueItems: true;
|
|
39
49
|
};
|
|
@@ -46,14 +56,24 @@ declare const plugin: {
|
|
|
46
56
|
readonly allow: {
|
|
47
57
|
readonly type: "array";
|
|
48
58
|
readonly items: {
|
|
49
|
-
readonly
|
|
59
|
+
readonly oneOf: readonly [{
|
|
60
|
+
readonly type: "object";
|
|
61
|
+
readonly additionalProperties: false;
|
|
62
|
+
}, {
|
|
63
|
+
readonly type: "string";
|
|
64
|
+
}];
|
|
50
65
|
};
|
|
51
66
|
readonly uniqueItems: true;
|
|
52
67
|
};
|
|
53
68
|
readonly disallow: {
|
|
54
69
|
readonly type: "array";
|
|
55
70
|
readonly items: {
|
|
56
|
-
readonly
|
|
71
|
+
readonly oneOf: readonly [{
|
|
72
|
+
readonly type: "object";
|
|
73
|
+
readonly additionalProperties: false;
|
|
74
|
+
}, {
|
|
75
|
+
readonly type: "string";
|
|
76
|
+
}];
|
|
57
77
|
};
|
|
58
78
|
readonly uniqueItems: true;
|
|
59
79
|
};
|
|
@@ -66,14 +86,24 @@ declare const plugin: {
|
|
|
66
86
|
readonly allow: {
|
|
67
87
|
readonly type: "array";
|
|
68
88
|
readonly items: {
|
|
69
|
-
readonly
|
|
89
|
+
readonly oneOf: readonly [{
|
|
90
|
+
readonly type: "object";
|
|
91
|
+
readonly additionalProperties: false;
|
|
92
|
+
}, {
|
|
93
|
+
readonly type: "string";
|
|
94
|
+
}];
|
|
70
95
|
};
|
|
71
96
|
readonly uniqueItems: true;
|
|
72
97
|
};
|
|
73
98
|
readonly disallow: {
|
|
74
99
|
readonly type: "array";
|
|
75
100
|
readonly items: {
|
|
76
|
-
readonly
|
|
101
|
+
readonly oneOf: readonly [{
|
|
102
|
+
readonly type: "object";
|
|
103
|
+
readonly additionalProperties: false;
|
|
104
|
+
}, {
|
|
105
|
+
readonly type: "string";
|
|
106
|
+
}];
|
|
77
107
|
};
|
|
78
108
|
readonly uniqueItems: true;
|
|
79
109
|
};
|
|
@@ -86,14 +116,24 @@ declare const plugin: {
|
|
|
86
116
|
readonly allow: {
|
|
87
117
|
readonly type: "array";
|
|
88
118
|
readonly items: {
|
|
89
|
-
readonly
|
|
119
|
+
readonly oneOf: readonly [{
|
|
120
|
+
readonly type: "object";
|
|
121
|
+
readonly additionalProperties: false;
|
|
122
|
+
}, {
|
|
123
|
+
readonly type: "string";
|
|
124
|
+
}];
|
|
90
125
|
};
|
|
91
126
|
readonly uniqueItems: true;
|
|
92
127
|
};
|
|
93
128
|
readonly disallow: {
|
|
94
129
|
readonly type: "array";
|
|
95
130
|
readonly items: {
|
|
96
|
-
readonly
|
|
131
|
+
readonly oneOf: readonly [{
|
|
132
|
+
readonly type: "object";
|
|
133
|
+
readonly additionalProperties: false;
|
|
134
|
+
}, {
|
|
135
|
+
readonly type: "string";
|
|
136
|
+
}];
|
|
97
137
|
};
|
|
98
138
|
readonly uniqueItems: true;
|
|
99
139
|
};
|
|
@@ -106,14 +146,24 @@ declare const plugin: {
|
|
|
106
146
|
readonly allow: {
|
|
107
147
|
readonly type: "array";
|
|
108
148
|
readonly items: {
|
|
109
|
-
readonly
|
|
149
|
+
readonly oneOf: readonly [{
|
|
150
|
+
readonly type: "object";
|
|
151
|
+
readonly additionalProperties: false;
|
|
152
|
+
}, {
|
|
153
|
+
readonly type: "string";
|
|
154
|
+
}];
|
|
110
155
|
};
|
|
111
156
|
readonly uniqueItems: true;
|
|
112
157
|
};
|
|
113
158
|
readonly disallow: {
|
|
114
159
|
readonly type: "array";
|
|
115
160
|
readonly items: {
|
|
116
|
-
readonly
|
|
161
|
+
readonly oneOf: readonly [{
|
|
162
|
+
readonly type: "object";
|
|
163
|
+
readonly additionalProperties: false;
|
|
164
|
+
}, {
|
|
165
|
+
readonly type: "string";
|
|
166
|
+
}];
|
|
117
167
|
};
|
|
118
168
|
readonly uniqueItems: true;
|
|
119
169
|
};
|
|
@@ -126,14 +176,24 @@ declare const plugin: {
|
|
|
126
176
|
readonly allow: {
|
|
127
177
|
readonly type: "array";
|
|
128
178
|
readonly items: {
|
|
129
|
-
readonly
|
|
179
|
+
readonly oneOf: readonly [{
|
|
180
|
+
readonly type: "object";
|
|
181
|
+
readonly additionalProperties: false;
|
|
182
|
+
}, {
|
|
183
|
+
readonly type: "string";
|
|
184
|
+
}];
|
|
130
185
|
};
|
|
131
186
|
readonly uniqueItems: true;
|
|
132
187
|
};
|
|
133
188
|
readonly disallow: {
|
|
134
189
|
readonly type: "array";
|
|
135
190
|
readonly items: {
|
|
136
|
-
readonly
|
|
191
|
+
readonly oneOf: readonly [{
|
|
192
|
+
readonly type: "object";
|
|
193
|
+
readonly additionalProperties: false;
|
|
194
|
+
}, {
|
|
195
|
+
readonly type: "string";
|
|
196
|
+
}];
|
|
137
197
|
};
|
|
138
198
|
readonly uniqueItems: true;
|
|
139
199
|
};
|
|
@@ -201,14 +261,24 @@ declare const plugin: {
|
|
|
201
261
|
readonly allowUrls: {
|
|
202
262
|
readonly type: "array";
|
|
203
263
|
readonly items: {
|
|
204
|
-
readonly
|
|
264
|
+
readonly oneOf: [{
|
|
265
|
+
readonly type: "object";
|
|
266
|
+
readonly additionalProperties: false;
|
|
267
|
+
}, {
|
|
268
|
+
readonly type: "string";
|
|
269
|
+
}];
|
|
205
270
|
};
|
|
206
271
|
readonly uniqueItems: true;
|
|
207
272
|
};
|
|
208
273
|
readonly disallowUrls: {
|
|
209
274
|
readonly type: "array";
|
|
210
275
|
readonly items: {
|
|
211
|
-
readonly
|
|
276
|
+
readonly oneOf: [{
|
|
277
|
+
readonly type: "object";
|
|
278
|
+
readonly additionalProperties: false;
|
|
279
|
+
}, {
|
|
280
|
+
readonly type: "string";
|
|
281
|
+
}];
|
|
212
282
|
};
|
|
213
283
|
readonly uniqueItems: true;
|
|
214
284
|
};
|
|
@@ -238,8 +308,8 @@ declare const plugin: {
|
|
|
238
308
|
LangOptions: import("@eslint/markdown").MarkdownLanguageOptions;
|
|
239
309
|
Code: import("@eslint/markdown").MarkdownSourceCode;
|
|
240
310
|
RuleOptions: [{
|
|
241
|
-
allowUrls: RegExp[];
|
|
242
|
-
disallowUrls: RegExp[];
|
|
311
|
+
allowUrls: (RegExp | string)[];
|
|
312
|
+
disallowUrls: (RegExp | string)[];
|
|
243
313
|
allowDefinitions: string[];
|
|
244
314
|
}];
|
|
245
315
|
Node: import("mdast").Node;
|
|
@@ -267,14 +337,24 @@ declare const plugin: {
|
|
|
267
337
|
readonly allowUrls: {
|
|
268
338
|
readonly type: "array";
|
|
269
339
|
readonly items: {
|
|
270
|
-
readonly
|
|
340
|
+
readonly oneOf: [{
|
|
341
|
+
readonly type: "object";
|
|
342
|
+
readonly additionalProperties: false;
|
|
343
|
+
}, {
|
|
344
|
+
readonly type: "string";
|
|
345
|
+
}];
|
|
271
346
|
};
|
|
272
347
|
readonly uniqueItems: true;
|
|
273
348
|
};
|
|
274
349
|
readonly disallowUrls: {
|
|
275
350
|
readonly type: "array";
|
|
276
351
|
readonly items: {
|
|
277
|
-
readonly
|
|
352
|
+
readonly oneOf: [{
|
|
353
|
+
readonly type: "object";
|
|
354
|
+
readonly additionalProperties: false;
|
|
355
|
+
}, {
|
|
356
|
+
readonly type: "string";
|
|
357
|
+
}];
|
|
278
358
|
};
|
|
279
359
|
readonly uniqueItems: true;
|
|
280
360
|
};
|
|
@@ -304,8 +384,8 @@ declare const plugin: {
|
|
|
304
384
|
LangOptions: import("@eslint/markdown").MarkdownLanguageOptions;
|
|
305
385
|
Code: import("@eslint/markdown").MarkdownSourceCode;
|
|
306
386
|
RuleOptions: [{
|
|
307
|
-
allowUrls: RegExp[];
|
|
308
|
-
disallowUrls: RegExp[];
|
|
387
|
+
allowUrls: (RegExp | string)[];
|
|
388
|
+
disallowUrls: (RegExp | string)[];
|
|
309
389
|
allowDefinitions: string[];
|
|
310
390
|
}];
|
|
311
391
|
Node: import("mdast").Node;
|
|
@@ -594,6 +674,7 @@ declare const plugin: {
|
|
|
594
674
|
readonly properties: {
|
|
595
675
|
readonly style: {
|
|
596
676
|
readonly type: "string";
|
|
677
|
+
readonly pattern: "^(?:consistent|(?:-[ \\t]*){3,}|(?:\\*[ \\t]*){3,}|(?:_[ \\t]*){3,})$";
|
|
597
678
|
};
|
|
598
679
|
};
|
|
599
680
|
readonly additionalProperties: false;
|
|
@@ -1206,6 +1287,53 @@ declare const plugin: {
|
|
|
1206
1287
|
'root:exit'(): void;
|
|
1207
1288
|
};
|
|
1208
1289
|
};
|
|
1290
|
+
'no-trailing-heading-punctuation': {
|
|
1291
|
+
readonly meta: {
|
|
1292
|
+
readonly type: "problem";
|
|
1293
|
+
readonly docs: {
|
|
1294
|
+
readonly description: "Disallow trailing punctuation in headings";
|
|
1295
|
+
readonly url: string;
|
|
1296
|
+
readonly recommended: false;
|
|
1297
|
+
readonly stylistic: true;
|
|
1298
|
+
};
|
|
1299
|
+
readonly fixable: "code";
|
|
1300
|
+
readonly schema: [{
|
|
1301
|
+
readonly type: "object";
|
|
1302
|
+
readonly properties: {
|
|
1303
|
+
readonly punctuation: {
|
|
1304
|
+
readonly type: "array";
|
|
1305
|
+
readonly items: {
|
|
1306
|
+
readonly type: "string";
|
|
1307
|
+
readonly minLength: 1;
|
|
1308
|
+
readonly maxLength: 1;
|
|
1309
|
+
};
|
|
1310
|
+
readonly minItems: 1;
|
|
1311
|
+
readonly uniqueItems: true;
|
|
1312
|
+
};
|
|
1313
|
+
};
|
|
1314
|
+
readonly additionalProperties: false;
|
|
1315
|
+
}];
|
|
1316
|
+
readonly defaultOptions: [{
|
|
1317
|
+
readonly punctuation: [".", ",", ";", ":", "!", "。", ",", ";", ":", "!"];
|
|
1318
|
+
}];
|
|
1319
|
+
readonly messages: {
|
|
1320
|
+
readonly noTrailingHeadingPunctuation: "Trailing punctuation `{{ punctuation }}` is not allowed in headings.";
|
|
1321
|
+
};
|
|
1322
|
+
readonly language: "markdown";
|
|
1323
|
+
readonly dialects: ["commonmark", "gfm"];
|
|
1324
|
+
};
|
|
1325
|
+
readonly create: (context: import("@eslint/core").RuleContext<{
|
|
1326
|
+
LangOptions: import("@eslint/markdown").MarkdownLanguageOptions;
|
|
1327
|
+
Code: import("@eslint/markdown").MarkdownSourceCode;
|
|
1328
|
+
RuleOptions: [{
|
|
1329
|
+
punctuation: string[];
|
|
1330
|
+
}];
|
|
1331
|
+
Node: import("mdast").Node;
|
|
1332
|
+
MessageIds: "noTrailingHeadingPunctuation";
|
|
1333
|
+
}>) => {
|
|
1334
|
+
heading(node: import("mdast").Heading): void;
|
|
1335
|
+
};
|
|
1336
|
+
};
|
|
1209
1337
|
'no-url-trailing-slash': {
|
|
1210
1338
|
readonly meta: {
|
|
1211
1339
|
readonly type: "problem";
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Heading } from 'mdast';
|
|
6
6
|
export interface HeadingOptions {
|
|
7
|
-
allow: RegExp[];
|
|
8
|
-
disallow: RegExp[];
|
|
7
|
+
allow: (RegExp | string)[];
|
|
8
|
+
disallow: (RegExp | string)[];
|
|
9
9
|
}
|
|
10
10
|
type RuleOptions = [Record<`h${Heading['depth']}`, HeadingOptions>];
|
|
11
11
|
type MessageIds = 'allowHeading' | 'disallowHeading';
|
|
@@ -27,14 +27,24 @@ declare const _default: {
|
|
|
27
27
|
readonly allow: {
|
|
28
28
|
readonly type: "array";
|
|
29
29
|
readonly items: {
|
|
30
|
-
readonly
|
|
30
|
+
readonly oneOf: readonly [{
|
|
31
|
+
readonly type: "object";
|
|
32
|
+
readonly additionalProperties: false;
|
|
33
|
+
}, {
|
|
34
|
+
readonly type: "string";
|
|
35
|
+
}];
|
|
31
36
|
};
|
|
32
37
|
readonly uniqueItems: true;
|
|
33
38
|
};
|
|
34
39
|
readonly disallow: {
|
|
35
40
|
readonly type: "array";
|
|
36
41
|
readonly items: {
|
|
37
|
-
readonly
|
|
42
|
+
readonly oneOf: readonly [{
|
|
43
|
+
readonly type: "object";
|
|
44
|
+
readonly additionalProperties: false;
|
|
45
|
+
}, {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
}];
|
|
38
48
|
};
|
|
39
49
|
readonly uniqueItems: true;
|
|
40
50
|
};
|
|
@@ -47,14 +57,24 @@ declare const _default: {
|
|
|
47
57
|
readonly allow: {
|
|
48
58
|
readonly type: "array";
|
|
49
59
|
readonly items: {
|
|
50
|
-
readonly
|
|
60
|
+
readonly oneOf: readonly [{
|
|
61
|
+
readonly type: "object";
|
|
62
|
+
readonly additionalProperties: false;
|
|
63
|
+
}, {
|
|
64
|
+
readonly type: "string";
|
|
65
|
+
}];
|
|
51
66
|
};
|
|
52
67
|
readonly uniqueItems: true;
|
|
53
68
|
};
|
|
54
69
|
readonly disallow: {
|
|
55
70
|
readonly type: "array";
|
|
56
71
|
readonly items: {
|
|
57
|
-
readonly
|
|
72
|
+
readonly oneOf: readonly [{
|
|
73
|
+
readonly type: "object";
|
|
74
|
+
readonly additionalProperties: false;
|
|
75
|
+
}, {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
}];
|
|
58
78
|
};
|
|
59
79
|
readonly uniqueItems: true;
|
|
60
80
|
};
|
|
@@ -67,14 +87,24 @@ declare const _default: {
|
|
|
67
87
|
readonly allow: {
|
|
68
88
|
readonly type: "array";
|
|
69
89
|
readonly items: {
|
|
70
|
-
readonly
|
|
90
|
+
readonly oneOf: readonly [{
|
|
91
|
+
readonly type: "object";
|
|
92
|
+
readonly additionalProperties: false;
|
|
93
|
+
}, {
|
|
94
|
+
readonly type: "string";
|
|
95
|
+
}];
|
|
71
96
|
};
|
|
72
97
|
readonly uniqueItems: true;
|
|
73
98
|
};
|
|
74
99
|
readonly disallow: {
|
|
75
100
|
readonly type: "array";
|
|
76
101
|
readonly items: {
|
|
77
|
-
readonly
|
|
102
|
+
readonly oneOf: readonly [{
|
|
103
|
+
readonly type: "object";
|
|
104
|
+
readonly additionalProperties: false;
|
|
105
|
+
}, {
|
|
106
|
+
readonly type: "string";
|
|
107
|
+
}];
|
|
78
108
|
};
|
|
79
109
|
readonly uniqueItems: true;
|
|
80
110
|
};
|
|
@@ -87,14 +117,24 @@ declare const _default: {
|
|
|
87
117
|
readonly allow: {
|
|
88
118
|
readonly type: "array";
|
|
89
119
|
readonly items: {
|
|
90
|
-
readonly
|
|
120
|
+
readonly oneOf: readonly [{
|
|
121
|
+
readonly type: "object";
|
|
122
|
+
readonly additionalProperties: false;
|
|
123
|
+
}, {
|
|
124
|
+
readonly type: "string";
|
|
125
|
+
}];
|
|
91
126
|
};
|
|
92
127
|
readonly uniqueItems: true;
|
|
93
128
|
};
|
|
94
129
|
readonly disallow: {
|
|
95
130
|
readonly type: "array";
|
|
96
131
|
readonly items: {
|
|
97
|
-
readonly
|
|
132
|
+
readonly oneOf: readonly [{
|
|
133
|
+
readonly type: "object";
|
|
134
|
+
readonly additionalProperties: false;
|
|
135
|
+
}, {
|
|
136
|
+
readonly type: "string";
|
|
137
|
+
}];
|
|
98
138
|
};
|
|
99
139
|
readonly uniqueItems: true;
|
|
100
140
|
};
|
|
@@ -107,14 +147,24 @@ declare const _default: {
|
|
|
107
147
|
readonly allow: {
|
|
108
148
|
readonly type: "array";
|
|
109
149
|
readonly items: {
|
|
110
|
-
readonly
|
|
150
|
+
readonly oneOf: readonly [{
|
|
151
|
+
readonly type: "object";
|
|
152
|
+
readonly additionalProperties: false;
|
|
153
|
+
}, {
|
|
154
|
+
readonly type: "string";
|
|
155
|
+
}];
|
|
111
156
|
};
|
|
112
157
|
readonly uniqueItems: true;
|
|
113
158
|
};
|
|
114
159
|
readonly disallow: {
|
|
115
160
|
readonly type: "array";
|
|
116
161
|
readonly items: {
|
|
117
|
-
readonly
|
|
162
|
+
readonly oneOf: readonly [{
|
|
163
|
+
readonly type: "object";
|
|
164
|
+
readonly additionalProperties: false;
|
|
165
|
+
}, {
|
|
166
|
+
readonly type: "string";
|
|
167
|
+
}];
|
|
118
168
|
};
|
|
119
169
|
readonly uniqueItems: true;
|
|
120
170
|
};
|
|
@@ -127,14 +177,24 @@ declare const _default: {
|
|
|
127
177
|
readonly allow: {
|
|
128
178
|
readonly type: "array";
|
|
129
179
|
readonly items: {
|
|
130
|
-
readonly
|
|
180
|
+
readonly oneOf: readonly [{
|
|
181
|
+
readonly type: "object";
|
|
182
|
+
readonly additionalProperties: false;
|
|
183
|
+
}, {
|
|
184
|
+
readonly type: "string";
|
|
185
|
+
}];
|
|
131
186
|
};
|
|
132
187
|
readonly uniqueItems: true;
|
|
133
188
|
};
|
|
134
189
|
readonly disallow: {
|
|
135
190
|
readonly type: "array";
|
|
136
191
|
readonly items: {
|
|
137
|
-
readonly
|
|
192
|
+
readonly oneOf: readonly [{
|
|
193
|
+
readonly type: "object";
|
|
194
|
+
readonly additionalProperties: false;
|
|
195
|
+
}, {
|
|
196
|
+
readonly type: "string";
|
|
197
|
+
}];
|
|
138
198
|
};
|
|
139
199
|
readonly uniqueItems: true;
|
|
140
200
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview Rule to enforce the use of allowed or disallowed headings.
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
|
-
import { testRegexStateless } from '../core/utils/index.js';
|
|
5
|
+
import { normalizeRegexPattern, testRegexStateless } from '../core/utils/index.js';
|
|
6
6
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
8
|
// Helper
|
|
@@ -13,14 +13,14 @@ const headingOptionsSchema = {
|
|
|
13
13
|
allow: {
|
|
14
14
|
type: 'array',
|
|
15
15
|
items: {
|
|
16
|
-
type: 'object',
|
|
16
|
+
oneOf: [{ type: 'object', additionalProperties: false }, { type: 'string' }],
|
|
17
17
|
},
|
|
18
18
|
uniqueItems: true,
|
|
19
19
|
},
|
|
20
20
|
disallow: {
|
|
21
21
|
type: 'array',
|
|
22
22
|
items: {
|
|
23
|
-
type: 'object',
|
|
23
|
+
oneOf: [{ type: 'object', additionalProperties: false }, { type: 'string' }],
|
|
24
24
|
},
|
|
25
25
|
uniqueItems: true,
|
|
26
26
|
},
|
|
@@ -73,18 +73,14 @@ export default {
|
|
|
73
73
|
create(context) {
|
|
74
74
|
const { sourceCode } = context;
|
|
75
75
|
const [{ h1, h2, h3, h4, h5, h6 }] = context.options;
|
|
76
|
-
const headingMap = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
4: h4,
|
|
81
|
-
5: h5,
|
|
82
|
-
6: h6,
|
|
83
|
-
};
|
|
76
|
+
const headingMap = [h1, h2, h3, h4, h5, h6].map(({ allow, disallow }) => ({
|
|
77
|
+
allow: allow.map(normalizeRegexPattern),
|
|
78
|
+
disallow: disallow.map(normalizeRegexPattern),
|
|
79
|
+
}));
|
|
84
80
|
return {
|
|
85
81
|
heading(node) {
|
|
86
82
|
const { depth } = node;
|
|
87
|
-
const { allow, disallow } = headingMap[depth];
|
|
83
|
+
const { allow, disallow } = headingMap[depth - 1];
|
|
88
84
|
const headingText = sourceCode.getText(node);
|
|
89
85
|
if (!allow.some(regex => testRegexStateless(regex, headingText))) {
|
|
90
86
|
context.report({
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import type { Definition } from 'mdast';
|
|
6
6
|
type RuleOptions = [
|
|
7
7
|
{
|
|
8
|
-
allowUrls: RegExp[];
|
|
9
|
-
disallowUrls: RegExp[];
|
|
8
|
+
allowUrls: (RegExp | string)[];
|
|
9
|
+
disallowUrls: (RegExp | string)[];
|
|
10
10
|
allowDefinitions: string[];
|
|
11
11
|
}
|
|
12
12
|
];
|
|
@@ -26,14 +26,24 @@ declare const _default: {
|
|
|
26
26
|
readonly allowUrls: {
|
|
27
27
|
readonly type: "array";
|
|
28
28
|
readonly items: {
|
|
29
|
-
readonly
|
|
29
|
+
readonly oneOf: [{
|
|
30
|
+
readonly type: "object";
|
|
31
|
+
readonly additionalProperties: false;
|
|
32
|
+
}, {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
}];
|
|
30
35
|
};
|
|
31
36
|
readonly uniqueItems: true;
|
|
32
37
|
};
|
|
33
38
|
readonly disallowUrls: {
|
|
34
39
|
readonly type: "array";
|
|
35
40
|
readonly items: {
|
|
36
|
-
readonly
|
|
41
|
+
readonly oneOf: [{
|
|
42
|
+
readonly type: "object";
|
|
43
|
+
readonly additionalProperties: false;
|
|
44
|
+
}, {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
}];
|
|
37
47
|
};
|
|
38
48
|
readonly uniqueItems: true;
|
|
39
49
|
};
|