Skip to content

Commit 9343679

Browse files
committed
fix(test): improve typing
1 parent 9079a04 commit 9343679

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

test/wrap-report-handler-test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@ describe("wrapReportHandler", function () {
1616
"rule-key": function (context) {
1717
const { RuleError } = context;
1818
return wrapReportHandler({
19-
ignoreNodeTypes: Object.keys(ASTNodeTypes)
19+
ignoreNodeTypes: Object.keys(ASTNodeTypes).concat("my-type")
2020
}, context, report => {
2121
return {
2222
...(Object.keys(ASTNodeTypes).reduce((object, key) => {
2323
object[key] = (node: AnyTxtNode) => {
2424
report(node, new RuleError(node.type));
2525
};
2626
return object;
27-
}, {} as any))
27+
}, {} as any)),
28+
...{
29+
"my-type"(node) {
30+
report(node, new RuleError(node.type));
31+
}
32+
}
2833
};
2934
});
3035
} as TextlintRuleReporter
@@ -119,7 +124,7 @@ code
119124
},
120125
];
121126
textlint.setupRules({
122-
"rule-key": function (context: any) {
127+
"rule-key": function (context) {
123128
const { Syntax, getSource } = context;
124129
return wrapReportHandler({
125130
ignoreNodeTypes: [context.Syntax.Code]
@@ -136,7 +141,7 @@ code
136141
}
137142
}
138143
});
139-
}
144+
} as TextlintRuleReporter
140145
});
141146
const text = "123`456`789";
142147
return textlint.lintMarkdown(text).then((result) => {
@@ -154,7 +159,7 @@ code
154159
const text = "> Line 1\n"
155160
+ "> This is `code`.";
156161
textlint.setupRules({
157-
"rule-key": function (context: any) {
162+
"rule-key": function (context) {
158163
const { Syntax, RuleError } = context;
159164
return wrapReportHandler({
160165
ignoreNodeTypes: [context.Syntax.Code]
@@ -175,7 +180,7 @@ code
175180
}
176181
}
177182
});
178-
}
183+
} as TextlintRuleReporter
179184
});
180185
return textlint.lintMarkdown(text).then((result) => {
181186
const messages = result.messages;

0 commit comments

Comments
 (0)