textlint-rule / textlint-rule-prh

textlint rule for prh.
MIT License
82 stars 6 forks source link

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

Closed dai0304 closed 6 years ago

dai0304 commented 6 years ago

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.

azu commented 6 years ago

Thanks for report.

Does textlint.json equals to .textlintrc? Do you use textlint --config docs/config/textlint.json docs/contents/ in project-2?

dai0304 commented 6 years ago

Yes! I forgot to tell you.

azu commented 6 years ago

textlint-rule-prh treat rulePaths as relative path from .textlintrc(textlint.json) (This document is missed, I've add it now #32)

For example is project-2.

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

and Put following config to textlint.json:

{
  "rules": {
    "prh": {
      "rulePaths": [
        "./prh-rules/foo.yml"
      ]
    }
  }
}

textlint-rule-prh treat "./rules/rule.yml" as relative path from ./docs/config/textlint.json. As a result, textlint-rule-prh load ./docs/config/./rules/rule.yml

I've tried to reproduce this issue. https://github.com/azu/textlint-rule-prh-issues-31 But, it seems that it work expectly.

Can you write following results?

$ textlint --version
# Version
$ textlint --debug --config docs/config/textlint.json docs/contents/
# or
$ DEBUG=textlint* textlint --config docs/config/textlint.json docs/contents/
dai0304 commented 6 years ago

I used textlint-rule-prh@2.4.1. In the latest version 5.0.1, it works fully expected!

Thank you for your kindness!