From f1219dbeeccb8bbd6c1652a09a9d35cd629cb1cb Mon Sep 17 00:00:00 2001 From: azu Date: Thu, 3 Jan 2019 15:21:11 +0900 Subject: [PATCH] fix(wrap): fix arguments order --- README.md | 4 ++-- src/wrap-report-handler.ts | 8 +++----- test/wrap-report-handler-test.ts | 16 ++++++++-------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ac6cf1e..b1a81c8 100644 --- a/README.md +++ b/README.md @@ -145,9 +145,9 @@ Example: ignore `BlockQuote` and `Code` node. import { wrapReportHandler } from "textlint-rule-helper"; const reporter = function (context) { const { Syntax, getSource } = context; - return wrapReportHandler({ + return wrapReportHandler(context, { ignoreNodeTypes: [Syntax.BlockQuote, Syntax.Code] - }, context, report => { // <= wrap version of context.report + },report => { // <= wrap version of context.report // handler should return a rule handler object return { [Syntax.Paragraph](node) { diff --git a/src/wrap-report-handler.ts b/src/wrap-report-handler.ts index dba04ba..8d5c3d1 100644 --- a/src/wrap-report-handler.ts +++ b/src/wrap-report-handler.ts @@ -17,16 +17,14 @@ export interface wrapReportHandlerOptions { /** * - * @param options * @param context + * @param options * @param handler */ export function wrapReportHandler, R extends TextlintRuleReportHandler>( - options: wrapReportHandlerOptions, context: T, - handler: ( - report: (node: AnyTxtNode, ruleError: TextlintRuleError) => void - ) => R + options: wrapReportHandlerOptions, + handler: (report: (node: AnyTxtNode, ruleError: TextlintRuleError) => void) => R ) { const ignoreNodeTypes = options.ignoreNodeTypes || []; const ignoreNodeManager = new IgnoreNodeManager(); diff --git a/test/wrap-report-handler-test.ts b/test/wrap-report-handler-test.ts index fc51561..1b6ccad 100644 --- a/test/wrap-report-handler-test.ts +++ b/test/wrap-report-handler-test.ts @@ -15,9 +15,9 @@ describe("wrapReportHandler", function () { textlint.setupRules({ "rule-key": function (context) { const { RuleError } = context; - return wrapReportHandler({ + return wrapReportHandler(context, { ignoreNodeTypes: Object.keys(ASTNodeTypes).concat("my-type") - }, context, report => { + }, report => { return { ...(Object.keys(ASTNodeTypes).reduce((object, key) => { object[key] = (node: AnyTxtNode) => { @@ -65,9 +65,9 @@ code let isCalled = false; textlint.setupRules({ "rule-key": function (context: any) { - return wrapReportHandler({ + return wrapReportHandler(context, { ignoreNodeTypes: [context.Syntax.BlockQuote, context.Syntax.Code] - }, context, _report => { + }, _report => { return { [context.Syntax.Paragraph]() { isCalled = true @@ -126,9 +126,9 @@ code textlint.setupRules({ "rule-key": function (context) { const { Syntax, getSource } = context; - return wrapReportHandler({ + return wrapReportHandler(context, { ignoreNodeTypes: [context.Syntax.Code] - }, context, report => { + }, report => { return { [Syntax.Paragraph](node) { const text = getSource(node); @@ -161,9 +161,9 @@ code textlint.setupRules({ "rule-key": function (context) { const { Syntax, RuleError } = context; - return wrapReportHandler({ + return wrapReportHandler(context, { ignoreNodeTypes: [context.Syntax.Code] - }, context, report => { + }, report => { return { [Syntax.Paragraph](node) { const text = context.getSource(node);