Skip to content

Commit 85b6a21

Browse files
committed
fix(wrap): fix typing
1 parent 05b9646 commit 85b6a21

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/wrap-report-handler.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// MIT © 2018 azu
22
"use strict";
3-
import { TxtNode, TxtNodeType, TxtParentNode, AnyTxtNode } from "@textlint/ast-node-types";
4-
import { TextlintRuleError, TextlintRuleReportHandler } from "@textlint/types";
3+
import { AnyTxtNode, TxtNodeType } from "@textlint/ast-node-types";
4+
import { TextlintRuleContext, TextlintRuleError, TextlintRuleReportHandler } from "@textlint/types";
55
import RuleHelper from "./textlint-rule-helper";
66
import IgnoreNodeManager from "./IgnoreNodeManager";
77
import { SourceLocation } from "./SourceLocation";
@@ -16,28 +16,25 @@ export interface wrapOptions {
1616
ignoreNodeTypes: TxtNodeType[]
1717
}
1818

19-
export function wrapReportHandler<T extends Function, R extends TextlintRuleReportHandler>(
19+
export function wrapReportHandler<T extends TextlintRuleContext, R extends TextlintRuleReportHandler>(
2020
options: wrapOptions,
2121
context: T,
2222
handler: (
23-
report: (node: AnyTxtNode, ruleError: TextlintRuleError) => R
23+
report: (node: AnyTxtNode, ruleError: TextlintRuleError) => void
2424
) => R
2525
) {
2626
const ignoreNodeTypes = options.ignoreNodeTypes || [];
2727
const ignoreNodeManager = new IgnoreNodeManager();
2828
const ruleHelper = new RuleHelper(context);
29-
const text = (context as any).getSource();
29+
const text = context.getSource();
3030
const sourceLocation = new SourceLocation(text);
31-
const reportIfUnignored = function reportIfUnignored(...args: any[]): any | Promise<any> {
32-
const node: TxtNode | TxtParentNode = args[0];
33-
const ruleError: RuleErrorPadding = args[1];
34-
const index = sourceLocation.toAbsoluteLocation(node, ruleError);
35-
if (ignoreNodeManager.isIgnoredIndex(index)) {
36-
return;
37-
}
38-
return (context as any).report(...args);
31+
const reportIfUnignored = function reportIfUnignored(node: AnyTxtNode, ruleError: TextlintRuleError): void | Promise<any> {
32+
const index = sourceLocation.toAbsoluteLocation(node, ruleError);
33+
if (ignoreNodeManager.isIgnoredIndex(index)) {
34+
return;
3935
}
40-
;
36+
return context.report(node, ruleError);
37+
};
4138

4239
const handlers = handler(reportIfUnignored);
4340
Object.keys(handlers).forEach(nodeType => {

0 commit comments

Comments
 (0)