Skip to content

Commit ca29203

Browse files
authored
fix(rule): prhのインライン化に対応 (#69)
辞書ファイルをインライン化したため、ブラウザでも動作するように修正
2 parents 0d03c8d + 3556143 commit ca29203

File tree

8 files changed

+1455
-896
lines changed

8 files changed

+1455
-896
lines changed

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "azu",
1212
"license": "MIT",
1313
"devDependencies": {
14-
"textlint": "^8.2.1"
14+
"textlint": "^11.4.0"
1515
},
1616
"dependencies": {
1717
"textlint-rule-preset-jtf-style": "file:.."

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@
3838
"translation"
3939
],
4040
"devDependencies": {
41-
"glob": "^7.1.2",
42-
"husky": "^1.3.1",
43-
"lint-staged": "^8.1.1",
44-
"prettier": "^1.7.0",
45-
"textlint-scripts": "^2.1.0"
41+
"glob": "^7.1.4",
42+
"husky": "^3.0.9",
43+
"lint-staged": "^9.4.2",
44+
"prettier": "^1.18.2",
45+
"textlint-scripts": "^3.0.0"
4646
},
4747
"dependencies": {
4848
"analyze-desumasu-dearu": "^2.1.2",
4949
"japanese-numerals-to-number": "^1.0.2",
50-
"match-index": "^1.0.1",
50+
"match-index": "^1.0.3",
5151
"moji": "^0.5.1",
5252
"regexp.prototype.flags": "^1.1.1",
5353
"regx": "^1.0.4",
5454
"sorted-joyo-kanji": "^0.2.0",
5555
"textlint-rule-helper": "^2.0.0",
56-
"textlint-rule-prh": "^5.0.0"
56+
"textlint-rule-prh": "^5.2.1"
5757
},
5858
"peerDependencies": {
5959
"textlint": ">= 5.6.0"

src/2.1.5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Halfwidth Katakana variants(半角片仮名)
1010
http://www.asahi-net.or.jp/~ax2s-kmtn/ref/unicode/uff00.html
1111
*/
1212
import { isUserWrittenNode } from "./util/node-util";
13-
import { hanKarakanaRegExp } from "./util/regexp";
1413
import prh from "textlint-rule-prh";
1514
import path from "path";
15+
import fs from "fs";
1616
import { matchCaptureGroupAll } from "match-index";
1717
import moji from "moji";
1818
/**
@@ -30,7 +30,7 @@ function reporter(context) {
3030
let { Syntax, RuleError, fixer, report, getSource } = context;
3131
// 辞書ベースのカタカタ表記のチェックを行う
3232
let dictRule = prh.fixer(context, {
33-
rulePaths: [path.join(__dirname, "..", "dict", "2.1.5.yml")]
33+
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.1.5.yml"), "utf-8")]
3434
});
3535
let originalStrRule = dictRule[Syntax.Str];
3636
// 半角カタカナの使用をチェックする

src/2.1.6.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
カタカナの長音表記のルールについては、『外来語(カタカナ)表記ガイドライン第 2 版』(テクニカルコミュニケーター協会、2008 年)に従います。
77
『日本語スタイルガイド』(テクニカルコミュニケーター協会編著)の 207 ページ「付録 2 外来語(カタカナ)表記ガイドライン」も参考にします。
88
*/
9-
import { isUserWrittenNode } from "./util/node-util";
10-
import prh from "textlint-rule-prh";
9+
import fs from "fs";
1110
import path from "path";
11+
import prh from "textlint-rule-prh";
12+
1213
module.exports = function(context) {
1314
// 辞書ベースのカタカナ末尾の長音のチェックを行う
1415
return prh.fixer(context, {
15-
rulePaths: [path.join(__dirname, "..", "dict", "2.1.6.yml")]
16+
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.1.6.yml"), "utf-8")]
1617
});
1718
};

src/2.2.1.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ JTFスタイルガイドは、ひらがなと漢字の使い分けについて
1414
用例集や用語集を作って表記の統一を図るのも有効な方法です。
1515
漢字を使用する傾向の強い特許、金融、法律の分野では、以下のひらがなを使用する語句について、漢字を使用する場合があります。
1616
*/
17-
import prh from "textlint-rule-prh";
17+
import fs from "fs";
1818
import path from "path";
19+
import prh from "textlint-rule-prh";
20+
1921
module.exports = function(context) {
2022
return prh.fixer(context, {
21-
rulePaths: [path.join(__dirname, "..", "dict", "2.2.1.yml")]
23+
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.2.1.yml"), "utf-8")]
2224
});
2325
};

src/2.2.3.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
*/
77
import prh from "textlint-rule-prh";
88
import path from "path";
9+
import fs from "fs";
910
module.exports = function(context) {
1011
return prh.fixer(context, {
11-
rulePaths: [path.join(__dirname, "..", "dict", "2.2.3.yml")]
12+
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.2.3.yml"), "utf-8")]
1213
});
1314
};

test/fixer-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import assert from "assert";
44
import preset from "../src/index";
55
import { TextLintCore } from "textlint";
6-
import * as fs from "fs";
6+
import fs from "fs";
7+
78
describe("fixer-test", function() {
89
it("should convert expected", function() {
910
const expected = fs.readFileSync(__dirname + "/fixtures/output.md", "utf-8");

0 commit comments

Comments
 (0)