Code Monkey home page Code Monkey logo

textlint-rule-prh's Introduction

textlint-rule-prh textlint rule Actions Status: test

textlint rule for 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!
{
    "rules": {
        "prh": {
            "rulePaths" :["path/to/prh.yml"]
        }
    }
}

Options

  • rulePaths(required) : array of path to YAML file from .textlintrc file
{
    "rules": {
        "prh": {
            "rulePaths" :["./prh-rules/rule1.yml", "./prh-rules/rule2.yml"]
        }
    }
}

You can use ~ as Home directory abbreviation.

{
    "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 ["<codeblock-lang>"] for checking CodeBlock
    • Example: If you want to check JavaScript CodeBlock, set { "checkCodeComment": ["js", "javascript"] } Options
    • Note: Currently only support JavaScript CodeBlock

Examples:

{
    "rules": {
        "prh": {
            "checkEmphasis": true,
            "checkHeader": false,
            "rulePaths" :["./prh.yml"]
        }
    }
}

Check CodeBlock's comment in JavaScript Code.

{
    "rules": {
        "prh": {
            "checkCodeComment": ["js", "javascript"],
            "rulePaths" :["./prh.yml"]
        }
    }
}

Fixable

textlint rule

textlint-rule-prh support --fix feature of textlint.

textlint --fix README.md

What is prh.yml?

Please See prh/prh: proofreading helper.

prh format

prh.yml can define RegExp as a dictionary.

# 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

version: 1

imports:
  - imports-a.yml
  - imports-b.yml

Example

See 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

textlint-rule-prh's People

Contributors

azu avatar chocoby avatar greenkeeper[bot] avatar leko avatar orangain avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

textlint-rule-prh's Issues

An error occurs `Cannot find module '@textlint/ast-node-types'`

I found this error on Nov 1st.
No special modifications were made to use textlint.
I ran it with textlint "filename" .

Error
Cannot find module '@textlint/ast-node-types'
Require stack:
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint-rule-prh\node_modules\textlint-rule-helper\lib\textlint-rule-helper.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint-rule-prh\node_modules\textlint-rule-helper\lib\index.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint-rule-prh\lib\textlint-rule-prh.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\engine\textlint-module-loader.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\engine\textlint-engine-core.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\textlint-engine.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\cli.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\bin\textlint.js

Stack trace
Error: Cannot find module '@textlint/ast-node-types'
Require stack:
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint-rule-prh\node_modules\textlint-rule-helper\lib\textlint-rule-helper.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint-rule-prh\node_modules\textlint-rule-helper\lib\index.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint-rule-prh\lib\textlint-rule-prh.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\engine\textlint-module-loader.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\engine\textlint-engine-core.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\textlint-engine.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\lib\src\cli.js
- C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint\bin\textlint.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\fxY90cc\AppData\Roaming\npm\node_modules\textlint-rule-prh\node_modules\textlint-rule-helper\lib\textlint-rule-helper.js:3:24)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

It is probably due to the effect of the textlint-rule-helper commit that you executed around October 31.
Can you tell me how to solve this problem?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac
  • actions/setup-node v4
npm
package.json
  • @babel/parser ^7.24.5
  • prh ^5.4.4
  • textlint-rule-helper ^2.3.1
  • @textlint/legacy-textlint-core ^14.0.4
  • lint-staged ^15.2.2
  • textlint 14.0.4
  • textlint-scripts ^14.0.4

  • Check this box to trigger a request for Renovate to run again on this repository

Support browser

use fromYAML insteadof fromYAMLFilePath for browserify friendly.

add ruleContents option for textlint-rule-prh.

リンクについてtextlint-rule-prhの対象にならない

事象

自分の環境では、[xxx](yyy)<yyy>のようなリンクについて、textlint-rule-prhの対象になりません。

checkLinkをtrueとして設定すればリンクも対象になるかと期待したのですが、対象にならないままでした。
こちらは仕様なのでしょうか? それとも環境(Apple M2)が悪いのでしょうか...。

image

たとえば、以下のようなリンクがある場合、textlint対象になって欲しいと思っています。

- [Title](Link) -> NG(NamedLink)

このように設定しました。

  - expected: NamedLink
    pattern:
      - /\[Title\]\(Link\)/

参考情報

