Skip to content

Commit

Permalink
feat(textlint): fixer support
Browse files Browse the repository at this point in the history
- Update textlint-rule-prh for fixer support
- Update textlint-tester for fixer
- Update README about fixer
  • Loading branch information
azu committed Mar 5, 2016
1 parent 0497911 commit 7dccdca
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
18 changes: 17 additions & 1 deletion README.md
@@ -1,4 +1,4 @@
# textlint-rule-preset-JTF-style [![Build Status](https://travis-ci.org/azu/textlint-rule-preset-JTF-style.svg?branch=master)](https://travis-ci.org/azu/textlint-rule-preset-JTF-style)
# textlint-rule-preset-JTF-style [![textlint rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/) [![Build Status](https://travis-ci.org/azu/textlint-rule-preset-JTF-style.svg?branch=master)](https://travis-ci.org/azu/textlint-rule-preset-JTF-style)

[JTF日本語標準スタイルガイド(翻訳用)](https://www.jtf.jp/jp/style_guide/styleguide_top.html "JTF日本語標準スタイルガイド(翻訳用)") for [textlint](https://github.com/textlint/textlint "textlint").

Expand Down Expand Up @@ -54,6 +54,22 @@ npm run-script経由で実行すれば、`node_modules/.bin/`は省略出来ま

- [npm で依存もタスクも一元化する - Qiita](http://qiita.com/Jxck_/items/efaff21b977ddc782971#%E3%82%BF%E3%82%B9%E3%82%AF%E3%81%AE%E5%AE%9F%E8%A1%8C "npm で依存もタスクも一元化する - Qiita")

## 自動修正

使用するルールの設定が終わったら、`textlint`を実行してみてください。
沢山のエラーが表示されると思います。

[![textlint rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/)

`textlint-rule-preset-JTF-style`の一部ルールは`textlint``--fix`にも対応しています。
`--fix`を使うことで機械的に判断して修正出来る部分は自動修正します。

```sh
textlint --fix /path/to/target.md
```

実際にファイルを書き換えるので、必ずファイルをコピーしておくなどしてファイルを戻せるようにしてから実行してください。

### サンプル

[example/](example/) に実行できるサンプルプロジェクトがあります。
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Expand Up @@ -11,7 +11,7 @@
"author": "azu",
"license": "MIT",
"devDependencies": {
"textlint": "^5.5.2-0",
"textlint": "^5.5.3",
"textlint-rule-preset-jtf-style": "file:.."
}
}
7 changes: 2 additions & 5 deletions package.json
Expand Up @@ -41,7 +41,7 @@
"glob": "^7.0.0",
"mocha": "^2.3.3",
"textlint": "^5.5.2-0",
"textlint-tester": "^0.5.1-0"
"textlint-tester": "^0.5.1"
},
"dependencies": {
"analyze-desumasu-dearu": "^2.1.2",
Expand All @@ -50,9 +50,6 @@
"regx": "^1.0.4",
"sorted-joyo-kanji": "^0.2.0",
"textlint-rule-helper": "^1.1.3",
"textlint-rule-prh": "^2.0.0"
},
"peerDependencies": {
"textlint": ">= 5.1.0 || 5.5.2-0"
"textlint-rule-prh": "^2.4.0"
}
}
2 changes: 1 addition & 1 deletion src/2.1.5.js
Expand Up @@ -28,7 +28,7 @@ function toZenkaku(string) {
function reporter(context) {
let {Syntax, fixer, report, getSource} = context;
// 辞書ベースのカタカタ表記のチェックを行う
let dictRule = prh(context, {
let dictRule = prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.1.5.yml")]
});
let originalStrRule = dictRule[Syntax.Str];
Expand Down
2 changes: 1 addition & 1 deletion src/2.1.6.js
Expand Up @@ -11,7 +11,7 @@ import prh from "textlint-rule-prh";
import path from "path";
export default function (context) {
// 辞書ベースのカタカナ末尾の長音のチェックを行う
return prh(context, {
return prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.1.6.yml")]
});
}
2 changes: 1 addition & 1 deletion src/2.2.1.js
Expand Up @@ -17,7 +17,7 @@ JTFスタイルガイドは、ひらがなと漢字の使い分けについて
import prh from "textlint-rule-prh";
import path from "path";
export default function (context) {
return prh(context, {
return prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.2.1.yml")]
});
}
2 changes: 1 addition & 1 deletion src/2.2.3.js
Expand Up @@ -7,7 +7,7 @@
import prh from "textlint-rule-prh";
import path from "path";
export default function (context) {
return prh(context, {
return prh.fixer(context, {
rulePaths: [path.join(__dirname, "..", "dict", "2.2.3.yml")]
});
}

0 comments on commit 7dccdca

Please sign in to comment.