Skip to content

Commit f1219db

Browse files
committed
fix(wrap): fix arguments order
1 parent b107ad4 commit f1219db

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ Example: ignore `BlockQuote` and `Code` node.
145145
import { wrapReportHandler } from "textlint-rule-helper";
146146
const reporter = function (context) {
147147
const { Syntax, getSource } = context;
148-
return wrapReportHandler({
148+
return wrapReportHandler(context, {
149149
ignoreNodeTypes: [Syntax.BlockQuote, Syntax.Code]
150-
}, context, report => { // <= wrap version of context.report
150+
},report => { // <= wrap version of context.report
151151
// handler should return a rule handler object
152152
return {
153153
[Syntax.Paragraph](node) {

src/wrap-report-handler.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ export interface wrapReportHandlerOptions {
1717

1818
/**
1919
*
20-
* @param options
2120
* @param context
21+
* @param options
2222
* @param handler
2323
*/
2424
export function wrapReportHandler<T extends Readonly<TextlintRuleContext>, R extends TextlintRuleReportHandler>(
25-
options: wrapReportHandlerOptions,
2625
context: T,
27-
handler: (
28-
report: (node: AnyTxtNode, ruleError: TextlintRuleError) => void
29-
) => R
26+
options: wrapReportHandlerOptions,
27+
handler: (report: (node: AnyTxtNode, ruleError: TextlintRuleError) => void) => R
3028
) {
3129
const ignoreNodeTypes = options.ignoreNodeTypes || [];
3230
const ignoreNodeManager = new IgnoreNodeManager();

test/wrap-report-handler-test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ describe("wrapReportHandler", function () {
1515
textlint.setupRules({
1616
"rule-key": function (context) {
1717
const { RuleError } = context;
18-
return wrapReportHandler({
18+
return wrapReportHandler(context, {
1919
ignoreNodeTypes: Object.keys(ASTNodeTypes).concat("my-type")
20-
}, context, report => {
20+
}, report => {
2121
return {
2222
...(Object.keys(ASTNodeTypes).reduce((object, key) => {
2323
object[key] = (node: AnyTxtNode) => {
@@ -65,9 +65,9 @@ code
6565
let isCalled = false;
6666
textlint.setupRules({
6767
"rule-key": function (context: any) {
68-
return wrapReportHandler({
68+
return wrapReportHandler(context, {
6969
ignoreNodeTypes: [context.Syntax.BlockQuote, context.Syntax.Code]
70-
}, context, _report => {
70+
}, _report => {
7171
return {
7272
[context.Syntax.Paragraph]() {
7373
isCalled = true
@@ -126,9 +126,9 @@ code
126126
textlint.setupRules({
127127
"rule-key": function (context) {
128128
const { Syntax, getSource } = context;
129-
return wrapReportHandler({
129+
return wrapReportHandler(context, {
130130
ignoreNodeTypes: [context.Syntax.Code]
131-
}, context, report => {
131+
}, report => {
132132
return {
133133
[Syntax.Paragraph](node) {
134134
const text = getSource(node);
@@ -161,9 +161,9 @@ code
161161
textlint.setupRules({
162162
"rule-key": function (context) {
163163
const { Syntax, RuleError } = context;
164-
return wrapReportHandler({
164+
return wrapReportHandler(context, {
165165
ignoreNodeTypes: [context.Syntax.Code]
166-
}, context, report => {
166+
}, report => {
167167
return {
168168
[Syntax.Paragraph](node) {
169169
const text = context.getSource(node);

0 commit comments

Comments
 (0)