2016-03-30 57 views
0

我之前在Codemirror上玩過CoffeeScript,我不知道爲什麼,但linting不能與Codemirror一起工作。即使是Codemirror包提供的lint也不適合我。在Codemirror上顯示CoffeeScript Lint

我在做什麼錯,我該如何解決這個問題?

// Initialize CodeMirror editor 
 
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 
 
    mode: "text/x-coffeescript", 
 
    tabMode: "indent", 
 
    styleActiveLine: true, 
 
    lineNumbers: true, 
 
    lineWrapping: true, 
 
    autoCloseTags: true, 
 
    foldGutter: true, 
 
    dragDrop: true, 
 
    lint: true, 
 
    gutters: ["CodeMirror-lint-markers", "CodeMirror-linenumbers", "CodeMirror-foldgutter"] 
 
})
.CodeMirror { 
 
    width: 100%; 
 
    height: auto; 
 
}
<link rel="stylesheet" href="https://necolas.github.io/normalize.css/4.0.0/normalize.css"> 
 
<link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css"> 
 
<link rel="stylesheet" href="http://codemirror.net/addon/fold/foldgutter.css"> 
 
<link rel="stylesheet" href="http://codemirror.net/addon/hint/show-hint.css"> 
 
<link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css"> 
 

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="http://codemirror.net/lib/codemirror.js"></script> 
 
<script src="http://codemirror.net/mode/javascript/javascript.js"></script> 
 
<script src="http://codemirror.net/mode/xml/xml.js"></script> 
 
<script src="http://codemirror.net/mode/css/css.js"></script> 
 
<script src="http://codemirror.net/mode/htmlmixed/htmlmixed.js"></script> 
 
<script src="http://codemirror.net/addon/edit/closetag.js"></script> 
 
<script src="http://codemirror.net/addon/edit/matchbrackets.js"></script> 
 
<script src="http://codemirror.net/addon/selection/active-line.js"></script> 
 
<script src="http://codemirror.net/addon/fold/foldcode.js"></script> 
 
<script src="http://codemirror.net/addon/fold/foldgutter.js"></script> 
 
<script src="http://codemirror.net/addon/fold/brace-fold.js"></script> 
 
<script src="http://codemirror.net/addon/fold/xml-fold.js"></script> 
 
<script src="http://codemirror.net/addon/fold/comment-fold.js"></script> 
 
<script src="http://coffeescript.org/extras/coffee-script.js"></script> 
 
<script src="http://coffeelint.org/js/coffeelint.js"></script> 
 
<script src="http://codemirror.net/mode/coffeescript/coffeescript.js"></script> 
 
<script src="http://codemirror.net/addon/lint/coffeescript-lint.js"></script> 
 

 
<textarea id="code">function() {}</textarea>

+0

如果有咖啡上鏡那麼鏡像將無法正常工作,你可能期望。我建議下載Cloth或Rag,並使用'Cloth.wipe()'或'Rag.spitOn().wipe()'。我希望這有幫助。 – Chrillewoodz

+0

咖啡鏡子只是'coffeescript-lint.js'文件需要的。我不熟悉布料或抹布。 –

回答

1

http://kodeweave.sourceforge.net/editor/#362e030f5d37beb17766999e92ef4e88

哈哈滑稽的錯誤。我忘了添加lint.js

<script src="http://codemirror.net/addon/lint/lint.js"></script> 

使用此功能的任何人的簡要說明。我試圖刷新皮棉與editor.refresh()刷新CodeMirror實例讓CoffeeScript的絨毛,而不是JavaScript的絨毛在我的編輯,但我可以得到它的工作的唯一辦法是禁用絨毛,並與重新啓用...

editor.setOption("lint", false) 
editor.setOption("lint", true) 

這是摘錄!

// Initialize CodeMirror editor 
 
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 
 
    mode: "text/x-coffeescript", 
 
    tabMode: "indent", 
 
    styleActiveLine: true, 
 
    lineNumbers: true, 
 
    lineWrapping: true, 
 
    autoCloseTags: true, 
 
    foldGutter: true, 
 
    dragDrop: true, 
 
    lint: true, 
 
    gutters: ["CodeMirror-lint-markers", "CodeMirror-linenumbers", "CodeMirror-foldgutter"] 
 
})
.CodeMirror { 
 
    width: 100%; 
 
    height: auto; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<link rel="stylesheet" href="https://necolas.github.io/normalize.css/4.0.0/normalize.css"> 
 
<link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css"> 
 
<link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css"> 
 
<script src="http://codemirror.net/lib/codemirror.js"></script> 
 
<script src="http://codemirror.net/addon/lint/lint.js"></script> 
 
<script src="http://codemirror.net/mode/coffeescript/coffeescript.js"></script> 
 
<script src="http://coffeescript.org/extras/coffee-script.js"></script> 
 
<script src="http://coffeelint.org/js/coffeelint.js"></script> 
 
<script src="http://codemirror.net/addon/lint/coffeescript-lint.js"></script> 
 

 
<textarea id="code">function() {} 
 
    
 
# Initialize CodeMirror editor 
 
editor = CodeMirror.fromTextArea(document.getElementById('code'), 
 
    mode: 'text/x-coffeescript' 
 
    tabMode: 'indent' 
 
    styleActiveLine: true 
 
    lineNumbers: true 
 
    lineWrapping: true 
 
    autoCloseTags: true 
 
    foldGutter: true 
 
    dragDrop: true 
 
    lint: true 
 
    gutters: [ 
 
    'CodeMirror-lint-markers' 
 
    'CodeMirror-linenumbers' 
 
    'CodeMirror-foldgutter' 
 
    ])</textarea>

相關問題