Skip to content

Commit 5e5f293

Browse files
committed
docs(README): Update REAME
1 parent 7cbe76c commit 5e5f293

File tree

2 files changed

+156
-1
lines changed

2 files changed

+156
-1
lines changed

README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,96 @@ This rule check the spell by used with `prh.yml`.
3030

3131
`textlint-rule-prh` support `--fix` feature of textlint.
3232

33-
### What is prh.yml?
33+
```sh
34+
textlint --fix README.md
35+
```
36+
37+
## What is prh.yml?
3438

3539
Please See [vvakame/prh](https://github.com/vvakame/prh "vvakame/prh").
3640

41+
### prh format
42+
43+
`prh.yml` can define RegExp as a dictionary.
44+
45+
```yaml
46+
# prh version
47+
version: 1
48+
rules:
49+
50+
# format case-sensitive
51+
- expected: Cookie
52+
# the above is equal to following
53+
# - expected: Cookie
54+
# pattern: "/[CcCc][OoOo][OoOo][KkKk][IiIi][EeEe]/g"
55+
# options:
56+
# wordBoundary: false
57+
# specs: []
58+
59+
# Write test to `expect`
60+
- expected: jQuery
61+
specs:
62+
- from: jquery
63+
to: jQuery
64+
- from: JQUERY
65+
to: jQuery
66+
67+
# If the `specs` is failed、fail to load prh.yml
68+
# - expected: JavaScript
69+
# specs:
70+
# - from: JAVASCRIPT
71+
# to: JavaScprit
72+
# Error: JavaScript spec failed. "JAVASCRIPT", expected "JavaScprit", but got "JavaScript", /[JjJj][AaAa][VvVv][AaAa][SsSs][CcCc][RrRr][IiIi][PpPp][TtTt]/g
73+
74+
# pattern => expected
75+
- expected: default
76+
pattern: deflaut
77+
78+
# Allow to write multiple `pattern`
79+
- expected: hardware
80+
patterns:
81+
- hadware
82+
- harrdware
83+
- harddware
84+
85+
# Allow to write `pattern` as RegExp
86+
# Can use $1...$9
87+
# Should wrap `/` and `/`
88+
# ECMAScript
89+
- expected: ECMAScript $1
90+
patterns:
91+
- /ECMAScript([0-9]+)/
92+
- /ECMA Script([0-9]+)/
93+
specs:
94+
- from: ECMAScript2015
95+
to: ECMAScript 2015
96+
97+
# expected contain pattern
98+
# https://github.com/azu/textlint-rule-prh/pull/8
99+
- expected: ベンダー
100+
pattern: /ベンダ(?!ー)/
101+
specs:
102+
- from: ベンダ
103+
to: ベンダー
104+
- from: ベンダー
105+
to: ベンダー
106+
# wordBoundary option
107+
- expected: js
108+
# === pattern: "/\b[JjJj][SsSs]\b/g"
109+
options:
110+
wordBoundary: true
111+
specs:
112+
- from: foo JS bar
113+
to: foo js bar
114+
- from: foo altJS bar
115+
to: foo altJS bar
116+
```
117+
118+
## Example
119+
120+
See [azu/prh-textlint-example: Example of textlint + prh.](https://github.com/azu/prh-textlint-example "azu/prh-textlint-example: Example of textlint + prh.").
121+
122+
37123
## Tests
38124
39125
npm test

test/fixtures/prh.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# prh version
2+
version: 1
3+
rules:
4+
5+
# format case-sensitive
6+
- expected: Cookie
7+
# the above is equal to following
8+
# - expected: Cookie
9+
# pattern: "/[CcCc][OoOo][OoOo][KkKk][IiIi][EeEe]/g"
10+
# options:
11+
# wordBoundary: false
12+
# specs: []
13+
14+
# Write test to `expect`
15+
- expected: jQuery
16+
specs:
17+
- from: jquery
18+
to: jQuery
19+
- from: JQUERY
20+
to: jQuery
21+
22+
# If the `specs` is failed、fail to load prh.yml
23+
# - expected: JavaScript
24+
# specs:
25+
# - from: JAVASCRIPT
26+
# to: JavaScprit
27+
# Error: JavaScript spec failed. "JAVASCRIPT", expected "JavaScprit", but got "JavaScript", /[JjJj][AaAa][VvVv][AaAa][SsSs][CcCc][RrRr][IiIi][PpPp][TtTt]/g
28+
29+
# pattern => expected
30+
- expected: default
31+
pattern: deflaut
32+
33+
# Allow to write multiple `pattern`
34+
- expected: hardware
35+
patterns:
36+
- hadware
37+
- harrdware
38+
- harddware
39+
40+
# Allow to write `pattern` as RegExp
41+
# Should wrap `/` and `/`
42+
# ECMAScript
43+
- expected: ECMAScript $1
44+
patterns:
45+
- /ECMAScript([0-9]+)/
46+
- /ECMA Script([0-9]+)/
47+
specs:
48+
- from: ECMAScript2015
49+
to: ECMAScript 2015
50+
51+
# expected contain pattern
52+
# https://github.com/azu/textlint-rule-prh/pull/8
53+
- expected: ベンダー
54+
pattern: /ベンダ(?!ー)/
55+
specs:
56+
- from: ベンダ
57+
to: ベンダー
58+
- from: ベンダー
59+
to: ベンダー
60+
# wordBoundary option
61+
- expected: js
62+
# === pattern: "/\b[JjJj][SsSs]\b/g"
63+
options:
64+
wordBoundary: true
65+
specs:
66+
- from: foo JS bar
67+
to: foo js bar
68+
- from: foo altJS bar
69+
to: foo altJS bar

0 commit comments

Comments
 (0)