https://github.com/textlint-rule/textlint-rule-prh
textlint rule for prh.
https://github.com/textlint-rule/textlint-rule-prh
textlintrule
Last synced: about 1 month ago
JSON representation
textlint rule for prh.
- Host: GitHub
- URL: https://github.com/textlint-rule/textlint-rule-prh
- Owner: textlint-rule
- License: mit
- Created: 2015-09-12T15:59:04.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-20T12:49:59.000Z (2 months ago)
- Last Synced: 2025-05-01T08:45:13.414Z (about 2 months ago)
- Topics: textlintrule
- Language: JavaScript
- Size: 3 MB
- Stars: 87
- Watchers: 2
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# textlint-rule-prh [](https://textlint.github.io/) [](https://github.com/textlint-rule/textlint-rule-prh/actions?query=workflow%3A"test")
[textlint](https://github.com/textlint-rule/textlint "textlint") rule for [prh/prh: proofreading helper](https://github.com/prh/prh "prh/prh: proofreading helper").
This rule check the spell by used with `prh.yml`.
## Installation
npm install textlint-rule-prh
## Usage
1. It require Rule Options!
```json
{
"rules": {
"prh": {
"rulePaths" :["path/to/prh.yml"]
}
}
}
```### Options
- `rulePaths`(required) : array of path to YAML file from `.textlintrc` file
```json
{
"rules": {
"prh": {
"rulePaths" :["./prh-rules/rule1.yml", "./prh-rules/rule2.yml"]
}
}
}
```You can use `~` as Home directory abbreviation.
```json
{
"rules": {
"prh": {
"rulePaths" :["~/global-rule/rule1.yml"]
}
}
}
```- `checkLink`(optional) : Check `Link` node type (default: `false`)
- `checkBlockQuote`(optional) : Check `BlockQuote` node type (default: `false`)
- `checkEmphasis`(optional) : Check `Emphasis` node type (default: `false`)
- `checkHeader`(optional) : Check `Header` node type (default: `true`)
- `checkCodeComment`(optional) : Check `CodeBlock` node's comment for `lang` (default: `[]`)
- Set `lang` array like `[""]` for checking CodeBlock
- Example: If you want to check JavaScript CodeBlock, set `{ "checkCodeComment": ["js", "javascript"] }` Options
- **Note:** Currently only support JavaScript CodeBlock
- It use [@babel/parser](https://babeljs.io/docs/en/babel-parser)**Examples**:
```json
{
"rules": {
"prh": {
"checkEmphasis": true,
"checkHeader": false,
"rulePaths" :["./prh.yml"]
}
}
}
```Check CodeBlock's comment in JavaScript Code.
```json
{
"rules": {
"prh": {
"checkCodeComment": ["js", "javascript"],
"rulePaths" :["./prh.yml"]
}
}
}
```### Fixable
[](https://textlint.github.io/)
`textlint-rule-prh` support `--fix` feature of textlint.
```sh
textlint --fix README.md
```## What is prh.yml?
Please See [prh/prh: proofreading helper](https://github.com/prh/prh "prh/prh: proofreading helper").
### prh format
`prh.yml` can define RegExp as a dictionary.
```yaml
# prh version
version: 1
rules:# format case-sensitive
- expected: Cookie
# the above is equal to following
# - expected: Cookie
# pattern: "/[CcCc][OoOo][OoOo][KkKk][IiIi][EeEe]/g"
# options:
# wordBoundary: false
# specs: []# Write test to `expect`
- expected: jQuery
specs:
- from: jquery
to: jQuery
- from: JQUERY
to: jQuery# If the `specs` is failed、fail to load prh.yml
# - 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# pattern => expected
- expected: default
pattern: deflaut# Allow to write multiple `pattern`
- expected: hardware
patterns:
- hadware
- harrdware
- harddware# Allow to write `pattern` as RegExp
# Can use $1...$9
# Should wrap `/` and `/`
# ECMAScript
- expected: ECMAScript $1
patterns:
- /ECMAScript([0-9]+)/
- /ECMA Script([0-9]+)/
specs:
- from: ECMAScript2015
to: ECMAScript 2015# expected contain pattern
# https://github.com/textlint-rule/textlint-rule-prh/pull/8
- expected: ベンダー
pattern: /ベンダ(?!ー)/
specs:
- from: ベンダ
to: ベンダー
- from: ベンダー
to: ベンダー
# wordBoundary option
- expected: js
# === pattern: "/\b[JjJj][SsSs]\b/g"
options:
wordBoundary: true
specs:
- from: foo JS bar
to: foo js bar
- from: foo altJS bar
to: foo altJS bar
```#### imports
`prh.yml` can import other yaml file
```yaml
version: 1imports:
- imports-a.yml
- imports-b.yml
```## Example
See [example-prh.yml](https://github.com/textlint-rule/textlint-rule-prh/blob/master/test/fixtures/example-prh.yml).
## Tests
npm test
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## License
MIT