-
Notifications
You must be signed in to change notification settings - Fork 51
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
Differentially treat specific blocks (use new processor API) #139
Comments
This is a very good suggestion and I would be in favor of exploiting those new APIs and remove a bit of dirty monkey patching from my plugin 😃 But as you noted, the biggest challenge is to mark variables as defined and used accross script tags (for non-module scripts). The processor API also lacks the ability to access the configuration I will keep this in mind and may find a way to use the new APIs while keeping a bit of monkeypatching for the blocking points. |
Are you working on this? It should not be difficult based on my experience by fixing If you haven't started, I can help to start the job when I'm free. |
I create https://github.com/nice-move/eslint-plugin-html to do this, not been published yet. I'm a rookie at making |
@Airkro : Ni hao and congratulations on getting a plugin working! It's great to see some movement on this, and it look like you took a sound approach. However, besides benefiting the other users of this plugin, a PR might ensure that all of the logic with |
I want to send a PR to https://github.com/BenoitZugmeyer/eslint-plugin-html, but it's difficult for me. let's see if anyone can help? I try to read the code of But I will try to solute the |
@Airkro I think you'd need to fork this repository, then copy your changes across from your repo into the fork on a new branch. You could then push your changes to your fork and request a PR from there. |
One option here would be to provide to different processors in the plugin - one for xml and one for html. The configuration can then specify which processor to use for which file extension.
I think it might be reasonable to ask core ESLint for an extension of the API to allow specifying the module/script type in the |
Description
#123 ties into this (and perhaps could be considered with this), though that issue is focused on inline event handler blocks, and this issue is more for the blocks that are already discovered by
eslint-plugin-html
(though supporting their differential treatment).If supporting the new ESLint processor API, (as
eslint-plugin-markdown
is now doing in their v2.0.0), this should I think alloweslint-plugin-html
to support the following:overrides
config (rules
, etc.) for specific script tagstype="module"
on the script tags could be used to determine whether the blocks are modules or not (rather than projectparserOptions.sourceType
config) they should be weaved together for purposes of undefined/unused variables (since files can have a mix of type or no type).(Of course, one would only wish to do this if the current beneficial ability to treat the blocks as tied together for purposes of undefined/used variables could be continued when non-module scripts were in use. If necessary, perhaps the non-modules could be strung together even if it means they could not have separate config, while allowing the modules to be treated as the separate entities they are.)
Alternatives
One can use external files and lint those by file name.
Additional context
See:
I'll admit this is not a burning need I have, but I figured it might be worth a look given ESLint's support for the approach, and that the Markdown plugin is now doing so.
Thanks for the great plug-in!
The text was updated successfully, but these errors were encountered: