Remove HTMLHint from being require()'d and instead use window global like other linters #4962
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm working on integrating CodeMirror into WordPress core to be part of the November release of 4.9. The work is being done in the Better Code Editing feature plugin. In order to improve performance of loading CodeMirror, we needed to create a bundle of the assets that we're going to be using. See WordPress/better-code-editing#92 if helpful.
When using Browserify, however, I came across a problem where HTMLHint was being imported into the bundle unlike the other linting libraries which all look at
window
. When HTMLHint is imported into the bundle, then there is nowindow.HTMLHint
for other scripts to interface with. This is a particular problem in this case because the plugin adds a new rule to HTMLHint to flag HTML as invalid if the user does not have permission (e.g. to add scripts).So I suggest, to better align with all of the other linters, that CodeMirror defer to
window.HTMLHint
as well.