Search code examples
javascriptcodemirror

How to fix "Error: HTMLHint not found, ..., CodeMirror HTML linting cannot run." error in CodeMirror


I want to get HTML linting working for my CodeMirror instance. I'm able to get CSS and JS linting working fine but HTML linting is not working. I'm still getting the "Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run." error in the console log for HTML. Where do I include the global "HTMLHint" variable?

I have already downloaded the required HTML linting file (// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js) and linked it in the "<head>".

<head>
       <script src="plugin/HTMLHint-develop/dist/htmlhint.js"></script>
</head>

<script>
        var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
            theme: "rubyblue",
            mode: "htmlmixed",
            scrollbarStyle: "simple",
            indentUnit: 4,
            lineNumbers: true,
            lineWrapping: true,
            foldGutter: true,
            lint: true
        });
</script>

I would expect that the linting would work based on the "<script></script>" tag. Obviously I must be missing something.


Solution

  • Within the HTML Hint js file it says:

    // Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js

    Here is a working link in github.

    https://raw.githubusercontent.com/htmlhint/brackets-htmlhint/master/htmlhint/htmlhint.js

    Simply include it in your page.