Skip to content

Commit

Permalink
refactor: use isPlainStrNode helper (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
azu authored May 16, 2021
1 parent 56b7dfd commit 70267cc
Show file tree
Hide file tree
Showing 17 changed files with 1,866 additions and 1,813 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packages/*"
],
"devDependencies": {
"lerna": "3.22.1"
"lerna": "4.0.0"
},
"scripts": {
"build": "lerna run build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"dependencies": {
"match-index": "^1.0.3",
"textlint-rule-helper": "^2.1.1"
"textlint-rule-helper": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (!helper.isPlainStrNode(node)) {
return;
}
const text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"dependencies": {
"match-index": "^1.0.3",
"textlint-rule-helper": "^2.1.1"
"textlint-rule-helper": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (!helper.isPlainStrNode(node)) {
return;
}
const text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"dependencies": {
"match-index": "^1.0.3",
"regx": "^1.0.4",
"textlint-rule-helper": "^2.1.1"
"textlint-rule-helper": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (!helper.isPlainStrNode(node)) {
return;
}
const text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"dependencies": {
"match-index": "^1.0.3",
"textlint-rule-helper": "^2.1.1"
"textlint-rule-helper": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (!helper.isPlainStrNode(node)) {
return;
}
let text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"dependencies": {
"match-index": "^1.0.1",
"textlint-rule-helper": "^2.0.0"
"textlint-rule-helper": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (!helper.isPlainStrNode(node)) {
return;
}
let text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
"use strict";
import TextLintTester from "textlint-tester";
import rule from "../src/index";

var tester = new TextLintTester();
tester.run("疑問符(?)", rule, {
valid: [
"【原文】Does the reader understand the document?",
"【訳文】読者は文書の内容を理解しているでしょうか。",
"オプションを変更しますか?",
"A 社の成功の秘密とは? この本ではそれをご紹介します。",
"どう操作したらよいのか?というユーザーの疑問に答えます。"
"どう操作したらよいのか?というユーザーの疑問に答えます。",
"# どう操作したらよいのか?という",
"![どう操作したらよいのか?という](https://example.com)",
"[どう操作したらよいのか?という](https://example.com)",
"> どう操作したらよいのか?という",
"**どう操作したらよいのか?という**",
"[どう操作したらよいのか?という][]",
"[^どう操作したらよいのか?という]",
],
invalid: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/textlint-rule-ja-space-around-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"dependencies": {
"match-index": "^1.0.1",
"textlint-rule-helper": "^2.0.0"
"textlint-rule-helper": "^2.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/textlint-rule-ja-space-around-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
},
"dependencies": {
"match-index": "^1.0.1",
"textlint-rule-helper": "^2.0.0"
"textlint-rule-helper": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"dependencies": {
"match-index": "^1.0.1",
"textlint-rule-helper": "^2.0.0"
"textlint-rule-helper": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ function reporter(context, options = {}) {
};
return {
[Syntax.Str](node){
const isIgnoredParentNode = helper.isChildNode(node, [
Syntax.Header, Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis
]);
if (isIgnoredParentNode) {
if (!helper.isPlainStrNode(node)) {
return;
}
const text = getSource(node);
Expand Down
Loading

0 comments on commit 70267cc

Please sign in to comment.