codemirror5: Error: Required option 'getAnnotations' missing (lint addon)

Hello, I’m using a compressed CodeMirror script and attempting to enable Javascript linting functionality and getting the above error (all other add-ons work, just not this one).

Is it possible that linting won’t work if a compressed all-in-one CodeMirror script is used?

The reason I ask is because I think I’m doing everything correctly with the only significant difference from the demo page being the order of scripts loading because the lint demo example page shows the jshint script referenced after codemirror.js and /mode/javascript/javascript.js but before /addon/lint/lint.js and /addon/lint/javascript-lint.js etc, however I’m using the single compressed script:

/* CodeMirror - Minified & Bundled
   Generated on 1/7/2014 with http://codemirror.net/doc/compress.html
   Version: HEAD

   CodeMirror Library:
   - codemirror.js
   Modes:
   - css.js
   - htmlmixed.js
   - javascript.js
   - xml.js
   Add-ons:
   - brace-fold.js
   - closebrackets.js
   - closetag.js
   - colorize.js
   - comment.js
   - comment-fold.js
   - css-hint.js
   - dialog.js
   - foldcode.js
   - foldgutter.js
   - html-hint.js
   - javascript-hint.js
   - javascript-lint.js
   - json-lint.js
   - lint.js
   - mark-selection.js
   - match-highlighter.js
   - matchbrackets.js
   - matchtags.js
   - search.js
   - searchcursor.js
   - show-hint.js
   - trailingspace.js
   - xml-fold.js
   - xml-hint.js
   Keymaps:
   - sublime.js
 */
...etc..

I’ve tried loading JSHINT before the CodeMirror script, and after but still get the same error.

This is my config:

 matchBrackets: true,
                autoCloseBrackets: true,
                matchTags: true,
                showTrailingSpace: true,
                lineNumbers: true,
                highlightSelectionMatches: true,
                extraKeys: {
                    'Ctrl-Q': function(cm) {
                        cm.foldCode(cm.getCursor());
                    },
                    'Ctrl-Space': 'autocomplete'
                },
                lint: true,
                foldGutter: true,
                gutters: ['CodeMirror-lint-markers','CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
                mode: 'javascript'

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Hi, I was getting the same error. It was being caused when I included the lint specific CodeMirror options (gutters: ["CodeMirror-lint-markers"] and lint: true) when in the wrong mode. For example, when CodeMirror is in htmlmixed mode those options will generate the error, but when in javascript mode it’s okay. So add a condition that checks the mode and only include them when necessary.