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

Add warning for specified unavailable formatter #462

Open
azu opened this issue Jan 13, 2018 · 0 comments
Open

Add warning for specified unavailable formatter #462

azu opened this issue Jan 13, 2018 · 0 comments
Labels
good first issue Good for newcomers Status: Proposal Request for comments Type: Enhance

Comments

@azu
Copy link
Member

azu commented Jan 13, 2018

Currently, textlint --format unavailable-formatter throw error.

$ textlint -f unavailable-formatter README.md
✖ Error
formatter is not a function

✖ Stack trace
TypeError: formatter is not a function

But, this error is not meaningful.
We should check the formatter is available before liting.

Motivation

From #148

textlint has two type formatter.
One is linter formater, Anther is fixer formatter

This difference cause unexepected error in following scenario.

First, You run lint a text.

texlint -f pretty-error README.md

Then, the lint result has error message.

Second, You want to fix this error, and run textlint --fix.

texlint --fix -f pretty-error README.md

texlint --fix -f pretty-error throw error!
Because, fixer formater not have pretty-error formatter.

We want to add warning for this scenario.

Tasks

  • Add resolveFormatter(name: string): string | null to formatter modules
  • Add check script in cli.execute

execute(args: string | Array<any> | object, text: string): Promise<number> {

Check logic

  • Lint mode
    • If linterFormatter.resolveFormatter() return null, show warning and exit 1.
  • Fix(--fix) mode
    • If fixerFormatter.resolveFormatter() return null, show warning and exit 1.

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Status: Proposal Request for comments Type: Enhance
Projects
None yet
Development

No branches or pull requests

1 participant