Error: Required option 'getAnnotations' missing (lint addon)
See original GitHub issueHello, 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:
- Created 9 years ago
- Comments:16 (5 by maintainers)
Top GitHub Comments
Hi, I was getting the same error. It was being caused when I included the lint specific CodeMirror options (
gutters: ["CodeMirror-lint-markers"]
andlint: true
) when in the wrong mode. For example, when CodeMirror is inhtmlmixed
mode those options will generate the error, but when injavascript
mode it’s okay. So add a condition that checks the mode and only include them when necessary.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?