question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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'

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicholaswrightcommented, Jul 24, 2014

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.

0reactions
Mad-Chemistcommented, Jul 25, 2016

As @nicholaswright mentioned above, I get this error consistently when using “htmlmixed” as my mode. As soon as I choose “javascript” for my mode, the error stops happening and linting works properly.

Any suggestions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 ...
Read more >
CodeMirror - get linting result from outside of the editor
There isn't a specific method to get the linting results, but there is a hook provided when you define a getAnnotations property in...
Read more >
CodeMirror 5 User Manual
See below for a full discussion of the configuration options that CodeMirror accepts. In cases where you don't want to append the editor...
Read more >
lint + html mixed mode - codemirror@googlegroups.com
I'm trying to use the lint plugin with html mixed mode and it always results in this error: ... getAnnotations) throw new Error("Required...
Read more >
CodeMirror: User Manual
See below for a full discussion of the configuration options that CodeMirror accepts. In cases where you don't want to append the editor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found