checkEmphasis:true, checkHeader:falseは効いているため、checkLink:trueの設定箇所誤りではなさそうです。
https://github.com/textlint-rule/textlint-rule-prh/blob/master/README.md#options

環境

npx: 10.2.4
textlint: v14.0.4
Application: Visual Studio Code - Insiders
Version: 1.89.0-insider (Universal)
Commit: 903ce35c77c7b5714a2d9063b9f1d9bc2956d07c
Date: 2024-04-11T05:50:09.275Z (17 hrs ago)
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 21.6.0

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (@azu)

null

間違えて立ててしまいました。
削除をお願いいたします。

An in-range update of mocha is breaking the build 🚨

Version 3.4.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.4.0

Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.

This week's highlights:

  • allowUncaught added to commandline as --allow-uncaught (and bugfixed)
  • warning-related Node flags

🎉 Enhancements

🐛 Fixes

🔩 Other

Commits

The new version differs by 9 commits0.

  • 7554b31 Add Changelog for v3.4.0
  • 9f7f7ed Add --trace-warnings flag
  • 92561c8 Add --no-warnings flag
  • ceee976 lint test/integration/fixtures/simple-reporter.js
  • dcfc094 Revert "use semistandard directly"
  • 93392dd no special case for macOS running Karma locally
  • 4d1d91d --allow-uncaught cli option
  • fb1e083 fix allowUncaught in browser
  • 4ed3fc5 Add license report and scan status

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Is there a way to specify rulePaths based on the path of textlint.json?

I want to share textlint configuration with multiple projects using git-subtree.
But configuration directory (subtree prefix) is not the same across all projects.

For example, there is following textlint-config repository.

.
|-- textlint.json
`-- prh-rules/
    `-- foo.yml

And the following projects, which share the configuration using git-subtree.

. (project-1)
|-- config/ (subtree)
|   |-- textlint.json
|   `-- prh-rules/
|       `-- foo.yml
`-- contents/
    `-- ...
. (project-2)
|-- src/
|   `-- ...
`-- docs/
    |-- config/ (subtree)
    |   |-- textlint.json
    |   `-- prh-rules/
    |       `-- foo.yml
    `-- contents/
        `-- ...

In the project-1 rulePaths must to be set as config/prh-rules/foo.yml,
but in the project-2 this have to be docs/config/prh-riles/foo.yml.

Any suggestions?
Thanks.

Question: prh.ymlのpatternsに指定した文字列がうまくマッチしない

はじめまして、textlintでHTML内に含まれる特定の文字列を検出したいと考えているのですが、うまく対象の文字列にヒットしません。

どこに問題があるのかわからず、こちらに質問をさせていただきました。

HTMLのタグ内(属性値など)を含む全コードに対して検査をしたいので、あえて@textlint/textlint-plugin-textを利用しています。

.textlintrc

{
  "filters": {},
  "rules": {
    "prh": {
      "rulePaths": ["./prh.yml"]
    }
  },
  "plugins": {
    "@textlint/text": {
        "extensions": [".html"]
    }
  }
}

prh.yml

version: 1
rules:
  - expected: textlint
    patterns: TextLint

test.html

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<p>テキストテキストテキストテキストテキストテキストテキストテキスト</p>
<p>TextLint</p>
<p>TextLintが好きです</p>
<p>私はTextLintが好きです</p>
<p>私は TextLint が好きです</p>
</body>
</html>

本来であれば、9, 10, 11, 12行目に指摘が入るはずだと思うのですが 10 行目にしか指摘が入りません。
なにか改善方法などありましたらご教授いただけないでしょうか。

Proposal: Add options to customize filter AST type

Currently, filtered AST types are Link, Image, BlockQuote, Emphasis.

if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {

I want to add Header to the blacklist.
But it cannot set as default behavior. It's not needed in many use cases.
So I propose to support ignoreSyntax option.

  • Type: Array<String> (optional)
  • Default values: [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis]

How about it?

Dependency deprecation warning: babel-preset-es2015 (npm)

On registry https://registry.npmjs.org/, the "latest" version (v6.24.1) of dependency babel-preset-es2015 has the following deprecation notice:

🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Affected package file(s): package.json

If you don't care about this, you can close this issue and not be warned about babel-preset-es2015's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.