posthtml-hint
posthtml-hint copied to clipboard
[discuss] I am trying to add the path information of linted js files to the report
Just as the title, because now, the report of errors, for example
PostHTML HINT
-------------
✖ error [10:12]
Special characters must be escaped : [ > ].
✖ error [12:3]
Special characters must be escaped : [ < ].
✖ error [12:21]
Special characters must be escaped : [ < ].
✖ error [12:30]
Special characters must be escaped : [ > ].
✖ error [15:17]
Tag must be paired, no start tag: [ </h1> ]
⚠ 5 Errors
there is no information about where they come from,
And I try to add the information to it,
but, the information (the parameter, tree
) passed by postHTML isn't enough.
It seems we should do something on postHTML to pass more information to plugins, isn't it?
PS, by the way, I fix some typo, to pass the test and building. https://github.com/posthtml/posthtml-hint/pull/2
Agreed tree.options.from
could be used to get the path but the plugins needs to be updated and options.from
must be set (Gulp, webpack) will do 'automatically'
plugin.js
module.exports = function posthtmlPlugin (options) {
options = Object.assign({}, options)
return function (tree) {
console.log(tree.options.from)
}
}
Node API
posthtml([ require('posthtml-hint')() ]).process(html, { from: 'path/to/file.html' })...
I just check the new version of posthtml-loader, It seems that you guys already add the path information to the parameter by the loader, great!! waiting for the release!
but, It seems that the plugins of posthtml have the dependency on webpack/gulp/...., isn't it, so without those builders, the ecosystem of posthtml will be weak, isn't it?
Yep gulp-posthtml
, posthtml-loader
and friends normally add this for you, they are using the Node API and have there own File I/O handling :stuck_out_tongue: the example above is the bare Node API uncommon to be used directly, despite you're a Plugin and/or Middleware Developer :)
? Plugins only depend on posthtml, and posthtml depends on the library it is integrated to when it comes to File I/O (the library has it's own logic to handle it)
If you use the posthtml Node API and plugin x and don't set e.g the { from: ''}
parameter you're lost yes 😛 . But shouldn't be a real problem
sure, it is no a real problem now, but if someday there are more requests just like { from: ''}
.
more friendly handler will be necessary, I think.
sorry, just a little over consideration
more friendly handler will be necessary, I think.
How ? 🙃
If a developer wants to use options which depend on builder like { from: ''}
, there is a friendly notice in debug-time for that?