eslint-markdown 0.11.1 → 0.12.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/index.d.ts +178 -0
- package/build/rules/allow-heading.d.ts +138 -61
- package/build/rules/allow-heading.js +63 -100
- package/build/rules/allow-image-url.js +1 -1
- package/build/rules/allow-link-url.js +1 -1
- package/build/rules/consistent-code-style.js +1 -1
- package/build/rules/index.d.ts +178 -0
- package/build/rules/index.js +2 -2
- package/build/rules/no-consecutive-blank-line.js +1 -1
- package/build/rules/no-control-character.js +1 -1
- package/build/rules/no-git-conflict-marker.js +1 -1
- package/build/rules/no-irregular-dash.js +1 -1
- package/build/rules/no-irregular-whitespace.js +1 -1
- package/build/rules/no-tab.js +1 -1
- package/build/rules/no-url-trailing-slash.js +1 -1
- package/build/rules/require-heading-id.js +1 -1
- package/build/rules/require-image-title.js +1 -1
- package/build/rules/require-link-title.js +1 -1
- package/package.json +1 -1
- /package/build/core/{ast → utils}/escape-string-regexp.d.ts +0 -0
- /package/build/core/{ast → utils}/escape-string-regexp.js +0 -0
- /package/build/core/{ast → utils}/html.d.ts +0 -0
- /package/build/core/{ast → utils}/html.js +0 -0
- /package/build/core/{ast → utils}/index.d.ts +0 -0
- /package/build/core/{ast → utils}/index.js +0 -0
- /package/build/core/{ast → utils}/is-blank-line.d.ts +0 -0
- /package/build/core/{ast → utils}/is-blank-line.js +0 -0
- /package/build/core/{ast → utils}/skip-ranges.d.ts +0 -0
- /package/build/core/{ast → utils}/skip-ranges.js +0 -0
package/build/configs/all.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export default function all(plugin: ESLint.Plugin): {
|
|
|
16
16
|
};
|
|
17
17
|
readonly language: "markdown/gfm";
|
|
18
18
|
readonly rules: {
|
|
19
|
+
readonly 'md/allow-heading': "error";
|
|
19
20
|
readonly 'md/allow-image-url': "error";
|
|
20
21
|
readonly 'md/allow-link-url': "error";
|
|
21
22
|
readonly 'md/code-lang-shorthand': "error";
|
package/build/configs/all.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -8,6 +8,184 @@ declare const plugin: {
|
|
|
8
8
|
readonly version: string;
|
|
9
9
|
};
|
|
10
10
|
readonly rules: {
|
|
11
|
+
'allow-heading': {
|
|
12
|
+
readonly meta: {
|
|
13
|
+
readonly type: "problem";
|
|
14
|
+
readonly docs: {
|
|
15
|
+
readonly description: "Enforce the use of allowed or disallowed headings";
|
|
16
|
+
readonly url: string;
|
|
17
|
+
readonly recommended: false;
|
|
18
|
+
readonly stylistic: false;
|
|
19
|
+
};
|
|
20
|
+
readonly schema: [{
|
|
21
|
+
readonly type: "object";
|
|
22
|
+
readonly properties: {
|
|
23
|
+
readonly h1: {
|
|
24
|
+
readonly type: "object";
|
|
25
|
+
readonly properties: {
|
|
26
|
+
readonly allow: {
|
|
27
|
+
readonly type: "array";
|
|
28
|
+
readonly items: {
|
|
29
|
+
readonly type: "object";
|
|
30
|
+
};
|
|
31
|
+
readonly uniqueItems: true;
|
|
32
|
+
};
|
|
33
|
+
readonly disallow: {
|
|
34
|
+
readonly type: "array";
|
|
35
|
+
readonly items: {
|
|
36
|
+
readonly type: "object";
|
|
37
|
+
};
|
|
38
|
+
readonly uniqueItems: true;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
readonly additionalProperties: false;
|
|
42
|
+
};
|
|
43
|
+
readonly h2: {
|
|
44
|
+
readonly type: "object";
|
|
45
|
+
readonly properties: {
|
|
46
|
+
readonly allow: {
|
|
47
|
+
readonly type: "array";
|
|
48
|
+
readonly items: {
|
|
49
|
+
readonly type: "object";
|
|
50
|
+
};
|
|
51
|
+
readonly uniqueItems: true;
|
|
52
|
+
};
|
|
53
|
+
readonly disallow: {
|
|
54
|
+
readonly type: "array";
|
|
55
|
+
readonly items: {
|
|
56
|
+
readonly type: "object";
|
|
57
|
+
};
|
|
58
|
+
readonly uniqueItems: true;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
readonly additionalProperties: false;
|
|
62
|
+
};
|
|
63
|
+
readonly h3: {
|
|
64
|
+
readonly type: "object";
|
|
65
|
+
readonly properties: {
|
|
66
|
+
readonly allow: {
|
|
67
|
+
readonly type: "array";
|
|
68
|
+
readonly items: {
|
|
69
|
+
readonly type: "object";
|
|
70
|
+
};
|
|
71
|
+
readonly uniqueItems: true;
|
|
72
|
+
};
|
|
73
|
+
readonly disallow: {
|
|
74
|
+
readonly type: "array";
|
|
75
|
+
readonly items: {
|
|
76
|
+
readonly type: "object";
|
|
77
|
+
};
|
|
78
|
+
readonly uniqueItems: true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly additionalProperties: false;
|
|
82
|
+
};
|
|
83
|
+
readonly h4: {
|
|
84
|
+
readonly type: "object";
|
|
85
|
+
readonly properties: {
|
|
86
|
+
readonly allow: {
|
|
87
|
+
readonly type: "array";
|
|
88
|
+
readonly items: {
|
|
89
|
+
readonly type: "object";
|
|
90
|
+
};
|
|
91
|
+
readonly uniqueItems: true;
|
|
92
|
+
};
|
|
93
|
+
readonly disallow: {
|
|
94
|
+
readonly type: "array";
|
|
95
|
+
readonly items: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
};
|
|
98
|
+
readonly uniqueItems: true;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
readonly additionalProperties: false;
|
|
102
|
+
};
|
|
103
|
+
readonly h5: {
|
|
104
|
+
readonly type: "object";
|
|
105
|
+
readonly properties: {
|
|
106
|
+
readonly allow: {
|
|
107
|
+
readonly type: "array";
|
|
108
|
+
readonly items: {
|
|
109
|
+
readonly type: "object";
|
|
110
|
+
};
|
|
111
|
+
readonly uniqueItems: true;
|
|
112
|
+
};
|
|
113
|
+
readonly disallow: {
|
|
114
|
+
readonly type: "array";
|
|
115
|
+
readonly items: {
|
|
116
|
+
readonly type: "object";
|
|
117
|
+
};
|
|
118
|
+
readonly uniqueItems: true;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
readonly additionalProperties: false;
|
|
122
|
+
};
|
|
123
|
+
readonly h6: {
|
|
124
|
+
readonly type: "object";
|
|
125
|
+
readonly properties: {
|
|
126
|
+
readonly allow: {
|
|
127
|
+
readonly type: "array";
|
|
128
|
+
readonly items: {
|
|
129
|
+
readonly type: "object";
|
|
130
|
+
};
|
|
131
|
+
readonly uniqueItems: true;
|
|
132
|
+
};
|
|
133
|
+
readonly disallow: {
|
|
134
|
+
readonly type: "array";
|
|
135
|
+
readonly items: {
|
|
136
|
+
readonly type: "object";
|
|
137
|
+
};
|
|
138
|
+
readonly uniqueItems: true;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
readonly additionalProperties: false;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
readonly additionalProperties: false;
|
|
145
|
+
}];
|
|
146
|
+
readonly defaultOptions: [{
|
|
147
|
+
readonly h1: {
|
|
148
|
+
readonly allow: [RegExp];
|
|
149
|
+
readonly disallow: [];
|
|
150
|
+
};
|
|
151
|
+
readonly h2: {
|
|
152
|
+
readonly allow: [RegExp];
|
|
153
|
+
readonly disallow: [];
|
|
154
|
+
};
|
|
155
|
+
readonly h3: {
|
|
156
|
+
readonly allow: [RegExp];
|
|
157
|
+
readonly disallow: [];
|
|
158
|
+
};
|
|
159
|
+
readonly h4: {
|
|
160
|
+
readonly allow: [RegExp];
|
|
161
|
+
readonly disallow: [];
|
|
162
|
+
};
|
|
163
|
+
readonly h5: {
|
|
164
|
+
readonly allow: [RegExp];
|
|
165
|
+
readonly disallow: [];
|
|
166
|
+
};
|
|
167
|
+
readonly h6: {
|
|
168
|
+
readonly allow: [RegExp];
|
|
169
|
+
readonly disallow: [];
|
|
170
|
+
};
|
|
171
|
+
}];
|
|
172
|
+
readonly messages: {
|
|
173
|
+
readonly allowHeading: "The level {{ depth }} heading `{{ heading }}` is not in the list of allowed headings. (Allow: {{ allow }}).";
|
|
174
|
+
readonly disallowHeading: "The level {{ depth }} heading `{{ heading }}` is in the list of disallowed headings. (Disallow: {{ disallow }}).";
|
|
175
|
+
};
|
|
176
|
+
readonly language: "markdown";
|
|
177
|
+
readonly dialects: ["commonmark", "gfm"];
|
|
178
|
+
};
|
|
179
|
+
readonly create: (context: import("@eslint/core").RuleContext<{
|
|
180
|
+
LangOptions: import("@eslint/markdown").MarkdownLanguageOptions;
|
|
181
|
+
Code: import("@eslint/markdown").MarkdownSourceCode;
|
|
182
|
+
RuleOptions: [Record<"h1" | "h2" | "h3" | "h4" | "h5" | "h6", import("./rules/allow-heading.js").HeadingOptions>];
|
|
183
|
+
Node: import("mdast").Node;
|
|
184
|
+
MessageIds: "allowHeading" | "disallowHeading";
|
|
185
|
+
}>) => {
|
|
186
|
+
heading(node: import("mdast").Heading): void;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
11
189
|
'allow-image-url': {
|
|
12
190
|
readonly meta: {
|
|
13
191
|
readonly type: "problem";
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Rule to enforce the use of allowed
|
|
2
|
+
* @fileoverview Rule to enforce the use of allowed or disallowed headings.
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
|
-
type
|
|
6
|
-
|
|
5
|
+
import type { Heading } from 'mdast';
|
|
6
|
+
export interface HeadingOptions {
|
|
7
|
+
allow: RegExp[];
|
|
8
|
+
disallow: RegExp[];
|
|
9
|
+
}
|
|
10
|
+
type RuleOptions = [Record<`h${Heading['depth']}`, HeadingOptions>];
|
|
11
|
+
type MessageIds = 'allowHeading' | 'disallowHeading';
|
|
7
12
|
declare const _default: {
|
|
8
13
|
readonly meta: {
|
|
9
14
|
readonly type: "problem";
|
|
10
15
|
readonly docs: {
|
|
11
|
-
readonly description: "Enforce the use of allowed
|
|
16
|
+
readonly description: "Enforce the use of allowed or disallowed headings";
|
|
12
17
|
readonly url: string;
|
|
13
18
|
readonly recommended: false;
|
|
14
19
|
readonly stylistic: false;
|
|
@@ -17,85 +22,157 @@ declare const _default: {
|
|
|
17
22
|
readonly type: "object";
|
|
18
23
|
readonly properties: {
|
|
19
24
|
readonly h1: {
|
|
20
|
-
readonly
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
readonly type: "object";
|
|
26
|
+
readonly properties: {
|
|
27
|
+
readonly allow: {
|
|
28
|
+
readonly type: "array";
|
|
29
|
+
readonly items: {
|
|
30
|
+
readonly type: "object";
|
|
31
|
+
};
|
|
32
|
+
readonly uniqueItems: true;
|
|
26
33
|
};
|
|
27
|
-
readonly
|
|
28
|
-
|
|
34
|
+
readonly disallow: {
|
|
35
|
+
readonly type: "array";
|
|
36
|
+
readonly items: {
|
|
37
|
+
readonly type: "object";
|
|
38
|
+
};
|
|
39
|
+
readonly uniqueItems: true;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
readonly additionalProperties: false;
|
|
29
43
|
};
|
|
30
44
|
readonly h2: {
|
|
31
|
-
readonly
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
readonly type: "object";
|
|
46
|
+
readonly properties: {
|
|
47
|
+
readonly allow: {
|
|
48
|
+
readonly type: "array";
|
|
49
|
+
readonly items: {
|
|
50
|
+
readonly type: "object";
|
|
51
|
+
};
|
|
52
|
+
readonly uniqueItems: true;
|
|
53
|
+
};
|
|
54
|
+
readonly disallow: {
|
|
55
|
+
readonly type: "array";
|
|
56
|
+
readonly items: {
|
|
57
|
+
readonly type: "object";
|
|
58
|
+
};
|
|
59
|
+
readonly uniqueItems: true;
|
|
37
60
|
};
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
};
|
|
62
|
+
readonly additionalProperties: false;
|
|
40
63
|
};
|
|
41
64
|
readonly h3: {
|
|
42
|
-
readonly
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
readonly type: "object";
|
|
66
|
+
readonly properties: {
|
|
67
|
+
readonly allow: {
|
|
68
|
+
readonly type: "array";
|
|
69
|
+
readonly items: {
|
|
70
|
+
readonly type: "object";
|
|
71
|
+
};
|
|
72
|
+
readonly uniqueItems: true;
|
|
73
|
+
};
|
|
74
|
+
readonly disallow: {
|
|
75
|
+
readonly type: "array";
|
|
76
|
+
readonly items: {
|
|
77
|
+
readonly type: "object";
|
|
78
|
+
};
|
|
79
|
+
readonly uniqueItems: true;
|
|
48
80
|
};
|
|
49
|
-
|
|
50
|
-
|
|
81
|
+
};
|
|
82
|
+
readonly additionalProperties: false;
|
|
51
83
|
};
|
|
52
84
|
readonly h4: {
|
|
53
|
-
readonly
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
readonly type: "object";
|
|
86
|
+
readonly properties: {
|
|
87
|
+
readonly allow: {
|
|
88
|
+
readonly type: "array";
|
|
89
|
+
readonly items: {
|
|
90
|
+
readonly type: "object";
|
|
91
|
+
};
|
|
92
|
+
readonly uniqueItems: true;
|
|
59
93
|
};
|
|
60
|
-
readonly
|
|
61
|
-
|
|
94
|
+
readonly disallow: {
|
|
95
|
+
readonly type: "array";
|
|
96
|
+
readonly items: {
|
|
97
|
+
readonly type: "object";
|
|
98
|
+
};
|
|
99
|
+
readonly uniqueItems: true;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
readonly additionalProperties: false;
|
|
62
103
|
};
|
|
63
104
|
readonly h5: {
|
|
64
|
-
readonly
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
105
|
+
readonly type: "object";
|
|
106
|
+
readonly properties: {
|
|
107
|
+
readonly allow: {
|
|
108
|
+
readonly type: "array";
|
|
109
|
+
readonly items: {
|
|
110
|
+
readonly type: "object";
|
|
111
|
+
};
|
|
112
|
+
readonly uniqueItems: true;
|
|
113
|
+
};
|
|
114
|
+
readonly disallow: {
|
|
115
|
+
readonly type: "array";
|
|
116
|
+
readonly items: {
|
|
117
|
+
readonly type: "object";
|
|
118
|
+
};
|
|
119
|
+
readonly uniqueItems: true;
|
|
70
120
|
};
|
|
71
|
-
|
|
72
|
-
|
|
121
|
+
};
|
|
122
|
+
readonly additionalProperties: false;
|
|
73
123
|
};
|
|
74
124
|
readonly h6: {
|
|
75
|
-
readonly
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
125
|
+
readonly type: "object";
|
|
126
|
+
readonly properties: {
|
|
127
|
+
readonly allow: {
|
|
128
|
+
readonly type: "array";
|
|
129
|
+
readonly items: {
|
|
130
|
+
readonly type: "object";
|
|
131
|
+
};
|
|
132
|
+
readonly uniqueItems: true;
|
|
133
|
+
};
|
|
134
|
+
readonly disallow: {
|
|
135
|
+
readonly type: "array";
|
|
136
|
+
readonly items: {
|
|
137
|
+
readonly type: "object";
|
|
138
|
+
};
|
|
139
|
+
readonly uniqueItems: true;
|
|
81
140
|
};
|
|
82
|
-
|
|
83
|
-
|
|
141
|
+
};
|
|
142
|
+
readonly additionalProperties: false;
|
|
84
143
|
};
|
|
85
144
|
};
|
|
86
145
|
readonly additionalProperties: false;
|
|
87
146
|
}];
|
|
88
147
|
readonly defaultOptions: [{
|
|
89
|
-
readonly h1:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
readonly
|
|
94
|
-
|
|
148
|
+
readonly h1: {
|
|
149
|
+
readonly allow: [RegExp];
|
|
150
|
+
readonly disallow: [];
|
|
151
|
+
};
|
|
152
|
+
readonly h2: {
|
|
153
|
+
readonly allow: [RegExp];
|
|
154
|
+
readonly disallow: [];
|
|
155
|
+
};
|
|
156
|
+
readonly h3: {
|
|
157
|
+
readonly allow: [RegExp];
|
|
158
|
+
readonly disallow: [];
|
|
159
|
+
};
|
|
160
|
+
readonly h4: {
|
|
161
|
+
readonly allow: [RegExp];
|
|
162
|
+
readonly disallow: [];
|
|
163
|
+
};
|
|
164
|
+
readonly h5: {
|
|
165
|
+
readonly allow: [RegExp];
|
|
166
|
+
readonly disallow: [];
|
|
167
|
+
};
|
|
168
|
+
readonly h6: {
|
|
169
|
+
readonly allow: [RegExp];
|
|
170
|
+
readonly disallow: [];
|
|
171
|
+
};
|
|
95
172
|
}];
|
|
96
173
|
readonly messages: {
|
|
97
|
-
readonly allowHeading: "The heading
|
|
98
|
-
readonly
|
|
174
|
+
readonly allowHeading: "The level {{ depth }} heading `{{ heading }}` is not in the list of allowed headings. (Allow: {{ allow }}).";
|
|
175
|
+
readonly disallowHeading: "The level {{ depth }} heading `{{ heading }}` is in the list of disallowed headings. (Disallow: {{ disallow }}).";
|
|
99
176
|
};
|
|
100
177
|
readonly language: "markdown";
|
|
101
178
|
readonly dialects: ["commonmark", "gfm"];
|
|
@@ -107,7 +184,7 @@ declare const _default: {
|
|
|
107
184
|
Node: import("mdast").Node;
|
|
108
185
|
MessageIds: MessageIds;
|
|
109
186
|
}>) => {
|
|
110
|
-
heading(node:
|
|
187
|
+
heading(node: Heading): void;
|
|
111
188
|
};
|
|
112
189
|
};
|
|
113
190
|
export default _default;
|
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Rule to enforce the use of allowed
|
|
2
|
+
* @fileoverview Rule to enforce the use of allowed or disallowed headings.
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
|
-
// --------------------------------------------------------------------------------
|
|
6
|
-
// Import
|
|
7
|
-
// --------------------------------------------------------------------------------
|
|
8
5
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
9
6
|
// --------------------------------------------------------------------------------
|
|
10
|
-
//
|
|
7
|
+
// Helper
|
|
11
8
|
// --------------------------------------------------------------------------------
|
|
12
|
-
const
|
|
9
|
+
const statefulRegexFlagRegex = /[gy]/u;
|
|
10
|
+
const headingOptionsSchema = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
allow: {
|
|
14
|
+
type: 'array',
|
|
15
|
+
items: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
},
|
|
18
|
+
uniqueItems: true,
|
|
19
|
+
},
|
|
20
|
+
disallow: {
|
|
21
|
+
type: 'array',
|
|
22
|
+
items: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
},
|
|
25
|
+
uniqueItems: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Tests a regex without mutating the state stored in its `lastIndex`.
|
|
32
|
+
* @param regex Regex to test.
|
|
33
|
+
* @param text Text to test.
|
|
34
|
+
* @returns Whether the regex matches the text.
|
|
35
|
+
*/
|
|
36
|
+
function testRegexStateless(regex, text) {
|
|
37
|
+
return statefulRegexFlagRegex.test(regex.flags)
|
|
38
|
+
? new RegExp(regex).test(text)
|
|
39
|
+
: regex.test(text);
|
|
40
|
+
}
|
|
13
41
|
// --------------------------------------------------------------------------------
|
|
14
42
|
// Rule Definition
|
|
15
43
|
// --------------------------------------------------------------------------------
|
|
@@ -17,7 +45,7 @@ export default {
|
|
|
17
45
|
meta: {
|
|
18
46
|
type: 'problem',
|
|
19
47
|
docs: {
|
|
20
|
-
description: 'Enforce the use of allowed
|
|
48
|
+
description: 'Enforce the use of allowed or disallowed headings',
|
|
21
49
|
url: URL_RULE_DOCS('allow-heading'),
|
|
22
50
|
recommended: false,
|
|
23
51
|
stylistic: false,
|
|
@@ -26,100 +54,35 @@ export default {
|
|
|
26
54
|
{
|
|
27
55
|
type: 'object',
|
|
28
56
|
properties: {
|
|
29
|
-
h1:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type: 'array',
|
|
36
|
-
items: { type: 'string' },
|
|
37
|
-
uniqueItems: true,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
h2: {
|
|
42
|
-
oneOf: [
|
|
43
|
-
{
|
|
44
|
-
enum: [false],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
type: 'array',
|
|
48
|
-
items: { type: 'string' },
|
|
49
|
-
uniqueItems: true,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
h3: {
|
|
54
|
-
oneOf: [
|
|
55
|
-
{
|
|
56
|
-
enum: [false],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: 'array',
|
|
60
|
-
items: { type: 'string' },
|
|
61
|
-
uniqueItems: true,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
h4: {
|
|
66
|
-
oneOf: [
|
|
67
|
-
{
|
|
68
|
-
enum: [false],
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: 'array',
|
|
72
|
-
items: { type: 'string' },
|
|
73
|
-
uniqueItems: true,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
},
|
|
77
|
-
h5: {
|
|
78
|
-
oneOf: [
|
|
79
|
-
{
|
|
80
|
-
enum: [false],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
type: 'array',
|
|
84
|
-
items: { type: 'string' },
|
|
85
|
-
uniqueItems: true,
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
h6: {
|
|
90
|
-
oneOf: [
|
|
91
|
-
{
|
|
92
|
-
enum: [false],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
type: 'array',
|
|
96
|
-
items: { type: 'string' },
|
|
97
|
-
uniqueItems: true,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
},
|
|
57
|
+
h1: headingOptionsSchema,
|
|
58
|
+
h2: headingOptionsSchema,
|
|
59
|
+
h3: headingOptionsSchema,
|
|
60
|
+
h4: headingOptionsSchema,
|
|
61
|
+
h5: headingOptionsSchema,
|
|
62
|
+
h6: headingOptionsSchema,
|
|
101
63
|
},
|
|
102
64
|
additionalProperties: false,
|
|
103
65
|
},
|
|
104
66
|
],
|
|
105
67
|
defaultOptions: [
|
|
106
68
|
{
|
|
107
|
-
h1:
|
|
108
|
-
h2:
|
|
109
|
-
h3:
|
|
110
|
-
h4:
|
|
111
|
-
h5:
|
|
112
|
-
h6:
|
|
69
|
+
h1: { allow: [/.*/u], disallow: [] },
|
|
70
|
+
h2: { allow: [/.*/u], disallow: [] },
|
|
71
|
+
h3: { allow: [/.*/u], disallow: [] },
|
|
72
|
+
h4: { allow: [/.*/u], disallow: [] },
|
|
73
|
+
h5: { allow: [/.*/u], disallow: [] },
|
|
74
|
+
h6: { allow: [/.*/u], disallow: [] },
|
|
113
75
|
},
|
|
114
76
|
],
|
|
115
77
|
messages: {
|
|
116
|
-
allowHeading: 'The heading
|
|
117
|
-
|
|
78
|
+
allowHeading: 'The level {{ depth }} heading `{{ heading }}` is not in the list of allowed headings. (Allow: {{ allow }}).',
|
|
79
|
+
disallowHeading: 'The level {{ depth }} heading `{{ heading }}` is in the list of disallowed headings. (Disallow: {{ disallow }}).',
|
|
118
80
|
},
|
|
119
81
|
language: 'markdown',
|
|
120
82
|
dialects: ['commonmark', 'gfm'],
|
|
121
83
|
},
|
|
122
84
|
create(context) {
|
|
85
|
+
const { sourceCode } = context;
|
|
123
86
|
const [{ h1, h2, h3, h4, h5, h6 }] = context.options;
|
|
124
87
|
const headingMap = {
|
|
125
88
|
1: h1,
|
|
@@ -131,28 +94,28 @@ export default {
|
|
|
131
94
|
};
|
|
132
95
|
return {
|
|
133
96
|
heading(node) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (expectedHeadingTexts === false)
|
|
139
|
-
return;
|
|
140
|
-
if (expectedHeadingTexts.length === 0) {
|
|
97
|
+
const { depth } = node;
|
|
98
|
+
const { allow, disallow } = headingMap[depth];
|
|
99
|
+
const headingText = sourceCode.getText(node);
|
|
100
|
+
if (!allow.some(regex => testRegexStateless(regex, headingText))) {
|
|
141
101
|
context.report({
|
|
142
102
|
node,
|
|
143
|
-
messageId: '
|
|
103
|
+
messageId: 'allowHeading',
|
|
144
104
|
data: {
|
|
145
|
-
depth
|
|
105
|
+
depth,
|
|
106
|
+
heading: headingText,
|
|
107
|
+
allow: allow.map(regex => `\`${regex}\``).join(', '),
|
|
146
108
|
},
|
|
147
109
|
});
|
|
148
110
|
}
|
|
149
|
-
|
|
111
|
+
if (disallow.some(regex => testRegexStateless(regex, headingText))) {
|
|
150
112
|
context.report({
|
|
151
113
|
node,
|
|
152
|
-
messageId: '
|
|
114
|
+
messageId: 'disallowHeading',
|
|
153
115
|
data: {
|
|
154
|
-
|
|
155
|
-
|
|
116
|
+
depth,
|
|
117
|
+
heading: headingText,
|
|
118
|
+
disallow: disallow.map(regex => `\`${regex}\``).join(', '),
|
|
156
119
|
},
|
|
157
120
|
});
|
|
158
121
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
5
|
import { normalizeIdentifier } from 'micromark-util-normalize-identifier';
|
|
6
|
-
import { getElementsByTagName } from '../core/
|
|
6
|
+
import { getElementsByTagName } from '../core/utils/index.js';
|
|
7
7
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
8
8
|
// --------------------------------------------------------------------------------
|
|
9
9
|
// Rule Definition
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
5
|
import { normalizeIdentifier } from 'micromark-util-normalize-identifier';
|
|
6
|
-
import { getElementsByTagName } from '../core/
|
|
6
|
+
import { getElementsByTagName } from '../core/utils/index.js';
|
|
7
7
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
8
8
|
// --------------------------------------------------------------------------------
|
|
9
9
|
// Rule Definition
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// --------------------------------------------------------------------------------
|
|
15
15
|
// Import
|
|
16
16
|
// --------------------------------------------------------------------------------
|
|
17
|
-
import { isBlankLine } from '../core/
|
|
17
|
+
import { isBlankLine } from '../core/utils/index.js';
|
|
18
18
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
19
19
|
// --------------------------------------------------------------------------------
|
|
20
20
|
// Helper
|
package/build/rules/index.d.ts
CHANGED
|
@@ -1,4 +1,182 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
'allow-heading': {
|
|
3
|
+
readonly meta: {
|
|
4
|
+
readonly type: "problem";
|
|
5
|
+
readonly docs: {
|
|
6
|
+
readonly description: "Enforce the use of allowed or disallowed headings";
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly recommended: false;
|
|
9
|
+
readonly stylistic: false;
|
|
10
|
+
};
|
|
11
|
+
readonly schema: [{
|
|
12
|
+
readonly type: "object";
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly h1: {
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
readonly properties: {
|
|
17
|
+
readonly allow: {
|
|
18
|
+
readonly type: "array";
|
|
19
|
+
readonly items: {
|
|
20
|
+
readonly type: "object";
|
|
21
|
+
};
|
|
22
|
+
readonly uniqueItems: true;
|
|
23
|
+
};
|
|
24
|
+
readonly disallow: {
|
|
25
|
+
readonly type: "array";
|
|
26
|
+
readonly items: {
|
|
27
|
+
readonly type: "object";
|
|
28
|
+
};
|
|
29
|
+
readonly uniqueItems: true;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly additionalProperties: false;
|
|
33
|
+
};
|
|
34
|
+
readonly h2: {
|
|
35
|
+
readonly type: "object";
|
|
36
|
+
readonly properties: {
|
|
37
|
+
readonly allow: {
|
|
38
|
+
readonly type: "array";
|
|
39
|
+
readonly items: {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
};
|
|
42
|
+
readonly uniqueItems: true;
|
|
43
|
+
};
|
|
44
|
+
readonly disallow: {
|
|
45
|
+
readonly type: "array";
|
|
46
|
+
readonly items: {
|
|
47
|
+
readonly type: "object";
|
|
48
|
+
};
|
|
49
|
+
readonly uniqueItems: true;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
readonly additionalProperties: false;
|
|
53
|
+
};
|
|
54
|
+
readonly h3: {
|
|
55
|
+
readonly type: "object";
|
|
56
|
+
readonly properties: {
|
|
57
|
+
readonly allow: {
|
|
58
|
+
readonly type: "array";
|
|
59
|
+
readonly items: {
|
|
60
|
+
readonly type: "object";
|
|
61
|
+
};
|
|
62
|
+
readonly uniqueItems: true;
|
|
63
|
+
};
|
|
64
|
+
readonly disallow: {
|
|
65
|
+
readonly type: "array";
|
|
66
|
+
readonly items: {
|
|
67
|
+
readonly type: "object";
|
|
68
|
+
};
|
|
69
|
+
readonly uniqueItems: true;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly additionalProperties: false;
|
|
73
|
+
};
|
|
74
|
+
readonly h4: {
|
|
75
|
+
readonly type: "object";
|
|
76
|
+
readonly properties: {
|
|
77
|
+
readonly allow: {
|
|
78
|
+
readonly type: "array";
|
|
79
|
+
readonly items: {
|
|
80
|
+
readonly type: "object";
|
|
81
|
+
};
|
|
82
|
+
readonly uniqueItems: true;
|
|
83
|
+
};
|
|
84
|
+
readonly disallow: {
|
|
85
|
+
readonly type: "array";
|
|
86
|
+
readonly items: {
|
|
87
|
+
readonly type: "object";
|
|
88
|
+
};
|
|
89
|
+
readonly uniqueItems: true;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
readonly additionalProperties: false;
|
|
93
|
+
};
|
|
94
|
+
readonly h5: {
|
|
95
|
+
readonly type: "object";
|
|
96
|
+
readonly properties: {
|
|
97
|
+
readonly allow: {
|
|
98
|
+
readonly type: "array";
|
|
99
|
+
readonly items: {
|
|
100
|
+
readonly type: "object";
|
|
101
|
+
};
|
|
102
|
+
readonly uniqueItems: true;
|
|
103
|
+
};
|
|
104
|
+
readonly disallow: {
|
|
105
|
+
readonly type: "array";
|
|
106
|
+
readonly items: {
|
|
107
|
+
readonly type: "object";
|
|
108
|
+
};
|
|
109
|
+
readonly uniqueItems: true;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
readonly additionalProperties: false;
|
|
113
|
+
};
|
|
114
|
+
readonly h6: {
|
|
115
|
+
readonly type: "object";
|
|
116
|
+
readonly properties: {
|
|
117
|
+
readonly allow: {
|
|
118
|
+
readonly type: "array";
|
|
119
|
+
readonly items: {
|
|
120
|
+
readonly type: "object";
|
|
121
|
+
};
|
|
122
|
+
readonly uniqueItems: true;
|
|
123
|
+
};
|
|
124
|
+
readonly disallow: {
|
|
125
|
+
readonly type: "array";
|
|
126
|
+
readonly items: {
|
|
127
|
+
readonly type: "object";
|
|
128
|
+
};
|
|
129
|
+
readonly uniqueItems: true;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
readonly additionalProperties: false;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
readonly additionalProperties: false;
|
|
136
|
+
}];
|
|
137
|
+
readonly defaultOptions: [{
|
|
138
|
+
readonly h1: {
|
|
139
|
+
readonly allow: [RegExp];
|
|
140
|
+
readonly disallow: [];
|
|
141
|
+
};
|
|
142
|
+
readonly h2: {
|
|
143
|
+
readonly allow: [RegExp];
|
|
144
|
+
readonly disallow: [];
|
|
145
|
+
};
|
|
146
|
+
readonly h3: {
|
|
147
|
+
readonly allow: [RegExp];
|
|
148
|
+
readonly disallow: [];
|
|
149
|
+
};
|
|
150
|
+
readonly h4: {
|
|
151
|
+
readonly allow: [RegExp];
|
|
152
|
+
readonly disallow: [];
|
|
153
|
+
};
|
|
154
|
+
readonly h5: {
|
|
155
|
+
readonly allow: [RegExp];
|
|
156
|
+
readonly disallow: [];
|
|
157
|
+
};
|
|
158
|
+
readonly h6: {
|
|
159
|
+
readonly allow: [RegExp];
|
|
160
|
+
readonly disallow: [];
|
|
161
|
+
};
|
|
162
|
+
}];
|
|
163
|
+
readonly messages: {
|
|
164
|
+
readonly allowHeading: "The level {{ depth }} heading `{{ heading }}` is not in the list of allowed headings. (Allow: {{ allow }}).";
|
|
165
|
+
readonly disallowHeading: "The level {{ depth }} heading `{{ heading }}` is in the list of disallowed headings. (Disallow: {{ disallow }}).";
|
|
166
|
+
};
|
|
167
|
+
readonly language: "markdown";
|
|
168
|
+
readonly dialects: ["commonmark", "gfm"];
|
|
169
|
+
};
|
|
170
|
+
readonly create: (context: import("@eslint/core").RuleContext<{
|
|
171
|
+
LangOptions: import("@eslint/markdown").MarkdownLanguageOptions;
|
|
172
|
+
Code: import("@eslint/markdown").MarkdownSourceCode;
|
|
173
|
+
RuleOptions: [Record<"h1" | "h2" | "h3" | "h4" | "h5" | "h6", import("./allow-heading.js").HeadingOptions>];
|
|
174
|
+
Node: import("mdast").Node;
|
|
175
|
+
MessageIds: "allowHeading" | "disallowHeading";
|
|
176
|
+
}>) => {
|
|
177
|
+
heading(node: import("mdast").Heading): void;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
2
180
|
'allow-image-url': {
|
|
3
181
|
readonly meta: {
|
|
4
182
|
readonly type: "problem";
|
package/build/rules/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint sort-imports: 'error', sort-keys: 'error' */
|
|
2
2
|
// TODO: Re-enable the commented-out rules once they stabilize.
|
|
3
|
-
|
|
3
|
+
import allowHeading from './allow-heading.js';
|
|
4
4
|
import allowImageUrl from './allow-image-url.js';
|
|
5
5
|
import allowLinkUrl from './allow-link-url.js';
|
|
6
6
|
import codeLangShorthand from './code-lang-shorthand.js';
|
|
@@ -28,7 +28,7 @@ import requireHeadingId from './require-heading-id.js';
|
|
|
28
28
|
import requireImageTitle from './require-image-title.js';
|
|
29
29
|
import requireLinkTitle from './require-link-title.js';
|
|
30
30
|
export default {
|
|
31
|
-
|
|
31
|
+
'allow-heading': allowHeading,
|
|
32
32
|
'allow-image-url': allowImageUrl,
|
|
33
33
|
'allow-link-url': allowLinkUrl,
|
|
34
34
|
'code-lang-shorthand': codeLangShorthand,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// --------------------------------------------------------------------------------
|
|
7
7
|
// Import
|
|
8
8
|
// --------------------------------------------------------------------------------
|
|
9
|
-
import { isBlankLine, SkipRanges } from '../core/
|
|
9
|
+
import { isBlankLine, SkipRanges } from '../core/utils/index.js';
|
|
10
10
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
11
11
|
// --------------------------------------------------------------------------------
|
|
12
12
|
// Rule Definition
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// --------------------------------------------------------------------------------
|
|
6
6
|
// Import
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
|
-
import { SkipRanges } from '../core/
|
|
8
|
+
import { SkipRanges } from '../core/utils/index.js';
|
|
9
9
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
10
10
|
// --------------------------------------------------------------------------------
|
|
11
11
|
// Helper
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// --------------------------------------------------------------------------------
|
|
6
6
|
// Import
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
|
-
import { SkipRanges } from '../core/
|
|
8
|
+
import { SkipRanges } from '../core/utils/index.js';
|
|
9
9
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
10
10
|
// --------------------------------------------------------------------------------
|
|
11
11
|
// Helper
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// --------------------------------------------------------------------------------
|
|
6
6
|
// Import
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
|
-
import { SkipRanges } from '../core/
|
|
8
|
+
import { SkipRanges } from '../core/utils/index.js';
|
|
9
9
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
10
10
|
// --------------------------------------------------------------------------------
|
|
11
11
|
// Helper
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// --------------------------------------------------------------------------------
|
|
6
6
|
// Import
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
|
-
import { SkipRanges } from '../core/
|
|
8
|
+
import { SkipRanges } from '../core/utils/index.js';
|
|
9
9
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
10
10
|
// --------------------------------------------------------------------------------
|
|
11
11
|
// Helper
|
package/build/rules/no-tab.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// --------------------------------------------------------------------------------
|
|
6
6
|
// Import
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
|
-
import { SkipRanges } from '../core/
|
|
8
|
+
import { SkipRanges } from '../core/utils/index.js';
|
|
9
9
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
10
10
|
// --------------------------------------------------------------------------------
|
|
11
11
|
// Helper
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview Rule to disallow URL trailing slash.
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
|
-
import { getElementsByTagName } from '../core/
|
|
5
|
+
import { getElementsByTagName } from '../core/utils/index.js';
|
|
6
6
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
8
|
// Helper
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview Rule to enforce the use of heading IDs.
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
|
-
import { escapeStringRegexp } from '../core/
|
|
5
|
+
import { escapeStringRegexp } from '../core/utils/index.js';
|
|
6
6
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
7
7
|
// --------------------------------------------------------------------------------
|
|
8
8
|
// Rule Definition
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
5
|
import { normalizeIdentifier } from 'micromark-util-normalize-identifier';
|
|
6
|
-
import { getElementsByTagName } from '../core/
|
|
6
|
+
import { getElementsByTagName } from '../core/utils/index.js';
|
|
7
7
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
8
8
|
// --------------------------------------------------------------------------------
|
|
9
9
|
// Rule Definition
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @author lumir(lumirlumir)
|
|
4
4
|
*/
|
|
5
5
|
import { normalizeIdentifier } from 'micromark-util-normalize-identifier';
|
|
6
|
-
import { getElementsByTagName } from '../core/
|
|
6
|
+
import { getElementsByTagName } from '../core/utils/index.js';
|
|
7
7
|
import { URL_RULE_DOCS } from '../core/constants.js';
|
|
8
8
|
// --------------------------------------------------------------------------------
|
|
9
9
|
// Rule Definition
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|