Closed tengattack closed 6 years ago
Nice! I think the --stdin-file-path
option is kind of confusing, since there's not a real file involved (the path is just used as a name for output, right?). It's also kind of strange that it works with no file name given but then uses the name "true". I will probably change it to --stdin
and use a default filename of "stdin".
The --format
option should also list possible values in the help. It would be nice if it got these dynamically from lib/formatters
, but I doubt there will be too many formatters so that's probably overkill.
I use the option --stdin-file-path
by extracting HTML content from other kinds of language or template (like EJS, PHP).
I think providing full file path can help us to identify the original source file name (like path, extension, etc.) for rules and plugins so that they could be enabled or not through the config file based on the path pattern or the file name extension.
I definitely agree that the name option to --stdin-file-path
is useful. It's just that calling it --stdin-file-path
rather than --stdin
is confusing: it seems like it's purpose is just to set the file path for stdin and there should be some other option to enable it in the first place.
I changed the option name to --stdin
and changed the help text to something I find clearer. I also changed the behavior when --stdin
is used without a value so that the filename "stdin" is used, rather than "true". Does that work for you?
Oh I see, I misunderstood before. That’s work for me.
version 0.0.7 not contains this feature and how write custom formatter ?
Hi, I didn't know why 0.0.7 not contains this feature, maybe we could ask the maintainer @mlochbaum
If you need to write custom formatter, you could take a look at: https://github.com/htmllint/htmllint-cli/blob/acb3029dbd7a5000407bfb474d522d3c9f714eb2/lib/formatters/index.js#L2-L5 formatter predefined there.
And then, you can take a look at the simple formatter: https://github.com/htmllint/htmllint-cli/blob/master/lib/formatters/simple.js
It contains two functions only, and I think it's easy to understand.
how call the custom formatter? only accept this two format
Currently, we can only call the custom formatter by adding it to the source code like above json
formatter.
Hi,
I add formatter and stdin options to this cli command line interface.
I think it would help if we can specify lint result output format to JSON format.
Usage shown as blow: