Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(rule): prhのインライン化に対応 #69

Merged
merged 3 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@
"translation"
],
"devDependencies": {
"glob": "^7.1.2",
"husky": "^1.3.1",
"lint-staged": "^8.1.1",
"prettier": "^1.7.0",
"textlint-scripts": "^2.1.0"
"glob": "^7.1.4",
"husky": "^3.0.0",
"lint-staged": "^9.2.0",
"prettier": "^1.18.2",
"textlint-scripts": "^3.0.0-beta.1"
},
"dependencies": {
"analyze-desumasu-dearu": "^2.1.2",
"japanese-numerals-to-number": "^1.0.2",
"match-index": "^1.0.1",
"match-index": "^1.0.3",
"moji": "^0.5.1",
"regexp.prototype.flags": "^1.1.1",
"regx": "^1.0.4",
"sorted-joyo-kanji": "^0.2.0",
"textlint-rule-helper": "^2.0.0",
"textlint-rule-prh": "^5.0.0"
"textlint-rule-prh": "^5.2.1"
},
"peerDependencies": {
"textlint": ">= 5.6.0"
Expand Down
4 changes: 2 additions & 2 deletions src/2.1.5.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Halfwidth Katakana variants(半角片仮名)
http://www.asahi-net.or.jp/~ax2s-kmtn/ref/unicode/uff00.html
*/
import { isUserWrittenNode } from "./util/node-util";
import { hanKarakanaRegExp } from "./util/regexp";
import prh from "textlint-rule-prh";
import path from "path";
import fs from "fs";
import { matchCaptureGroupAll } from "match-index";
import moji from "moji";
/**
Expand All @@ -30,7 +30,7 @@ function reporter(context) {
let { Syntax, RuleError, fixer, report, getSource } = context;
// 辞書ベースのカタカタ表記のチェックを行う
let dictRule = prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.1.5.yml")]
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.1.5.yml"), "utf-8")]
});
let originalStrRule = dictRule[Syntax.Str];
// 半角カタカナの使用をチェックする
Expand Down
7 changes: 4 additions & 3 deletions src/2.1.6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
カタカナの長音表記のルールについては、『外来語(カタカナ)表記ガイドライン第 2 版』(テクニカルコミュニケーター協会、2008 年)に従います。
『日本語スタイルガイド』(テクニカルコミュニケーター協会編著)の 207 ページ「付録 2 外来語(カタカナ)表記ガイドライン」も参考にします。
*/
import { isUserWrittenNode } from "./util/node-util";
import prh from "textlint-rule-prh";
import fs from "fs";
import path from "path";
import prh from "textlint-rule-prh";

module.exports = function(context) {
// 辞書ベースのカタカナ末尾の長音のチェックを行う
return prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.1.6.yml")]
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.1.6.yml"), "utf-8")]
});
};
6 changes: 4 additions & 2 deletions src/2.2.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ JTFスタイルガイドは、ひらがなと漢字の使い分けについて
用例集や用語集を作って表記の統一を図るのも有効な方法です。
漢字を使用する傾向の強い特許、金融、法律の分野では、以下のひらがなを使用する語句について、漢字を使用する場合があります。
*/
import prh from "textlint-rule-prh";
import fs from "fs";
import path from "path";
import prh from "textlint-rule-prh";

module.exports = function(context) {
return prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.2.1.yml")]
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.2.1.yml"), "utf-8")]
});
};
3 changes: 2 additions & 1 deletion src/2.2.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/
import prh from "textlint-rule-prh";
import path from "path";
import fs from "fs";
module.exports = function(context) {
return prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.2.3.yml")]
ruleContents: [fs.readFileSync(path.join(__dirname, "..", "dict", "2.2.3.yml"), "utf-8")]
});
};
3 changes: 2 additions & 1 deletion test/fixer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import assert from "assert";
import preset from "../src/index";
import { TextLintCore } from "textlint";
import * as fs from "fs";
import fs from "fs";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Experience-Monks/babel-plugin-static-fs#17
This PR fix the workaround.


describe("fixer-test", function() {
it("should convert expected", function() {
const expected = fs.readFileSync(__dirname + "/fixtures/output.md", "utf-8");
Expand Down
Loading