Skip to content

Commit

Permalink
fix(4.3.1): revert #76 (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Sep 29, 2020
1 parent bc2630b commit 602e9a0
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 45 deletions.
7 changes: 4 additions & 3 deletions src/4.3.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ function reporter(context) {
// 半角のかっこ()は使用しないで全角のかっこを使用する
const text = getSource(node);
const matchRegExps = [
rx`([\(\)])(?:.*${japaneseRegExp}+.*)([\(\)])`,
rx`([\(\)])(?:.*${japaneseRegExp})`,
rx`(?:${japaneseRegExp}.*)([\(\)])`
// FIXME: https://github.com/textlint-ja/textlint-rule-preset-JTF-style/issues/79
// rx`([\(\)])(?:${japaneseRegExp}+)([\(\)])`,
// rx`([\(\)])(?:${japaneseRegExp})`,
rx`(?:${japaneseRegExp})([\(\)])`
];
matchRegExps.forEach(matchRegExp => {
matchCaptureGroupAll(text, matchRegExp).forEach(match => {
Expand Down
70 changes: 39 additions & 31 deletions test/4.3.1-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import TextLintTester from "textlint-tester";
import rule from "../src/4.3.1.js";
var tester = new TextLintTester();
tester.run("4.3.1.丸かっこ()", rule, {
valid: ["クォーク(物質の素粒子)", "(物質の素粒子)", "(npm 2.x以上をインストールしている必要があります)"],
valid: [
"クォーク(物質の素粒子)",
"(物質の素粒子)",
"(npm 2.x以上をインストールしている必要があります)",
// 英語のみの半角括弧は許可
// https://github.com/textlint-ja/textlint-rule-preset-JTF-style/issues/79
"これは (English text in half-width parens) です。"
],
invalid: [
{
// 半角かっこ
Expand All @@ -21,36 +28,37 @@ tester.run("4.3.1.丸かっこ()", rule, {
}
]
},
{
// 半角かっこ
text: "(物質の素粒子)",
output: "(物質の素粒子)",
errors: [
{
message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
column: 1
},
{
message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
column: 8
}
]
},
{
// 半角かっこ
text: "(npm 2.x以上をインストールしている必要があります)",
output: "(npm 2.x以上をインストールしている必要があります)",
errors: [
{
message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
column: 1
},
{
message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
column: 29
}
]
},
// // FIXME: https://github.com/textlint-ja/textlint-rule-preset-JTF-style/issues/79
// {
// // 半角かっこ
// text: "(物質の素粒子)",
// output: "(物質の素粒子)",
// errors: [
// {
// message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
// column: 1
// },
// {
// message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
// column: 8
// }
// ]
// },
// {
// // 半角かっこ
// text: "(npm 2.x以上をインストールしている必要があります)",
// output: "(npm 2.x以上をインストールしている必要があります)",
// errors: [
// {
// message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
// column: 1
// },
// {
// message: "半角のかっこ()が使用されています。全角のかっこ()を使用してください。",
// column: 29
// }
// ]
// },
{
// 半角かっこ
text: "例)test",
Expand Down
2 changes: 1 addition & 1 deletion test/fixer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("fixer-test", function() {
for (var i = 0; i < inputs.length; i++) {
const input = inputs[i];
const output = outputs[i];
assert.equal(input, output);
assert.strictEqual(input, output);
}
});
});
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ A氏は「5月に新製品を発売します。」と述べました。

クォーク(物質の素粒子)

(物質の素粒子)

(npm 2.x以上をインストールしている必要があります)

例)test

半角[かっこ
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ A氏は「5月に新製品を発売します」と述べました。

クォーク(物質の素粒子)

(物質の素粒子)

(npm 2.x以上をインストールしている必要があります)

例)test

半角[かっこ
Expand Down
4 changes: 2 additions & 2 deletions tool/create-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const RESULT = {
function processFile(filePath) {
const contents = fs.readFileSync(filePath, "utf-8");
const lines = contents.split(/\n/);
const inputRegExp = /text:\s*?"(.*?)"/;
const outputRegExp = /output:\s*?"(.*?)"/;
const inputRegExp = /^\s+text:\s*?"(.*?)"/;
const outputRegExp = /^\s+output:\s*?"(.*?)"/;
lines.forEach(function(line, index) {
const nextLine = lines[index + 1];
if (inputRegExp.test(line) && outputRegExp.test(nextLine)) {
Expand Down

0 comments on commit 602e9a0

Please sign in to comment.