Skip to content
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

File extension wildcard support for the extensions option #577

Open
robstewart57 opened this issue Jan 4, 2019 · 3 comments
Open

File extension wildcard support for the extensions option #577

robstewart57 opened this issue Jan 4, 2019 · 3 comments

Comments

@robstewart57
Copy link

What version of textlint are you using?

11.0.1

What did you do? Please include the actual source code causing the issue.

Running textlint on a file with an arbitrary file extension or no file extension at all, e.g.

npx textlint --config .textlintrc --rule write-good file.xyz
npx textlint --config .textlintrc --rule write-good file

With the .textlintrc contents:

{
    "plugins": {
        "@textlint/text": {
            "extensions": [".org"]
        }
    }
}

What did you expect to happen?

No output.

Feature request.

The output from the write-good rule for the contents of files file.xyz and file.

Is it possible to use wildcards with the extensions option? E.g.

"extensions": [".*","*"]

If not, is this feature be supported with other flags or options?

@azu
Copy link
Member

azu commented Jan 5, 2019

Currently, wildcard is not supported in @textlint/textlint-plugin-markdown and @textlint/textlint-plugin-text.
We can implement wildcard on extensions options using micromatch library, but I wonder if wildcard support is really necessary?

For instance, Adding forceMatch option resolve this issue?
I feel that we need to search other suitable resolution.

Ho does other tools resolve this issue? etc...

The output from the write-good rule for the contents of files file.xyz and file.

texlint depended on file extension.
But, I found a workaround for this.

{
  "plugins": {
    "@textlint/markdown": {
      // "" match non-ext file
      "extensions": [""]
    }
  },
  "filters": {},
  "rules": {
    "write-good": true
  }
}

@robstewart57
Copy link
Author

For instance, Adding forceMatch option resolve this issue?

That sounds plausible. In which case:

What did you do?

Not use --forceMatch:

npx textlint --plugin @textlint/text --rule write-good file.xyz

What did you expect to happen?

No output.

What did you do?

Use --forceMatch:

npx textlint --plugin @textlint/text --rule write-good --forceMatch file.xyz

What did you expect to happen?

file.xyz:1:10: "were made" may be passive voice [Error/write-good]

@azu
Copy link
Member

azu commented Jan 30, 2019

textlint has multiple plugins by default.
So, --forceMatch(only) can not help textlint to use which plugin.

prettier's overrides feature is similar approach.
It force match files and parser.

However, I want to avoid complex feature like overrides.

📝 I found a workaround: use --stdin and --stdin-filename for faking file path.

cat file.xyz | textlint --stdin --stdin-filename file.txt --plugin @textlint/text --rule write-good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants