How to use a custom linter after calling CodeMirror.registerHelper()

I am currently building a code editor with a custom mode.
This is how it is defined:

    let codeMirror = CodeMirror.fromTextArea(textArea,
      {
        mode: "customMode",
        lint: true,
        theme: customtheme,
      }

I then create a custom linter, defined as:

  CodeMirror.registerHelper("lint", "customMode", function (text) {
    // the "myLint()" function returns an array of error objects
    // each object has a "from", "to", "severity", and "message" property
    let errorsArray = myLint(text)
    return errorsArray ;
});

If run the command
console.log(CodeMirror.lint.customMode(code));
An array of error objects is printed to the console, each with a “to”, “from”, “severity” and “message” property. What I’m wondering is, how do I use this function so that these errors can be underlined in red in the code editor?
Thank you

That should just work automatically, if you’ve loaded the lint addon (and make sure to register the helper before creating the editor).

1 Like

Thank you very much! It turns out I wasn’t properly importing the lint addon!