Skip to content

feat(textlint): add prh rule #49

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

Merged
merged 2 commits into from
Sep 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .textlintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"no-mix-dearu-desumasu": true,
"no-start-duplicated-conjunction": {
"interval": 2
},
"prh": {
"rulePaths": [
"test/prh-rule.yaml"
]
}
}
}
4 changes: 2 additions & 2 deletions ja/connect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
> この文章はConnect 3.4.0を元に書かれています。

[Connect](https://github.com/senchalabs/connect "Connect")はNode.jsで動くHTTPサーバフレームワークです。
_middleware_という拡張する仕組みを持っていて、connectが持つ機能自体はとても少ないです
_middleware_という拡張する仕組みを持っていて、Connectが持つ機能自体はとても少ないです

この章ではconnectの_middleware_の仕組みついて見て行きましょう
この章ではConnectの_middleware_の仕組みついて見て行きましょう

## どう書ける?

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"textlint-rule-max-ten": "^1.1.0",
"textlint-rule-no-mix-dearu-desumasu": "^1.0.1",
"textlint-rule-no-start-duplicated-conjunction": "^1.0.3",
"textlint-rule-prh": "^1.0.1",
"textlint-rule-spellcheck-tech-word": "^4.0.1"
},
"dependencies": {
Expand Down
68 changes: 68 additions & 0 deletions test/prh-rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: 1
rules:

# 大文字小文字全角半角の統一
- expected: Cookie
# 以下と等価 正規表現には強制でgフラグが付く
# - expected: Cookie
# pattern: "/[CcCc][OoOo][OoOo][KkKk][IiIi][EeEe]/g"
# options:
# wordBoundary: false
# specs: []

# 変換結果についてテストも書ける
- expected: jQuery
specs:
- from: jquery
to: jQuery
- from: JQUERY
to: jQuery

# 変換結果が期待通りではなかった場合、ルールのロードに失敗する
# - expected: JavaScript
# specs:
# - from: JAVASCRIPT
# to: JavaScprit # この場合はテスト側が間違ってる!
# Error: JavaScript spec failed. "JAVASCRIPT", expected "JavaScprit", but got "JavaScript", /[JjJj][AaAa][VvVv][AaAa][SsSs][CcCc][RrRr][IiIi][PpPp][TtTt]/g

# 表現の統一を図る
- expected: デフォルト
pattern: ディフォルト

# patternは複数記述可能
- expected: ハードウェア
pattern:
- ハードウエアー
- ハードウエア # 正規表現に変換する都合上短いものを後に書いたほうがよい
- ハードウェアー

# patternには正規表現が利用可能 否定戻り先読みが欲しい…(JSにはない
- expected: $1ソフトウェア
pattern: /([^経])ソフトウエア/
specs:
# 普通に変換
- from: 広義のソフトウエア
to: 広義のソフトウェア
# 日経ソフトウエア(書名)は変換しない
- from: 日経ソフトウエア
to: 日経ソフトウエア

# 単語境界の区別
- expected: js
# pattern: "/\b[JjJj][SsSs]\b/g" # と等価 \b が前後に付与される
options:
wordBoundary: true
specs:
- from: foo JS bar
to: foo js bar
- from: foo altJS bar
to: foo altJS bar
# 日本語+単語境界の仕様は自分で調べてね…!
- from: 今日もJS祭り
to: 今日もjs祭り

- expected: ESLint
- expected: Connect
specs:
- from: connect
to: Connect